Last active
September 28, 2018 12:10
-
-
Save huan-nguyen/0ec738d68484e49c3cf625a2c9e85279 to your computer and use it in GitHub Desktop.
Updated code with tap position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override fun onViewCreated(view: View, savedState: Bundle?) { | |
| super.onViewCreated(view, savedState) | |
| tapPosition = savedState?.getInt(TAP_POSITION, NO_POSITION) ?: NO_POSITION | |
| postponeEnterTransition() | |
| ... | |
| } | |
| ... | |
| private fun render(state: State) { | |
| when (state) { | |
| ... | |
| is Success -> { | |
| ... | |
| (view?.parent as? ViewGroup)?.doOnPreDraw { | |
| if (exitTransition == null) { | |
| exitTransition = SlideExplode().apply { | |
| duration = TRANSITION_DURATION | |
| interpolator = transitionInterpolator | |
| } | |
| } | |
| val layoutManager = emailList.layoutManager as LinearLayoutManager | |
| layoutManager.findViewByPosition(tapPosition)?.let { view -> | |
| view.getGlobalVisibleRect(viewRect) | |
| (exitTransition as Transition).epicenterCallback = | |
| object : Transition.EpicenterCallback() { | |
| override fun onGetEpicenter(transition: Transition) = viewRect | |
| } | |
| } | |
| startPostponedEnterTransition() | |
| } | |
| } | |
| } | |
| } | |
| ... | |
| override fun onSaveInstanceState(outState: Bundle) { | |
| super.onSaveInstanceState(outState) | |
| outState.putInt(TAP_POSITION, tapPosition) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment