Example usage for android.app ActivityOptions makeSceneTransitionAnimation

List of usage examples for android.app ActivityOptions makeSceneTransitionAnimation

Introduction

In this page you can find the example usage for android.app ActivityOptions makeSceneTransitionAnimation.

Prototype

public static ActivityOptions makeSceneTransitionAnimation(Activity activity, View sharedElement,
        String sharedElementName) 

Source Link

Document

Create an ActivityOptions to transition between Activities using cross-Activity scene animations.

Usage

From source file:it.cammino.risuscito.LUtils.java

public void startActivityWithTransition(Intent intent, final View clickedView, final String transitionName) {
    ActivityOptions options = null;/*from   www .j av  a 2 s  . c  o  m*/
    if (hasL() && clickedView != null && !TextUtils.isEmpty(transitionName)) {
        options = ActivityOptions.makeSceneTransitionAnimation(mActivity, clickedView, transitionName);
        ActivityCompat.startActivity(mActivity, intent, options.toBundle());
    } else {
        mActivity.startActivity(intent);
        mActivity.overridePendingTransition(R.anim.slide_in_right, R.anim.hold_on);
    }
}

From source file:it.cammino.risuscito.LUtils.java

public void startActivityWithFadeIn(Intent intent, final View clickedView, final String transitionName) {
    ActivityOptions options = null;//from w  ww .  j a  va  2  s .c  om
    if (hasL() && clickedView != null && !TextUtils.isEmpty(transitionName)) {
        options = ActivityOptions.makeSceneTransitionAnimation(mActivity, clickedView, transitionName);
        ActivityCompat.startActivity(mActivity, intent, options.toBundle());
    } else {
        mActivity.startActivity(intent);
        mActivity.overridePendingTransition(R.anim.image_fade_in, R.anim.hold_on);
    }
}

From source file:de.dreier.mytargets.utils.IntentWrapper.java

public IntentWrapper fromFab(View fab, @ColorRes int color, int icon) {
    if (Utils.isLollipop()) {
        FabTransform.addExtras(intent, color, icon);
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(fab), fab,
                fab.getContext().getString(R.string.transition_root_view));
        this.options = options.toBundle();
    }//from   w  w w  .j a  v  a 2 s .c o  m
    return this;
}

From source file:com.fbartnitzek.tasteemall.mainpager.DrinkPagerFragment.java

@Nullable
@Override// w  ww. java2 s. c  om
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Log.v(LOG_TAG, "onCreateView, hashCode=" + this.hashCode() + ", " + "inflater = [" + inflater
            + "], container = [" + container + "], savedInstanceState = [" + savedInstanceState + "]");
    mDrinkAdapter = new DrinkAdapter(new DrinkAdapter.DrinkAdapterClickHandler() {
        @Override
        public void onClick(String drinkName, Uri contentUri, DrinkAdapter.ViewHolder vh) {
            Bundle bundle = null;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                        new Pair<View, String>(vh.drinkNameView, vh.drinkNameView.getTransitionName()),
                        new Pair<View, String>(vh.producerNameView, vh.producerNameView.getTransitionName()))
                        .toBundle();
            }
            Intent intent = new Intent(getActivity(), ShowDrinkActivity.class).setData(contentUri);
            startActivity(intent, bundle);
        }
    }, getActivity());

    mDrinksHeading = (TextView) mRootView.findViewById(R.id.heading_entities);
    mDrinksHeading.setText(getString(R.string.label_list_entries_preview, getString(R.string.label_drinks)));
    RecyclerView reviewRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview_entities);
    reviewRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    reviewRecyclerView.setAdapter(mDrinkAdapter);

    return mRootView;
}

From source file:com.fbartnitzek.tasteemall.mainpager.ReviewPagerFragment.java

