Search in sources :

Example 21 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project mvpanimation by androidMVP.

the class ExpandingAdapter method startActivity.

private void startActivity(Context context, Intent intent, ViewHolder viewHolder) {
    final Pair<View, String>[] pairs = createSafeTransitionParticipants((Activity) context, false, new Pair<>(viewHolder.avatar1, "avatar1"), new Pair<>(viewHolder.avatar2, "avatar2"), new Pair<>(viewHolder.mImageView, "image"));
    ActivityOptionsCompat transitionActivityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, pairs);
    context.startActivity(intent, transitionActivityOptions.toBundle());
}
Also used : ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Pair(android.support.v4.util.Pair)

Example 22 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project vialer-android by VoIPGRID.

the class MainActivity method openDialer.

/**
 * Show the dialer view
 */
public void openDialer() {
    Intent intent = new Intent(this, DialerActivity.class);
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, findViewById(R.id.floating_action_button), "floating_action_button_transition_name");
        startActivity(intent, options.toBundle());
    } else {
        startActivity(intent);
    }
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 23 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Now by XunMengWinter.

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);
    }
    activity.setExitSharedElementCallback(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) {
                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(android.support.v4.app.SharedElementCallback) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) View(android.view.View) PhotoView(com.github.chrisbanes.photoview.PhotoView) TextView(android.widget.TextView)

Example 24 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project butter-android by butterproject.

the class StreamLoadingActivity method startActivity.

public static Intent startActivity(Activity activity, StreamInfo info, Pair<View, String>... elements) {
    Intent intent = new Intent(activity, StreamLoadingActivity.class);
    intent.putExtra(EXTRA_INFO, info);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, elements);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
    return intent;
}
Also used : Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 25 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project opacclient by opacapp.

the class SearchResultListActivity method showDetail.

public void showDetail(SearchResult res, View coverView, int touchX, int touchY) {
    Bitmap cover = BitmapUtils.bitmapFromBytes(res.getCoverBitmap());
    Bitmap smallCover;
    if (cover != null && cover.getWidth() * cover.getHeight() > 300 * 300) {
        // Android's Parcelable implementation doesn't like huge images
        int max = Math.max(cover.getWidth(), cover.getHeight());
        int width = (int) ((300f / max) * cover.getWidth());
        int height = (int) ((300f / max) * cover.getHeight());
        smallCover = Bitmap.createScaledBitmap(cover, width, height, false);
    } else {
        smallCover = cover;
    }
    if (twoPane) {
        // In two-pane mode, show the detail view in this activity by
        // adding or replacing the detail fragment using a
        // fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putInt(SearchResultDetailFragment.ARG_ITEM_NR, res.getNr());
        if (res.getId() != null) {
            arguments.putString(SearchResultDetailFragment.ARG_ITEM_ID, res.getId());
        }
        if (res.getCoverBitmap() != null) {
            arguments.putParcelable(SearchResultDetailFragment.ARG_ITEM_COVER_BITMAP, smallCover);
        }
        if (res.getType() != null) {
            arguments.putString(SearchResultDetailFragment.ARG_ITEM_MEDIATYPE, res.getType().toString());
        }
        detailFragment = new SearchResultDetailFragment();
        detailFragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().replace(R.id.searchresult_detail_container, detailFragment).commit();
    } else {
        // In single-pane mode, simply start the detail activity
        // for the selected item ID.
        Intent detailIntent = new Intent(this, SearchResultDetailActivity.class);
        detailIntent.putExtra(SearchResultDetailFragment.ARG_ITEM_NR, res.getNr());
        if (res.getId() != null) {
            detailIntent.putExtra(SearchResultDetailFragment.ARG_ITEM_ID, res.getId());
        }
        if (res.getType() != null) {
            detailIntent.putExtra(SearchResultDetailFragment.ARG_ITEM_MEDIATYPE, res.getType().toString());
        }
        if (res.getCoverBitmap() != null) {
            detailIntent.putExtra(SearchResultDetailFragment.ARG_ITEM_COVER_BITMAP, smallCover);
            detailIntent.putExtra(SearchResultDetailActivity.ARG_TOUCH_POSITION_X, touchX);
            detailIntent.putExtra(SearchResultDetailActivity.ARG_TOUCH_POSITION_Y, touchY);
            @SuppressWarnings("unchecked") ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, new Pair<>(coverView, getString(R.string.transition_cover)), new Pair<>((View) toolbar, getString(R.string.transition_toolbar)));
            ActivityCompat.startActivity(this, detailIntent, options.toBundle());
        } else {
            startActivity(detailIntent);
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) Bundle(android.os.Bundle) Intent(android.content.Intent) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) View(android.view.View)

Aggregations

ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)92 Intent (android.content.Intent)72 View (android.view.View)31 Pair (android.support.v4.util.Pair)18 ImageView (android.widget.ImageView)15 TextView (android.widget.TextView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 Activity (android.app.Activity)12 OnClick (butterknife.OnClick)7 ActivityOptions (android.app.ActivityOptions)4 Context (android.content.Context)4 Bundle (android.os.Bundle)4 Handler (android.os.Handler)4 BindView (butterknife.BindView)4 CardView (android.support.v7.widget.CardView)3 Explode (android.transition.Explode)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2