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

@SafeVarargs
public static ActivityOptions makeSceneTransitionAnimation(Activity activity,
        Pair<View, String>... sharedElements) 

Source Link

Document

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

Usage

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

@Nullable
@Override//from   ww  w .j a  va 2s  .  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 + "]");
    mProducerAdapter = new ProducerAdapter(new ProducerAdapter.ProducerAdapterClickHandler() {
        @Override
        public void onClick(String producerName, Uri contentUri, ProducerAdapter.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.nameView, vh.nameView.getTransitionName()))
                        .toBundle();
            }
            Intent intent = new Intent(getActivity(), ShowProducerActivity.class).setData(contentUri);
            startActivity(intent, bundle);
        }
    }, getActivity());

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

    return mRootView;
}

From source file:io.romain.passport.ui.fragments.CityListFragment.java

@Override
public void onCityClicked(final View v, final City city) {
    Intent intent = new Intent(getContext(), CityDetailActivity.class);
    intent.putExtra(CityDetailActivity.EXTRA_CITY, city);
    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
            //            Pair.create((View) image, getContext().getString(R.string.transition_picture)),
            (Pair<View, String>) Pair.create(v, getContext().getString(R.string.transition_detail_background)));

    getContext().startActivity(intent, options.toBundle());
}

From source file:com.adkdevelopment.e_contact.ui.TasksFragment.java

@Override
public void onItemClicked(TaskRealm item, View view) {

    Intent intent = new Intent(getContext(), DetailActivity.class);
    intent.putExtra(TaskRealm.TASK_EXTRA, item);
    intent.putExtra(TaskRealm.TASK_EXTRA_TITLE, String.valueOf(item.getId()));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Pair pair = Pair.create(view.findViewById(R.id.task_item_card),
                view.findViewById(R.id.task_item_card).getTransitionName());
        Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(), pair).toBundle();

        startActivity(intent, bundle);//w ww  .  ja  va  2s  .  co  m
    } else {
        startActivity(intent);
    }

}

From source file:com.brettyin.cardshelper.fragment.SignInFragment.java

private void performSignInWithTransition(View v) {
    final Activity activity = getActivity();

    final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, true,
            new Pair<>(v, activity.getString(R.string.transition_avatar)));
    ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(activity, pairs);
    //CategorySelectionActivity.start(activity, mPlayer, activityOptions);
}

From source file:com.adkdevelopment.earthquakesurvival.ui.PagerActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (mGoogleApiClient != null && (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting())) {
        mGoogleApiClient.connect();//  w  w  w . j av a  2 s  . c om
    }

    _subscription = new CompositeSubscription();
    _subscription.add(_rxBus.toObservable().subscribe(o -> {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && o instanceof Pair) {
            Pair pair = (Pair) o;
            Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(this, (Pair) pair.second).toBundle();
            startActivity((Intent) pair.first, bundle);
        } else if (o instanceof Intent) {
            startActivity((Intent) o);
        }
    }));
}

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

private void onAlbumClick(int i, View v) {
    if (mAdapter.getChildrenCount(SearchAdapter.ALBUM) > 1) {
        SearchAdapter.SearchEntry entry = mAdapter.getChild(SearchAdapter.ALBUM, i);

        if (entry.ref.equals(KEY_SPECIAL_MORE)) {
            mAdapter.setGroupMaxCount(SearchAdapter.ALBUM, mAdapter.getGroupMaxCount(SearchAdapter.ALBUM) + 5);
        } else {/*from www.j av  a2  s.  c om*/
            SearchAdapter.ViewHolder holder = (SearchAdapter.ViewHolder) v.getTag();
            Bitmap hero = ((MaterialTransitionDrawable) holder.albumArtImageView.getDrawable())
                    .getFinalDrawable().getBitmap();
            int color = 0xffffff;
            if (hero != null) {
                Palette palette = Palette.generate(hero);
                Palette.Swatch darkVibrantColor = palette.getDarkVibrantSwatch();
                Palette.Swatch darkMutedColor = palette.getDarkMutedSwatch();

                if (darkVibrantColor != null) {
                    color = darkVibrantColor.getRgb();
                } else if (darkMutedColor != null) {
                    color = darkMutedColor.getRgb();
                } else {
                    color = getResources().getColor(R.color.default_album_art_background);
                }
            }

            Intent intent = AlbumActivity.craftIntent(getActivity(), hero, entry.ref, entry.identifier, color);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ImageView ivCover = holder.albumArtImageView;
                ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                        new Pair<View, String>(ivCover, "itemImage"));
                getActivity().startActivity(intent, opt.toBundle());
            } else {
                startActivity(intent);
            }
        }
    }
}

