use of androidx.core.app.ActivityOptionsCompat in project CloudReader by youlookwhat.
the class FilmDetailActivity method start.
/**
* @param context activity
* @param positionData bean
* @param imageView imageView
*/
public static void start(Activity context, FilmItemBean positionData, ImageView imageView) {
Intent intent = new Intent(context, FilmDetailActivity.class);
intent.putExtra("bean", positionData);
ActivityOptionsCompat options = // 与xml文件对应
ActivityOptionsCompat.makeSceneTransitionAnimation(context, imageView, CommonUtils.getString(R.string.transition_movie_img));
ActivityCompat.startActivity(context, intent, options.toBundle());
}
use of androidx.core.app.ActivityOptionsCompat in project CloudReader by youlookwhat.
the class BigImagePagerActivity method startThis.
public static void startThis(final AppCompatActivity activity, List<View> imageViews, List<String> imageUrls, int enterIndex) {
Intent intent = new Intent(activity, BigImagePagerActivity.class);
intent.putStringArrayListExtra(KEY_IMAGE_URLS, (ArrayList<String>) imageUrls);
intent.putExtra(KEY_ENTER_INDEX, enterIndex);
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, imageViews.get(enterIndex), imageUrls.get(enterIndex));
try {
ActivityCompat.startActivity(activity, intent, optionsCompat.toBundle());
} catch (IllegalArgumentException e) {
e.printStackTrace();
activity.startActivity(intent);
}
ActivityCompat.setExitSharedElementCallback(activity, new SharedElementCallback() {
@Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
super.onMapSharedElements(names, sharedElements);
/* 这个方法会调用两次,一次进入前,一次回来前。 */
if (sExitIndex == null) {
return;
}
int exitIndex = sExitIndex;
sExitIndex = null;
if (exitIndex != enterIndex && imageViews.size() > exitIndex && imageUrls.size() > exitIndex) {
names.clear();
sharedElements.clear();
View view = imageViews.get(exitIndex);
String transitName = imageUrls.get(exitIndex);
if (view == null) {
activity.setExitSharedElementCallback((SharedElementCallback) null);
return;
}
names.add(transitName);
sharedElements.put(transitName, view);
}
activity.setExitSharedElementCallback((SharedElementCallback) null);
}
});
}
use of androidx.core.app.ActivityOptionsCompat in project Tusky by Vavassor.
the class SFragment method viewMedia.
protected void viewMedia(int urlIndex, List<AttachmentViewData> attachments, @Nullable View view) {
final AttachmentViewData active = attachments.get(urlIndex);
Attachment.Type type = active.getAttachment().getType();
switch(type) {
case GIFV:
case VIDEO:
case IMAGE:
case AUDIO:
{
final Intent intent = ViewMediaActivity.newIntent(getContext(), attachments, urlIndex);
if (view != null) {
String url = active.getAttachment().getUrl();
ViewCompat.setTransitionName(view, url);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), view, url);
startActivity(intent, options.toBundle());
} else {
startActivity(intent);
}
break;
}
default:
case UNKNOWN:
{
LinkHelper.openLink(active.getAttachment().getUrl(), getContext());
break;
}
}
}
use of androidx.core.app.ActivityOptionsCompat in project GankTouTiao by heqiangflytosky.
the class AppUtils method startImageBrowserActivity.
public static void startImageBrowserActivity(View view, int index) {
if (view == null || view.getContext() == null) {
return;
}
Activity activity = (Activity) view.getContext();
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, String.valueOf(index));
Intent intent = new Intent(activity, ImageBrowserActivity.class);
// intent.putExtra(ImageBrowserActivity.EXTRA_DATA, (Serializable)list);
intent.putExtra(ImageBrowserActivity.EXTRA_INDEX, index);
activity.startActivity(intent, options.toBundle());
// activity.overridePendingTransition(0, 0);
}
Aggregations