Java Code Examples for androidx.core.app.ActivityOptionsCompat#makeSceneTransitionAnimation()

The following examples show how to use androidx.core.app.ActivityOptionsCompat#makeSceneTransitionAnimation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoutingHelper.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void startPhotoActivity(Activity a, View image, View background, Photo photo, int currentIndex) {
    Bundle b = new Bundle();
    ActivityOptionsCompat optionsCompat;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        optionsCompat = ActivityOptionsCompat.makeScaleUpAnimation(
                background,
                (int) background.getX(), (int) background.getY(),
                background.getMeasuredWidth(), background.getMeasuredHeight()
        );
    } else {
        optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(
                a,
                new Pair<>(image, a.getString(R.string.transition_photo_image) + "_" + photo.id),
                new Pair<>(background, a.getString(R.string.transition_photo_image) + "_" + photo.id)
        );
    }
    ARouter.getInstance()
            .build(PhotoActivity.PHOTO_ACTIVITY)
            .withParcelable(PhotoActivity.KEY_PHOTO_ACTIVITY_PHOTO, photo)
            .withInt(PhotoActivity.KEY_PHOTO_ACTIVITY_CURRENT_INDEX, currentIndex)
            .withString(PhotoActivity.KEY_PHOTO_ACTIVITY_ID, photo.id)
            .withBundle(a.getString(R.string.transition_photo_image), b)
            .withOptionsCompat(optionsCompat)
            .navigation(a);
}
 
Example 2
Source File: LatestFragment.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onItemClick(View view, final int position) {
    //Toast.makeText(getActivity(),"item click detected", Toast.LENGTH_SHORT).show();
    if(position < 0 || position >= listNovelItemInfo.size()) {
        // ArrayIndexOutOfBoundsException
        Toast.makeText(getActivity(), "ArrayIndexOutOfBoundsException: " + position + " in size " + listNovelItemInfo.size(), Toast.LENGTH_SHORT).show();
        return;
    }

    // go to detail activity
    Intent intent = new Intent(getActivity(), NovelInfoActivity.class);
    intent.putExtra("aid", listNovelItemInfo.get(position).aid);
    intent.putExtra("from", "latest");
    intent.putExtra("title", listNovelItemInfo.get(position).title);
    if(Build.VERSION.SDK_INT < 21) {
        startActivity(intent);
    }
    else {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                Pair.create(view.findViewById(R.id.novel_cover), "novel_cover"),
                Pair.create(view.findViewById(R.id.novel_title), "novel_title"));
        ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
    }
}
 
Example 3
Source File: SharedElementsComponentSpec.java    From litho with Apache License 2.0 6 votes vote down vote up
@OnEvent(ClickEvent.class)
static void onClickEvent(
    ComponentContext c, @FromEvent View view, @Param int color, @State boolean landLitho) {
  Activity activity = (Activity) c.getAndroidContext();
  Intent intent = new Intent(c.getAndroidContext(), DetailActivity.class);
  intent.putExtra(INTENT_COLOR_KEY, color);
  intent.putExtra(INTENT_LAND_LITHO, landLitho);
  ActivityOptionsCompat options =
      ActivityOptionsCompat.makeSceneTransitionAnimation(
          activity,
          new Pair<View, String>(view, SQUARE_TRANSITION_NAME),
          new Pair<View, String>(
              activity.getWindow().getDecorView().findViewWithTag(TITLE_TRANSITION_NAME),
              TITLE_TRANSITION_NAME));
  activity.startActivity(intent, options.toBundle());
}
 
Example 4
Source File: NovelItemListFragment.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onItemClick(View view, final int position) {
    //Toast.makeText(getActivity(),"item click detected", Toast.LENGTH_SHORT).show();
    if(position < 0 || position >= listNovelItemAid.size()) {
        // ArrayIndexOutOfBoundsException
        Toast.makeText(getActivity(), "ArrayIndexOutOfBoundsException: " + position + " in size " + listNovelItemAid.size(), Toast.LENGTH_SHORT).show();
        return;
    }

    // go to detail activity
    Intent intent = new Intent(getActivity(), NovelInfoActivity.class);
    intent.putExtra("aid", listNovelItemAid.get(position));
    intent.putExtra("from", "list");
    intent.putExtra("title", ((TextView) view.findViewById(R.id.novel_title)).getText());

    if(Build.VERSION.SDK_INT < 21) {
        startActivity(intent);
    }
    else {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                Pair.create(view.findViewById(R.id.novel_cover), "novel_cover"),
                Pair.create(view.findViewById(R.id.novel_title), "novel_title"));
        ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
    }
}
 