From source file:com.hackvg.android.views.activities.MoviesActivity.java

@SuppressWarnings("unchecked")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void startDetailActivityBySharedElements(View touchedView, int moviePosition,
        Intent movieDetailActivityIntent) {

    ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this,
            new Pair<>(touchedView, SHARED_ELEMENT_COVER + moviePosition));

    startActivity(movieDetailActivityIntent, options.toBundle());
}

From source file:io.plaidapp.core.ui.FeedAdapter.java

private void openDesignerNewsStory(StoryViewHolder.TransitionData data) {
    final Intent intent = ActivityHelper.intentTo(Activities.DesignerNews.Story.INSTANCE);
    intent.putExtra(Activities.DesignerNews.Story.EXTRA_STORY, data.getStory());
    ReflowText.addExtras(intent, new ReflowText.ReflowableTextView(data.getTitle()));
    setGridItemContentTransitions(data.getItemView());

    // on return, fade the pocket & comments buttons in
    host.setExitSharedElementCallback(new SharedElementCallback() {
        @Override//from w  w  w. j  ava  2 s  . com
        public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements,
                List<View> sharedElementSnapshots) {
            host.setExitSharedElementCallback(null);
            notifyItemChanged(data.getPosition(), HomeGridItemAnimator.STORY_COMMENTS_RETURN);
        }
    });

    final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host,
            data.getSharedElements());
    host.startActivity(intent, options.toBundle());
}

From source file:com.adkdevelopment.e_contact.TasksFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from  ww w .  jav a  2  s.c  o m
public void onTaskClickTransition(TaskItem item, Pair<View, String> pair) {
    Intent intent = new Intent(getContext(), DetailActivity.class);
    intent.putExtra(TaskItem.TASKITEM, item);

    //noinspection unchecked always true
    Bundle bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(), pair).toBundle();
    startActivity(intent, bundle);
}

From source file:com.fbartnitzek.tasteemall.showentry.ShowReviewFragment.java

@Override
public void onClick(View v) {
    //        Log.v(LOG_TAG, "onClick, mProducer_Id=" + mProducer_Id + ", mDrink_Id=" + mDrink_Id + ", mLocation_Id=" + mLocation_Id);
    if (v.getId() == R.id.producer_name && mProducer_Id > -1) { // open producer
        Bundle bundle = null;/*from   w  w  w .  j  a  va  2 s .  co m*/
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            bundle = ActivityOptions
                    .makeSceneTransitionAnimation(getActivity(),
                            new Pair<View, String>(mProducerNameView,
                                    getString(R.string.shared_transition_producer_producer) + mProducer_Id))
                    .toBundle();
        }
        startActivity(new Intent(getActivity(), ShowProducerActivity.class)
                .setData(DatabaseContract.ProducerEntry.buildUri(mProducer_Id)), bundle);
    } else if (v.getId() == R.id.drink_name && mDrink_Id > -1) { // open drink
        Bundle bundle = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(),
                    new Pair<View, String>(mProducerNameView,
                            getString(R.string.shared_transition_drink_producer) + mDrink_Id),
                    new Pair<View, String>(mDrinkNameView,
                            getString(R.string.shared_transition_drink_drink) + mDrink_Id))
                    .toBundle();
        }
        startActivity(new Intent(getActivity(), ShowDrinkActivity.class)
                .setData(DatabaseContract.DrinkEntry.buildUri(mDrink_Id)), bundle);
    } else if (v.getId() == R.id.review_location && mLocation_Id > -1) {
        startActivity(new Intent(getActivity(), ShowLocationActivity.class)
                .setData(DatabaseContract.LocationEntry.buildUri(mLocation_Id)));
    } else if (v.getId() == R.id.fab_share && mProducer_Id > -1) { // all loaded
        shareReview();
    }
}