Search in sources :

Example 11 with ActivityOptionsCompat

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());
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat)

Example 12 with ActivityOptionsCompat

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);
        }
    });
}
Also used : Intent(android.content.Intent) SharedElementCallback(androidx.core.app.SharedElementCallback) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat) PhotoView(com.github.chrisbanes.photoview.PhotoView) View(android.view.View)

Example 13 with ActivityOptionsCompat

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;
            }
    }
}
Also used : AttachmentViewData(com.keylesspalace.tusky.viewdata.AttachmentViewData) Attachment(com.keylesspalace.tusky.entity.Attachment) Intent(android.content.Intent) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat)

Example 14 with ActivityOptionsCompat

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);
}
Also used : AboutMeActivity(com.android.hq.ganktoutiao.ui.activity.AboutMeActivity) ArticleDetailActivity(com.android.hq.ganktoutiao.ui.activity.ArticleDetailActivity) ImageBrowserActivity(com.android.hq.ganktoutiao.ui.activity.ImageBrowserActivity) Activity(android.app.Activity) Intent(android.content.Intent) ActivityOptionsCompat(androidx.core.app.ActivityOptionsCompat)

Aggregations

ActivityOptionsCompat (androidx.core.app.ActivityOptionsCompat)14 Intent (android.content.Intent)12 View (android.view.View)4 Activity (android.app.Activity)2 TextView (android.widget.TextView)2 SuppressLint (android.annotation.SuppressLint)1 ClipData (android.content.ClipData)1 ClipboardManager (android.content.ClipboardManager)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 LinkMovementMethod (android.text.method.LinkMovementMethod)1 Fade (android.transition.Fade)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 GONE (android.view.View.GONE)1 VISIBLE (android.view.View.VISIBLE)1 Button (android.widget.Button)1 ImageView (android.widget.ImageView)1 Toast (android.widget.Toast)1 ActionBar (androidx.appcompat.app.ActionBar)1