Example 5
Source File: UserDetailActivity.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
public static void openWithAnimation(Activity activity, String username, ImageView imgAvatar, String avatarUrl) {
    Intent intent = new Intent(activity, UserDetailActivity.class);
    intent.putExtra("loginName", username);
    intent.putExtra("avatarUrl", UrlUtils.getAvaterurlm(avatarUrl));
    needAnimate = true;
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imgAvatar, NAME_IMG_AVATAR);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
 
Example 6
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到视频播放
 *
 * @param activity
 * @param view
 */
public static void goToVideoPickPlayer(Activity activity, View view) {
    Intent intent = new Intent(activity, PlayPickActivity.class);
    intent.putExtra(PlayActivity.TRANSITION, true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION);
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, pair);
        ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
    }
}
 
Example 7
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转列表带广告
 *
 * @param activity
 */
public static void goToADListVideoPlayer(Activity activity) {
    //Intent intent = new Intent(activity, ListADVideoActivity.class);
    Intent intent = new Intent(activity, ListADVideoActivity2.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 8
Source File: OneMovieDetailActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * @param context      activity
 * @param positionData bean
 * @param imageView    imageView
 */
public static void start(Activity context, SubjectsBean positionData, ImageView imageView) {
    Intent intent = new Intent(context, OneMovieDetailActivity.class);
    intent.putExtra("bean", positionData);
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(context,
                    imageView, CommonUtils.getString(R.string.transition_movie_img));//与xml文件对应
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
 
Example 9
Source File: TransitionHelper.java    From YcShareElement with Apache License 2.0 5 votes vote down vote up
public static Bundle getTransitionBundle(Activity activity, View... shareViews) {
    if (!ENABLE || shareViews == null) {
        return null;
    }
    List<Pair<View, String>> pairs = new ArrayList<>();
    //添加ShareElements
    for (int i = 0; i < shareViews.length; i++) {
        View view = shareViews[i];
        pairs.add(Pair.create(view, view.getTransitionName()));
    }
    Pair<View, String>[] pairsArray = new Pair[pairs.size()];
    pairs.toArray(pairsArray);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairsArray);
    return options.toBundle();
}
 
Example 10
Source File: RoutingHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void startCollectionActivity(Activity a,
                                           View avatar, View background, Collection c) {
    Bundle b = new Bundle();
    ActivityOptionsCompat optionsCompat;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        optionsCompat = ActivityOptionsCompat.makeScaleUpAnimation(
                background,
                (int) background.getX(), (int) background.getY(),
                background.getMeasuredWidth(), background.getMeasuredHeight()
        );
    } else {
        Recolor.addExtraProperties(background, b);
        RoundCornerTransition.addExtraProperties(background, b);

        optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(
                a,
                Pair.create(avatar, a.getString(R.string.transition_collection_avatar)),
                Pair.create(background, a.getString(R.string.transition_collection_background))
        );
    }

    ARouter.getInstance()
            .build(CollectionActivity.COLLECTION_ACTIVITY)
            .withParcelable(CollectionActivity.KEY_COLLECTION_ACTIVITY_COLLECTION, c)
            .withBundle(a.getString(R.string.transition_collection_background), b)
            .withOptionsCompat(optionsCompat)
            .navigation(a);
}
 
Example 11
Source File: TEIDataPresenterImpl.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void seeDetails(View sharedView, DashboardProgramModel dashboardProgramModel) {
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(view.getAbstractActivity(), sharedView, "user_info");
    view.seeDetails(EnrollmentActivity.Companion.getIntent(view.getContext(),
            dashboardProgramModel.getCurrentEnrollment().uid(),
            dashboardProgramModel.getCurrentProgram().uid(),
            EnrollmentActivity.EnrollmentMode.CHECK,
            false), options.toBundle());
}
 
Example 12
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到无UI视频播放
 *
 * @param activity
 * @param view
 */
public static void goToPlayEmptyControlActivity(Activity activity, View view) {
    Intent intent = new Intent(activity, PlayEmptyControlActivity.class);
    intent.putExtra(PlayActivity.TRANSITION, true);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION);
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, pair);
        ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
    } else {
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out);
    }
}
 
Example 13
Source File: VODAdapter.java    From Twire with GNU General Public License v3.0 5 votes vote down vote up
@Override
void handleElementOnClick(final View view) {
    final int itemPosition = getRecyclerView().getChildAdapterPosition(view);
    VideoOnDemand item = getElements().get(itemPosition);
    if (activity instanceof VODActivity) {
        ((VODActivity) activity).startNewVOD(item);
    } else {
        Intent intent = VODActivity.createVODIntent(item, getContext());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            intent.putExtra(getContext().getString(R.string.stream_preview_url), item.getMediumPreview());
            intent.putExtra(getContext().getString(R.string.stream_preview_alpha), hasVodBeenWatched(item.getVideoId()) ? VOD_WATCHED_IMAGE_ALPHA : 1.0f);

            final View sharedView = view.findViewById(R.id.image_stream_preview);
            sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
            final ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));

            activity.setExitSharedElementCallback(new SharedElementCallback() {
                @SuppressLint("NewApi")
                @Override
                public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                    super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

                    sharedView.animate().alpha(VOD_WATCHED_IMAGE_ALPHA).setDuration(300).start();
                    activity.setExitSharedElementCallback(null);
                }
            });

            activity.startActivity(intent, options.toBundle());
        } else {
            getContext().startActivity(intent);
            activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
        }
    }
}
 