@Nullable
@Override/*from   w w  w  . j  a v  a 2 s.  c  o  m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    Log.v(LOG_TAG, "onCreateView, hashCode=" + this.hashCode() + ", " + "inflater = [" + inflater
            + "], container = [" + container + "], savedInstanceState = [" + savedInstanceState + "]");
    mReviewAdapter = new ReviewAdapter(new ReviewAdapter.ReviewAdapterClickHandler() {

        @Override
        public void onClick(Uri contentUri, ReviewAdapter.ViewHolder vh) {
            Bundle bundle = null;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                        new Pair<View, String>(vh.drinkNameView, vh.drinkNameView.getTransitionName()),
                        new Pair<View, String>(vh.producerNameView, vh.producerNameView.getTransitionName()))
                        .toBundle();
            }

            startActivity(new Intent(getActivity(), ShowReviewActivity.class).setData(contentUri), bundle);
        }
    }, getActivity());

    mReviewsHeading = (TextView) mRootView.findViewById(R.id.heading_entities);
    mReviewsHeading.setText(getString(R.string.label_list_entries_preview, getString(R.string.label_reviews)));
    RecyclerView reviewRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview_entities);
    reviewRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    reviewRecyclerView.setAdapter(mReviewAdapter);

    return mRootView;
}

From source file:net.mm2d.dmsexplorer.ServerDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.frg_server_detail, container, false);
    final String udn = getArguments().getString(Const.EXTRA_UDN);
    final DataHolder dataHolder = DataHolder.getInstance();
    final MediaServer server = dataHolder.getMsControlPoint().getMediaServer(udn);
    if (server == null) {
        getActivity().finish();/* w w w. j  a va 2s.  c o  m*/
        return rootView;
    }
    final TextView titleView = (TextView) rootView.findViewById(R.id.title);
    if (titleView != null) {
        titleView.setText(server.getFriendlyName());
        titleView.setBackgroundColor(ThemeUtils.getAccentColor(server.getFriendlyName()));
    }
    final RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.server_detail);
    final PropertyAdapter adapter = new PropertyAdapter(getContext());
    setupPropertyAdapter(adapter, server);
    adapter.setOnItemLinkClickListener(this);
    recyclerView.setAdapter(adapter);

    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    if (fab == null) {
        fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    }
    if (fab != null) {
        fab.setOnClickListener(view -> {
            final Intent intent = CdsListActivity.makeIntent(getContext(), udn);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                final TransitionSet ts = new TransitionSet();
                ts.addTransition(new Slide(Gravity.START));
                ts.addTransition(new Fade());
                getActivity().getWindow().setExitTransition(ts);
                startActivity(intent,
                        ActivityOptions.makeSceneTransitionAnimation(getActivity(), view, "share").toBundle());
            } else {
                startActivity(intent);
            }
        });
    }
    return rootView;
}

From source file:de.schildbach.wallet.ui.scan.ScanActivity.java

public static void startForResult(final Activity activity, @Nullable final View clickView,
        final int requestCode) {
    if (clickView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final int[] clickViewLocation = new int[2];
        clickView.getLocationOnScreen(clickViewLocation);
        final Intent intent = new Intent(activity, ScanActivity.class);
        intent.putExtra(ScanActivity.INTENT_EXTRA_SCENE_TRANSITION_X,
                (int) (clickViewLocation[0] + clickView.getWidth() / 2));
        intent.putExtra(ScanActivity.INTENT_EXTRA_SCENE_TRANSITION_Y,
                (int) (clickViewLocation[1] + clickView.getHeight() / 2));
        final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity, clickView,
                "transition");
        activity.startActivityForResult(intent, requestCode, options.toBundle());
    } else {//from  ww  w  . j ava2 s.c o m
        startForResult(activity, requestCode);
    }
}

From source file:com.fastbootmobile.encore.app.fragments.AlbumsFragment.java

