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 MainActivity extends Activity { | |
private static final String BACK_STACK_ROOT_TAG = "root_fragment"; | |
public void onTabSelected(int position) { | |
// Pop off everything up to and including the current tab | |
FragmentManager fragmentManager = getSupportFragmentManager(); | |
fragmentManager.popBackStack(BACK_STACK_ROOT_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); | |
// Add the new tab fragment | |
fragmentManager.beginTransaction() |
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 void addSubscreen(Fragment fragment) { | |
getSupportManager() | |
.beginTransaction() | |
.replace(R.id.container, fragment) | |
.addToBackStack(null) | |
.commit(); | |
subscreensOnTheStack++; | |
} | |
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 PicassoFragment extends Fragment { | |
private static final String KEY_WILL_ANIMATE_IMAGE = "keyWillAnimateImage"; | |
private boolean willAnimateImage; | |
/** | |
* Get a new PicassoFragment instance | |
* @param wilAnimateImage True if the image will animate in during the tragment transaction | |
*/ | |
public static PicassoFragment newInstance(boolean willAnimateImage) { |
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
/** | |
* Similar to {@link ChangeImageTransform}, but prior to capturing the end values for the transition | |
* it will copy the drawable from the starting image to the ending image. | |
* | |
* This allows the image transform to work when the end ImageView doesn't immediately have content, | |
* such as when the image will be loaded via Picasso. | |
* | |
* @author bherbst | |
*/ | |
@TargetApi(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
DetailsFragment details = DetailsFragment.newInstance(); | |
// Note that we need the API version check here because the actual transition classes (e.g. Fade) | |
// are not in the support library and are only available in API 21+. The methods we are calling on the Fragment | |
// ARE available in the support library (though they don't do anything on API < 21) | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
details.setSharedElementEnterTransition(new DetailsTransition()); | |
details.setEnterTransition(new Fade()); | |
setExitTransition(new Fade()); | |
details.setSharedElementReturnTransition(new DetailsTransition()); |
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 DetailsTransition extends TransitionSet { | |
public DetailsTransition() { | |
setOrdering(ORDERING_TOGETHER); | |
addTransition(new ChangeBounds()). | |
addTransition(new ChangeTransform()). | |
addTransition(new ChangeImageTransform())); | |
} | |
} |
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
<merge xmlns:android="http://schemas.android.com/apk/res/android" > | |
<RelativeLayout | |
android:layout_width="match_parent" | |
android:layout_height="0dp" | |
android:layout_weight="1" > | |
<ProgressBar | |
android:id="@+id/redBar" | |
style="@android:style/Widget.ProgressBar.Horizontal" |
NewerOlder