BaseNavigationalTransition { @SuppressWarnings("unchecked") @SafeVarargs public final T sharedElements(@NonNull final Pair<View, String>... elements) { if (sharedElements == null) { this.sharedElements = new ArrayList<>(1); } this.sharedElements.addAll(Arrays.asList(elements)); return (T) this; } BaseNavigationalTransition();  BaseNavigationalTransition(@NonNull final Class<? extends Activity> classOfTransitionActivity); @SuppressWarnings("deprecation") @Nullable final Class<? extends Activity> getActivityClass(); @SuppressWarnings("unchecked") T intentExtras(@Nullable final Bundle extras); @NonNull Bundle intentExtras(); @SuppressWarnings("unchecked") T requestCode(@IntRange(from = RC_NONE) final int requestCode); @IntRange(from = RC_NONE) int requestCode(); @SuppressWarnings("unchecked") T enterTransition(@Nullable final Transition transition); @Nullable Transition enterTransition(); @SuppressWarnings("unchecked") T reenterTransition(@Nullable final Transition transition); @Nullable Transition reenterTransition(); @SuppressWarnings("unchecked") T returnTransition(@Nullable final Transition transition); @Nullable Transition returnTransition(); @SuppressWarnings("unchecked") T exitTransition(@Nullable final Transition transition); @Nullable Transition exitTransition(); @SuppressWarnings("unchecked") T allowEnterTransitionOverlap(final boolean allow); boolean allowEnterTransitionOverlap(); @SuppressWarnings("unchecked") T allowReturnTransitionOverlap(final boolean allow); boolean allowReturnTransitionOverlap(); @SuppressWarnings("unchecked") T sharedElementEnterTransition(@Nullable final Transition transition); @Nullable Transition sharedElementEnterTransition(); @SuppressWarnings("unchecked") T sharedElementReenterTransition(@Nullable final Transition transition); @Nullable Transition sharedElementReenterTransition(); @SuppressWarnings("unchecked") T sharedElementReturnTransition(@Nullable final Transition transition); @Nullable Transition sharedElementReturnTransition(); @SuppressWarnings("unchecked") T sharedElementExitTransition(@Nullable final Transition transition); @Nullable Transition sharedElementExitTransition(); @SuppressWarnings("unchecked") T sharedElementsUseOverlay(final boolean useOverlay); boolean sharedElementsUseOverlay(); @SuppressLint("NewApi") @Nullable Transition inflateTransition(@NonNull final Context context, final int resource); @SuppressLint("NewApi") @Nullable TransitionManager inflateTransitionManager(@NonNull final Context context, final int resource, @NonNull final ViewGroup sceneRoot); @SuppressWarnings("unchecked") @SafeVarargs final T sharedElements(@NonNull final Pair<View, String>... elements); @SuppressWarnings("unchecked") T sharedElement(@NonNull final View element, @NonNull final String elementName); @Nullable List<Pair<View, String>> sharedElements(); @Nullable Pair<View, String> singleSharedElement(); void start(@NonNull final Activity caller); void configureTransitions(@NonNull final Activity activity); void configureIncomingTransitions(@NonNull final Activity activity); void configureOutgoingTransitions(@NonNull final Activity activity); @SuppressLint("NewApi") @SuppressWarnings("unchecked") @Nullable ActivityOptions makeSceneTransitionAnimation(@NonNull final Activity caller); @NonNull Intent createIntent(@NonNull final Activity caller); void finish(@NonNull final Activity caller); static final boolean MATERIAL_SUPPORT; static final int RC_NONE; }
@SuppressWarnings("ConstantConditions") @Test public void testSharedElements() { final TestTransition transition = new TestTransition(); final View firstElement = new View(context); final View secondElement = new View(context); final View thirdElement = new View(context); transition.sharedElements( new Pair<>(firstElement, "first_element"), new Pair<>(secondElement, "second_element") ); transition.sharedElements(new Pair<>(thirdElement, "third_element")); final List<Pair<View, String>> sharedElements = transition.sharedElements(); assertThat(sharedElements, is(notNullValue())); assertThat(sharedElements.size(), is(3)); assertThat(sharedElements.get(0).first, is(firstElement)); assertThat(sharedElements.get(0).second, is("first_element")); assertThat(sharedElements.get(1).first, is(secondElement)); assertThat(sharedElements.get(1).second, is("second_element")); assertThat(sharedElements.get(2).first, is(thirdElement)); assertThat(sharedElements.get(2).second, is("third_element")); }