List of usage examples for android.app ActivityOptions makeSceneTransitionAnimation
public static ActivityOptions makeSceneTransitionAnimation(Activity activity, View sharedElement, String sharedElementName)
From source file:io.plaidapp.ui.PostNewDesignerNewsStory.java
@OnClick(R.id.new_story_post) protected void postNewStory() { if (DesignerNewsPrefs.get(this).isLoggedIn()) { ImeUtils.hideIme(title);//from www . j a va 2 s . c o m Intent data = new Intent(); data.putExtra(EXTRA_STORY_TITLE, title.getText().toString()); data.putExtra(EXTRA_STORY_URL, url.getText().toString()); data.putExtra(EXTRA_STORY_COMMENT, comment.getText().toString()); setResult(RESULT_POST, data); finishAfterTransition(); } else { Intent login = new Intent(this, DesignerNewsLogin.class); login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, ContextCompat.getColor(this, R.color.designer_news)); login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, 0); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, post, getString(R.string.transition_designer_news_login)); startActivity(login, options.toBundle()); } }
From source file:io.plaidapp.ui.PostNewDesignerNewsStory.java
@OnClick(R.id.new_story_post) protected void postNewStory() { if (DesignerNewsPrefs.get(this).isLoggedIn()) { ImeUtils.hideIme(title);//from www .jav a2 s. co m Intent postIntent = new Intent(PostStoryService.ACTION_POST_NEW_STORY, null, this, PostStoryService.class); postIntent.putExtra(PostStoryService.EXTRA_STORY_TITLE, title.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_STORY_URL, url.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_STORY_COMMENT, comment.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT, getIntent().getBooleanExtra(PostStoryService.EXTRA_BROADCAST_RESULT, false)); startService(postIntent); setResult(RESULT_POSTING); finishAfterTransition(); } else { Intent login = new Intent(this, DesignerNewsLogin.class); MorphTransform.addExtras(login, ContextCompat.getColor(this, R.color.designer_news), 0); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, post, getString(R.string.transition_designer_news_login)); startActivity(login, options.toBundle()); } }
From source file:com.fastbootmobile.encore.app.fragments.PlaylistListFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // If mAdapter isn't null, we're in portrait with the draggable list view. if (mAdapter != null) { mRecyclerView = (RecyclerView) view.findViewById(R.id.rvPlaylists); mLayoutManager = new LinearLayoutManager(getContext()); // drag & drop manager mRecyclerViewDragDropManager = new RecyclerViewDragDropManager(); //adapter mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mAdapter); // wrap for dragging final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator(); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter mRecyclerView.setItemAnimator(animator); // additional decorations mRecyclerView.addItemDecoration( new SimpleListDividerDecorator(getResources().getDrawable(R.drawable.list_divider), true)); mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView); if (!mIsStandalone) { mRecyclerView.setPadding(0, 0, 0, 0); }//from ww w . j a v a2 s . c o m } else { // We're in landscape with the grid view GridView root = (GridView) view.findViewById(R.id.gvPlaylists); root.setAdapter(mGridAdapter); if (!mIsStandalone) { root.setPadding(0, 0, 0, 0); } // Setup the click listener root.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { MainActivity act = (MainActivity) getActivity(); PlaylistGridAdapter.ViewHolder tag = (PlaylistGridAdapter.ViewHolder) view.getTag(); Intent intent = PlaylistActivity.craftIntent(act, mGridAdapter.getItem(position), ((MaterialTransitionDrawable) tag.ivCover.getDrawable()).getFinalDrawable() .getBitmap()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(), tag.ivCover, "itemImage"); act.startActivity(intent, opt.toBundle()); } else { act.startActivity(intent); } } }); } }
From source file:com.jrummyapps.busybox.fragments.ScriptsFragment.java
@Override public void onClick(View view) { if (view == fab) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Intent intent = new Intent(getActivity(), CreateScriptActivity.class); intent.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, getRadiant().accentColor()); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(getActivity(), view, getString(R.string.morphing_dialog_transition)); getActivity().startActivityForResult(intent, REQUEST_CREATE_SCRIPT, options.toBundle()); } else {// w ww . jav a 2 s . c om new CreateScriptDialog().show(getActivity().getFragmentManager(), "CreateScriptDialog"); } } }
From source file:io.plaidapp.ui.FeedAdapter.java
@NonNull private DribbbleShotHolder createDribbbleShotHolder(ViewGroup parent) { final DribbbleShotHolder holder = new DribbbleShotHolder( layoutInflater.inflate(R.layout.dribbble_shot_item, parent, false)); holder.image.setOnClickListener(new View.OnClickListener() { @Override//from ww w .j a va2 s .co m public void onClick(View view) { holder.itemView .setTransitionName(holder.itemView.getResources().getString(R.string.transition_shot)); holder.itemView.setBackgroundColor(ContextCompat.getColor(host, R.color.background_light)); Intent intent = new Intent(); intent.setClass(host, DribbbleShot.class); intent.putExtra(DribbbleShot.EXTRA_SHOT, (Shot) getItem(holder.getAdapterPosition())); setGridItemContentTransitions(holder.itemView); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_shot)), Pair.create(view, host.getString(R.string.transition_shot_background))); host.startActivity(intent, options.toBundle()); } }); // play animated GIFs whilst touched holder.image.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // get the image and check if it's an animated GIF final Drawable drawable = holder.image.getDrawable(); if (drawable == null) return false; GifDrawable gif = null; if (drawable instanceof GifDrawable) { gif = (GifDrawable) drawable; } else if (drawable instanceof TransitionDrawable) { // we fade in images on load which uses a TransitionDrawable; check its layers TransitionDrawable fadingIn = (TransitionDrawable) drawable; for (int i = 0; i < fadingIn.getNumberOfLayers(); i++) { if (fadingIn.getDrawable(i) instanceof GifDrawable) { gif = (GifDrawable) fadingIn.getDrawable(i); break; } } } if (gif == null) return false; // GIF found, start/stop it on press/lift switch (event.getAction()) { case MotionEvent.ACTION_DOWN: gif.start(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: gif.stop(); break; } return false; } }); return holder; }
From source file:com.fastbootmobile.encore.app.fragments.SearchFragment.java
private void onArtistClick(int i, View v) { if (mAdapter.getChildrenCount(SearchAdapter.ARTIST) > 1) { SearchAdapter.SearchEntry entry = mAdapter.getChild(SearchAdapter.ARTIST, i); if (entry.ref.equals(KEY_SPECIAL_MORE)) { mAdapter.setGroupMaxCount(SearchAdapter.ARTIST, mAdapter.getGroupMaxCount(SearchAdapter.ARTIST) + 5); } else {//from w w w . ja v a 2 s. co m SearchAdapter.ViewHolder holder = (SearchAdapter.ViewHolder) v.getTag(); ImageView ivCover = holder.albumArtImageView; Bitmap hero = ((MaterialTransitionDrawable) ivCover.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 = new Intent(getActivity(), ArtistActivity.class); intent.putExtra(ArtistActivity.EXTRA_ARTIST, entry.ref); intent.putExtra(ArtistActivity.EXTRA_BACKGROUND_COLOR, color); Utils.queueBitmap(ArtistActivity.BITMAP_ARTIST_HERO, hero); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation(getActivity(), ivCover, "itemImage"); getActivity().startActivity(intent, opt.toBundle()); } else { startActivity(intent); } } } }
From source file:io.plaidapp.designernews.PostNewDesignerNewsStory.java
protected void postNewStory() { if (DesignerNewsPrefs.get(this).isLoggedIn()) { ImeUtils.hideIme(title);/*from w w w . j a va 2 s . c om*/ Intent postIntent = new Intent(PostStoryService.ACTION_POST_NEW_STORY, null, this, PostStoryService.class); postIntent.putExtra(PostStoryService.EXTRA_STORY_TITLE, title.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_STORY_URL, url.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_STORY_COMMENT, comment.getText().toString()); postIntent.putExtra(PostStoryService.EXTRA_BROADCAST_RESULT, getIntent().getBooleanExtra(PostStoryService.EXTRA_BROADCAST_RESULT, false)); startService(postIntent); setResult(Activities.DesignerNews.PostStory.RESULT_POSTING); finishAfterTransition(); } else { Intent login = ActivityHelper.intentTo(Activities.DesignerNews.Login.INSTANCE); MorphTransform.addExtras(login, ContextCompat.getColor(this, io.plaidapp.R.color.designer_news), 0); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, post, getString(io.plaidapp.R.string.transition_designer_news_login)); startActivity(login, options.toBundle()); } }
From source file:com.example.admin.news.mvp.ui.fragment.NewsListFragment.java
private void startActivity(View view, Intent intent) { ImageView newsSummaryPhotoIv = (ImageView) view.findViewById(R.id.news_summary_photo_iv); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(mActivity, newsSummaryPhotoIv, Constants.TRANSITION_ANIMATION_NEWS_PHOTOS); startActivity(intent, options.toBundle()); } else {/* w w w . j a v a 2s . c o m*/ /* ActivityOptionsCompat.makeCustomAnimation(this, R.anim.slide_bottom_in, R.anim.slide_bottom_out); overridePendingTransition(R.anim.slide_bottom_in, android.R.anim.fade_out);*/ /* ActivityOptionsCompat.makeThumbnailScaleUpAnimation(source, thumbnail, startX, startY) ?4.x??Bitmpat*/ //Activity?? ActivityOptionsCompat options = ActivityOptionsCompat.makeScaleUpAnimation(view, view.getWidth() / 2, view.getHeight() / 2, 0, 0); ActivityCompat.startActivity(mActivity, intent, options.toBundle()); } }
From source file:io.plaidapp.ui.DribbbleShot.java
public void postComment(View view) { if (dribbblePrefs.isLoggedIn()) { if (TextUtils.isEmpty(enterComment.getText())) return; enterComment.setEnabled(false);/*from w w w . ja va2 s . co m*/ final Call<Comment> postCommentCall = dribbblePrefs.getApi().postComment(shot.id, enterComment.getText().toString().trim()); postCommentCall.enqueue(new Callback<Comment>() { @Override public void onResponse(Call<Comment> call, Response<Comment> response) { loadComments(); enterComment.getText().clear(); enterComment.setEnabled(true); } @Override public void onFailure(Call<Comment> call, Throwable t) { enterComment.setEnabled(true); } }); } else { Intent login = new Intent(DribbbleShot.this, DribbbleLogin.class); FabTransform.addExtras(login, ContextCompat.getColor(DribbbleShot.this, R.color.background_light), R.drawable.ic_comment_add); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(DribbbleShot.this, postComment, getString(R.string.transition_dribbble_login)); startActivityForResult(login, RC_LOGIN_COMMENT, options.toBundle()); } }
From source file:com.fastbootmobile.encore.app.adapters.PlaylistListAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final int itemViewType = getItemViewType(position); if (itemViewType == VIEW_TYPE_HEADER) { SpecialViewHolder specialHolder = (SpecialViewHolder) holder; specialHolder.cardFavorites.setOnClickListener(new View.OnClickListener() { @Override// w w w .j a v a 2 s . c o m public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_FAVORITES, null); ctx.startActivity(intent); } }); specialHolder.cardMostPlayed.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, AutoPlaylistHelper.REF_SPECIAL_MOST_PLAYED, null); ctx.startActivity(intent); } }); } else if (itemViewType == VIEW_TYPE_REGULAR) { final Playlist item = mPlaylists.get(position - 1); holder.tvPlaylistName.setText(item.getName()); holder.ivCover.loadArtForPlaylist(item); if (item.isLoaded() || item.getSongsCount() > 0) { ProviderConnection provider = PluginsLookup.getDefault().getProvider(item.getProvider()); if (provider != null) { holder.tvPlaylistDesc .setText(String.format("%s / %s", holder.tvPlaylistDesc.getContext().getResources().getQuantityString( R.plurals.xx_songs, item.getSongsCount(), item.getSongsCount()), provider.getProviderName())); } holder.ivOfflineStatus.setVisibility(View.VISIBLE); switch (item.getOfflineStatus()) { case BoundEntity.OFFLINE_STATUS_NO: holder.ivOfflineStatus.setVisibility(View.GONE); break; case BoundEntity.OFFLINE_STATUS_DOWNLOADING: holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_in_progress); break; case BoundEntity.OFFLINE_STATUS_ERROR: holder.ivOfflineStatus.setImageResource(R.drawable.ic_sync_problem); break; case BoundEntity.OFFLINE_STATUS_PENDING: holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_download_pending); break; case BoundEntity.OFFLINE_STATUS_READY: holder.ivOfflineStatus.setImageResource(R.drawable.ic_track_downloaded); break; } } else { holder.tvPlaylistDesc.setText(null); holder.ivOfflineStatus.setVisibility(View.GONE); } final int dragState = holder.getDragStateFlags(); if (((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_UPDATED) != 0)) { int bgColor = 0; if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_IS_ACTIVE) != 0) { bgColor = 0xFFDDDDDD; } else if ((dragState & RecyclerViewDragDropManager.STATE_FLAG_DRAGGING) != 0) { bgColor = 0xFFAAAAAA; } if (bgColor != 0) { holder.container.setBackgroundColor(bgColor); } else { int[] attrs = new int[] { android.R.attr.selectableItemBackground /* index 0 */ }; TypedArray ta = holder.container.getContext().obtainStyledAttributes(attrs); Drawable drawableFromTheme = ta.getDrawable(0 /* index */); ta.recycle(); holder.container.setBackground(drawableFromTheme); } } holder.container.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Context ctx = v.getContext(); Intent intent = PlaylistActivity.craftIntent(ctx, item, ((MaterialTransitionDrawable) holder.ivCover.getDrawable()).getFinalDrawable() .getBitmap()); if (Utils.hasLollipop()) { ActivityOptions opt = ActivityOptions.makeSceneTransitionAnimation((Activity) ctx, holder.ivCover, "itemImage"); ctx.startActivity(intent, opt.toBundle()); } else { ctx.startActivity(intent); } } }); } }