This file contains 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
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<ImageView | |
android:id="@+id/logo" | |
android:layout_width="90dp" | |
android:layout_height="90dp" | |
android:layout_alignParentBottom="true" |
This file contains 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
private void performTransaction(F fromFragment, F toFragment, List<String> transitionElements) | |
{ | |
if (fromFragment == null) | |
{ // if there is no Fragment loaded, the Activity does not exist anymore | |
return; | |
} | |
FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction(); | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) | |
{ |
This file contains 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
for (View sharedView : fromFragment.getSharedElements()) | |
{ | |
if (transitionElements.contains(sharedView.getTransitionName())) | |
{ | |
fragmentTransaction.addSharedElement(sharedView, sharedView.getTransitionName()); | |
} | |
} |
This file contains 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
// Enter Shared Elements Transition | |
TransitionSet enterTransitionSet = new TransitionSet(); | |
enterTransitionSet.addTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); | |
enterTransitionSet.setDuration(TRANSITION_DEFAULT_TIME); | |
toFragment.setSharedElementEnterTransition(enterTransitionSet); | |
// Exit Shared Elements Transition | |
TransitionSet exitTransitionSet = new TransitionSet(); | |
exitTransitionSet.addTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); | |
exitTransitionSet.setDuration(TRANSITION_DEFAULT_TIME); |
This file contains 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
// Enter Transition | |
Fade fade = new Fade(); | |
fade.setStartDelay(TRANSITION_DEFAULT_TIME); | |
toFragment.setEnterTransition(fade); | |
// Exit Transition | |
toFragment.setExitTransition(new Fade()); |
This file contains 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
// Enter Transition | |
Fade fade = new Fade(); | |
fade.setStartDelay(TRANSITION_DEFAULT_TIME); | |
toFragment.setEnterTransition(fade); |
This file contains 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
public class SimpleFragment extends Fragment implements ViewWithSharedElements | |
{ | |
private static final String RESOURCE_LAYOUT = "RESOURCE_LAYOUT"; | |
private int mLayoutResourceId; | |
@Nullable @BindView(R.id.logo) ImageView mLogo; | |
@Nullable @BindView(R.id.button) ImageButton mButton; | |
public SimpleFragment() | |
{ |
This file contains 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
private void setDelayedLoaders() | |
{ | |
Handler h1 = new Handler(); | |
h1.postDelayed(this::transition1, 1000); | |
Handler h2 = new Handler(); | |
h2.postDelayed(this::transition2, 3000); | |
Handler h3 = new Handler(); | |
h3.postDelayed(this::transition3, 5000); |
This file contains 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
private void loadInitialFragment() | |
{ | |
F fragment = (F) SimpleFragment.newInstance(R.layout.fragment_logo_center); | |
FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction(); | |
fragmentTransaction.replace(R.id.fragment_container, fragment); | |
fragmentTransaction.commit(); | |
} |