Example 14
Source File: TransitionActivityMain.java    From android-test with Apache License 2.0 5 votes vote down vote up
/**
 * Called when an item in the {@link android.widget.GridView} is clicked. Here will launch the
 * {@link TransitionDetailActivity}, using the Scene Transition animation functionality.
 */
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    TransitionActivityItem item =
        (TransitionActivityItem) adapterView.getItemAtPosition(position);

    // Construct an Intent as normal
    Intent intent = new Intent(this, TransitionDetailActivity.class);
    intent.putExtra(TransitionDetailActivity.EXTRA_PARAM_ID, item.getId());

    /**
     * Now create an {@link android.app.ActivityOptions} instance using the
     * {@link ActivityOptionsCompat#makeSceneTransitionAnmation(Activity, Pair[])} factory
     * method.
     */
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
        this,

        // Now we provide a list of Pair items which contain the view we can transitioning
        // from, and the name of the view it is transitioning to, in the launched activity
        new Pair<View, String>(view.findViewById(R.id.imageview_item),
            TransitionDetailActivity.VIEW_NAME_HEADER_IMAGE),
        new Pair<View, String>(view.findViewById(R.id.textview_name),
            TransitionDetailActivity.VIEW_NAME_HEADER_TITLE));

    // Now we can start the Activity, providing the activity options as a bundle
    ActivityCompat.startActivity(this, intent, activityOptions.toBundle());
}
 
Example 15
Source File: DetailActivity.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void launch(Activity activity, String attraction, View heroView) {
    Intent intent = getLaunchIntent(activity, attraction);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, heroView, heroView.getTransitionName());
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
 
Example 16
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到视频列表
 *
 * @param activity
 */
public static void goToVideoPlayer(Activity activity) {
    Intent intent = new Intent(activity, ListVideoActivity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 17
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到视频列表2
 *
 * @param activity
 */
public static void goToVideoPlayer2(Activity activity) {
    Intent intent = new Intent(activity, ListVideo2Activity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 18
Source File: ChannelsAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
@Override
void handleElementOnClick(final View view) {
	int itemPosition = getRecyclerView().getChildAdapterPosition(view);
	final ChannelInfo item = getElements().get(itemPosition);
	final StreamerInfoViewHolder vh = (StreamerInfoViewHolder) getRecyclerView().getChildViewHolder(view);
	final PreviewTarget previewTarget = getTargets().get(vh.getTargetsKey());

	// Create intent for opening StreamerInfo activity. Send the StreamerInfo object with
	// the intent, and flag it to make sure it creates a new task on the history stack
	final Intent intent = new Intent(getContext(), ChannelActivity.class);
	intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), item);
	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		View sharedView = view.findViewById(R.id.profileLogoImageView);
		sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
		final ActivityOptionsCompat options = ActivityOptionsCompat.
				makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

		activity.setExitSharedElementCallback(new SharedElementCallback() {
			@SuppressLint("NewApi")
			@Override
			public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
				super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

				if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
					View element = sharedElements.get(0);
					Animation anim = new RoundImageAnimation(element.getWidth()/2, 0, (ImageView) element, previewTarget.getPreview());
					anim.setDuration(200);
					anim.setInterpolator(new DecelerateInterpolator());
					view.startAnimation(anim);
				}
				activity.setExitSharedElementCallback(null);
			}
		});
		activity.startActivity(intent, options.toBundle());
	} else {
		getContext().startActivity(intent);
		if(activity != null) {
			activity.overridePendingTransition(R.anim.slide_in_right_anim, R.anim.fade_out_semi_anim);
		}
	}
}
 
Example 19
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到视频列表
 *
 * @param activity
 */
public static void goToVideoRecyclerPlayer(Activity activity) {
    Intent intent = new Intent(activity, RecyclerViewActivity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}
 
Example 20
Source File: JumpUtils.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
/**
 * 跳转到硬解码
 *
 * @param activity
 */
public static void goMediaCodec(Activity activity) {
    Intent intent = new Intent(activity, RecyclerView3Activity.class);
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(activity);
    ActivityCompat.startActivity(activity, intent, activityOptions.toBundle());
}