/**
 * {@inheritDoc}//from  w  w w .java 2 s  .  c  o  m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View root = inflater.inflate(R.layout.fragment_albums, container, false);
    mGridView = (GridView) root.findViewById(R.id.gvAlbums);
    mGridView.setFastScrollEnabled(true);

    // Get the albums
    new GetAlbumsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    // Setup the click listener
    mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            AlbumsAdapter.ViewHolder tag = (AlbumsAdapter.ViewHolder) view.getTag();
            ImageView ivCover = tag.ivCover;
            Album item = mAdapter.getItem(position);

            Bitmap hero = ((MaterialTransitionDrawable) ivCover.getDrawable()).getFinalDrawable().getBitmap();
            Intent intent = AlbumActivity.craftIntent(getActivity(), hero, item.getRef(), item.getProvider(),
                    tag.itemColor);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(), tag.ivCover,
                        "itemImage");
                getActivity().startActivity(intent, opt.toBundle());
            } else {
                startActivity(intent);
            }
        }
    });

    return root;
}

From source file:com.d2connect.droidltest.util.LPreviewUtilsImpl.java

public void startActivityWithTransition(Intent intent, final View clickedView, final String sharedElementName) {
    ActivityOptions options = null;/*from w  w w  . ja  v a 2  s .c  o m*/
    if (clickedView != null && !TextUtils.isEmpty(sharedElementName)) {
        options = ActivityOptions.makeSceneTransitionAnimation(mActivity, clickedView, sharedElementName);
    }

    mActivity.setExitSharedElementListener(new SharedElementListener() {
        @Override
        public void remapSharedElements(List<String> names, Map<String, View> sharedElements) {
            super.remapSharedElements(names, sharedElements);
            sharedElements.put(sharedElementName, clickedView);
        }
    });

    mActivity.startActivity(intent, (options != null) ? options.toBundle() : null);
}

From source file:com.fbartnitzek.tasteemall.location.ShowProducerMapFragment.java

@Nullable
@Override//from w w  w  .  jav  a2s  .  c  o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Bundle args = getArguments();
    if (args == null) {
        Log.w(LOG_TAG, "onCreateView without args...");
    } else {
        Log.v(LOG_TAG, "onCreateView with args: " + args);

        if (args.containsKey(REVIEW_URI)) {
            mBaseUri = args.getParcelable(REVIEW_URI);
            getLoaderManager().restartLoader(PRODUCERS_LOADER_ID, null, this);
        }
    }

    mProducerLocationAdapter = new ProducerLocationAdapter(
            new ProducerLocationAdapter.ProducerLocationAdapterClickHandler() {
                @Override
                public void onClick(String producerId, ProducerLocationAdapter.ViewHolder viewHolder,
                        LatLng latLng, String formatted, String name) {
                    addProducerLocationMarker(producerId, viewHolder, latLng, formatted, name);
                }
            });

    mHeadingProducerLocations = (TextView) mRootView.findViewById(R.id.heading_map_producers);
    mHeadingProducerLocations.setText(R.string.label_list_map_producer_locations_preview);
    RecyclerView locationRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview_map_producer);
    locationRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    locationRecyclerView.setAdapter(mProducerLocationAdapter);

    mHeadingReviewsOfProducer = (TextView) mRootView.findViewById(R.id.heading_map_sub_list_reviews);
    mHeadingReviewsOfProducer.setText(R.string.label_list_map_reviews_of_producer_preview);
    mReviewOfProducerAdapter = new ReviewOfLocationAdapter(
            new ReviewOfLocationAdapter.ReviewAdapterClickHandler() {
                @Override
                public void onClick(Uri contentUri, ReviewOfLocationAdapter.ViewHolder vh) {
                    Bundle bundle = null;
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                        bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                                new Pair<View, String>(vh.drinkNameView, vh.drinkNameView.getTransitionName()),
                                new Pair<View, String>(vh.producerNameView,
                                        vh.producerNameView.getTransitionName()))
                                .toBundle();
                    }

                    startActivity(new Intent(getActivity(), ShowReviewActivity.class).setData(contentUri),
                            bundle);
                }
            }, getActivity());
    RecyclerView reviewsRecyclerView = (RecyclerView) mRootView
            .findViewById(R.id.recyclerview_map_sub_list_reviews);
    reviewsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    reviewsRecyclerView.setAdapter(mReviewOfProducerAdapter);

    return mRootView;
}