List of usage examples for android.app ActivityOptions toBundle
public Bundle toBundle()
From source file:pl.ipebk.tabi.presentation.ui.search.SearchActivity.java
public void goToPlaceDetails(View view, AggregateId placeId, String searchedPlate, SearchType searchType, PlaceListItemType itemType, int position) { indicator.setVisibility(View.GONE); Intent intent = new Intent(this, DetailsSearchActivity.class); intent.putExtra(DetailsSearchActivity.PARAM_PLACE_ID, placeId.getValue()); intent.putExtra(DetailsSearchActivity.PARAM_SEARCHED_PLATE, searchedPlate); intent.putExtra(DetailsSearchActivity.PARAM_SEARCHED_TYPE, searchType); intent.putExtra(DetailsSearchActivity.PARAM_ITEM_TYPE, itemType); intent.putExtra(DetailsSearchActivity.PARAM_ADAPTER_POSITION, position); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { List<Pair<View, String>> transitions = new ArrayList<>(); // shared elements transitions.add(Pair.create(indicator, getString(R.string.trans_tab_indicator))); transitions.add(Pair.create(searchInputWrap, getString(R.string.trans_search_input))); transitions.add(Pair.create(view, SharedTransitionNaming.getName(getString(R.string.trans_row_background), position))); transitions.add(Pair.create(view.findViewById(R.id.txt_voivodeship), SharedTransitionNaming.getName(getString(R.string.trans_voivodeship_name), position))); transitions.add(Pair.create(view.findViewById(R.id.txt_powiat), SharedTransitionNaming.getName(getString(R.string.trans_powiat_name), position))); transitions.add(Pair.create(view.findViewById(R.id.txt_place_name), SharedTransitionNaming.getName(getString(R.string.trans_place_name), position))); transitions.add(Pair.create(view.findViewById(R.id.ic_row), SharedTransitionNaming.getName(getString(R.string.trans_place_icon), position))); transitions.add(Pair.create(view.findViewById(R.id.txt_plate), SharedTransitionNaming.getName(getString(R.string.trans_place_plate), position))); // status and nav bar View statusBar = findViewById(android.R.id.statusBarBackground); if (statusBar != null) { transitions.add(Pair.create(statusBar, Window.STATUS_BAR_BACKGROUND_TRANSITION_NAME)); }/*w ww. j ava 2 s . c om*/ View navigationBar = findViewById(android.R.id.navigationBarBackground); if (navigationBar != null) { transitions.add(Pair.create(navigationBar, Window.NAVIGATION_BAR_BACKGROUND_TRANSITION_NAME)); } Pair<View, String>[] transitionsArray = transitions.toArray(new Pair[transitions.size()]); ActivityOptions transitionActivityOptions = ActivityOptions.makeSceneTransitionAnimation(this, transitionsArray); startActivity(intent, transitionActivityOptions.toBundle()); } else { startActivity(intent); } }
From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java
@NonNull private BoardgameHolder createBoardgameHolder(ViewGroup parent) { final BoardgameHolder holder = new BoardgameHolder( layoutInflater.inflate(R.layout.boardgame_item, parent, false)); holder.image.setOnClickListener(new View.OnClickListener() { @Override/*w ww. j ava 2 s. c om*/ public void onClick(View view) { holder.itemView .setTransitionName(holder.itemView.getResources().getString(R.string.transition_game)); holder.itemView.setBackgroundColor(ContextCompat.getColor(host, R.color.background_light)); Intent intent = new Intent(); intent.setClass(host, BoardgameDetails.class); intent.putExtra(BoardgameDetails.EXTRA_BOARDGAME, (Boardgame) getItem(holder.getAdapterPosition())); setGridItemContentTransitions(holder.itemView); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(view, host.getString(R.string.transition_game)), Pair.create(view, host.getString(R.string.transition_game_background))); host.startActivity(intent, options.toBundle()); } }); // show deletion confirmation holder.image.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { new AlertDialog.Builder(context).setTitle(host.getString(R.string.remove_game_title)) .setMessage(host.getString(R.string.remove_game_message)) .setPositiveButton(host.getString(R.string.dialog_remove), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { BoardgameDbHelper bgHelper = new BoardgameDbHelper(context); bgHelper.delete((Boardgame) getItem(holder.getAdapterPosition())); items.remove(getItem(holder.getAdapterPosition())); notifyDataSetChanged(); } }) .setNegativeButton(host.getString(R.string.dialog_cancel), null).show(); return false; } }); return holder; }
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 www. j a va 2s .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.d2connect.droidltest.util.LPreviewUtilsImpl.java
public void startActivityWithTransition(Intent intent, final View clickedView, final String sharedElementName) { ActivityOptions options = null; if (clickedView != null && !TextUtils.isEmpty(sharedElementName)) { options = ActivityOptions.makeSceneTransitionAnimation(mActivity, clickedView, sharedElementName); }//from ww w . ja v a 2s . c o m 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:io.plaidapp.ui.HomeActivity.java
@OnClick(R.id.fab) protected void fabClick() { if (designerNewsPrefs.isLoggedIn()) { Intent intent = new Intent(this, PostNewDesignerNewsStory.class); intent.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, ContextCompat.getColor(this, R.color.accent)); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, fab, getString(R.string.transition_new_designer_news_post)); startActivityForResult(intent, RC_NEW_DESIGNER_NEWS_STORY, options.toBundle()); } else {//from w w w . ja v a2 s. co m Intent intent = new Intent(this, DesignerNewsLogin.class); intent.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, ContextCompat.getColor(this, R.color.accent)); ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this, fab, getString(R.string.transition_designer_news_login)); startActivityForResult(intent, RC_NEW_DESIGNER_NEWS_LOGIN, options.toBundle()); } }
From source file:com.fastbootmobile.encore.app.fragments.PlaybackQueueFragment.java
public PlaybackQueueFragment() { mHandler = new PlaybackQueueHandler(new WeakReference<>(this)); mPlayFabClickListener = new View.OnClickListener() { @Override/*w ww . j a v a 2 s . c o m*/ public void onClick(View v) { switch (PlaybackProxy.getState()) { case PlaybackService.STATE_PAUSED: case PlaybackService.STATE_STOPPED: case PlaybackService.STATE_PAUSING: PlaybackProxy.play(); break; case PlaybackService.STATE_BUFFERING: case PlaybackService.STATE_PLAYING: PlaybackProxy.pause(); break; } } }; mNextClickListener = new View.OnClickListener() { @Override public void onClick(View v) { PlaybackProxy.next(); } }; mPreviousClickListener = new View.OnClickListener() { @Override public void onClick(View v) { PlaybackProxy.previous(); } }; mSeekListener = new SeekBar.OnSeekBarChangeListener() { private int mStartProgress; @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { mLockSeekBarUpdate = true; mStartProgress = seekBar.getProgress(); } @Override public void onStopTrackingTouch(SeekBar seekBar) { mLockSeekBarUpdate = false; int endProgress = seekBar.getProgress(); if (endProgress != mStartProgress) { PlaybackProxy.seek(endProgress); } } }; mRepeatClickListener = new View.OnClickListener() { @Override public void onClick(View v) { boolean currentMode = PlaybackProxy.isRepeatMode(); boolean newMode = !currentMode; PlaybackProxy.setRepeatMode(newMode); v.animate().rotationBy(-360).setDuration(600).start(); if (newMode) { ((ImageView) v).setImageResource(R.drawable.ic_replay); } else { ((ImageView) v).setImageResource(R.drawable.ic_replay_gray); } } }; mShuffleClickListener = new View.OnClickListener() { @Override public void onClick(View v) { boolean currentMode = PlaybackProxy.isShuffleMode(); boolean newMode = !currentMode; PlaybackProxy.setShuffleMode(newMode); if (newMode) { ((ImageView) v).setImageResource(R.drawable.ic_shuffle); } else { ((ImageView) v).setImageResource(R.drawable.ic_shuffle_gray); } } }; mLikeClickListener = new View.OnClickListener() { @Override public void onClick(View v) { ListenLogger logger = new ListenLogger(getActivity()); PlaybackQueueAdapter.ViewHolder tag = (PlaybackQueueAdapter.ViewHolder) v.getTag(); boolean isLiked = logger.isLiked(tag.song.getRef()); if (isLiked) { logger.removeLike(tag.song); ((ImageView) v).setImageResource(R.drawable.ic_thumbs_up_gray); } else { logger.addLike(tag.song); final AutoMixBucket bucket = AutoMixManager.getDefault().getCurrentPlayingBucket(); if (bucket != null) { new Thread() { public void run() { try { bucket.notifyLike(); } catch (EchoNestException e) { Log.e(TAG, "Unable to notify like event to EchoNest"); } } }.start(); } ((ImageView) v).setImageResource(R.drawable.ic_thumbs_up); } } }; mDislikeClickListener = new View.OnClickListener() { @Override public void onClick(View v) { ListenLogger logger = new ListenLogger(getActivity()); PlaybackQueueAdapter.ViewHolder tag = (PlaybackQueueAdapter.ViewHolder) v.getTag(); boolean isDisliked = logger.isDisliked(tag.song.getRef()); if (isDisliked) { logger.removeDislike(tag.song); ((ImageView) v).setImageResource(R.drawable.ic_thumb_down_gray); } else { logger.addDislike(tag.song); final AutoMixBucket bucket = AutoMixManager.getDefault().getCurrentPlayingBucket(); if (bucket != null) { new Thread() { public void run() { try { bucket.notifyDislike(); } catch (EchoNestException e) { Log.e(TAG, "Unable to notify dislike event to EchoNest"); } } }.start(); } ((ImageView) v).setImageResource(R.drawable.ic_thumb_down); } } }; mAlbumArtClickListener = new View.OnClickListener() { @Override @TargetApi(Build.VERSION_CODES.LOLLIPOP) public void onClick(View v) { PlaybackQueueAdapter.ViewHolder tag = (PlaybackQueueAdapter.ViewHolder) v.getTag(); if (tag.song.getAlbum() != null) { Bitmap hero = ((MaterialTransitionDrawable) tag.ivAlbumArt.getDrawable()).getFinalDrawable() .getBitmap(); Intent intent = AlbumActivity.craftIntent(getActivity(), hero, tag.song.getAlbum(), tag.song.getProvider(), 0xFF333333); if (Utils.hasLollipop()) { ActivityOptions opts = ActivityOptions.makeSceneTransitionAnimation(getActivity(), v, "itemImage"); getActivity().startActivity(intent, opts.toBundle()); } else { startActivity(intent); } } else { Toast.makeText(getActivity(), R.string.toast_song_no_album, Toast.LENGTH_SHORT).show(); } } }; }
From source file:com.hannesdorfmann.FeedAdapter.java
private void bindDribbbleShotView(final Shot shot, final DribbbleShotHolder holder, final int position) { final BadgedFourThreeImageView iv = (BadgedFourThreeImageView) holder.itemView; Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() { @Override// www . j a v a2 s . co m public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { if (!shot.hasFadedIn) { iv.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( if (iv.getDrawable() != null) { iv.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm)); } } }); saturation.setDuration(2000); saturation.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { iv.setHasTransientState(false); } }); saturation.start(); shot.hasFadedIn = true; } return false; } @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.ALL).into(new DribbbleTarget(iv, false)); iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { iv.setTransitionName(iv.getResources().getString(R.string.transition_shot)); iv.setBackgroundColor(ContextCompat.getColor(host, R.color.background_light)); Intent intent = new Intent(); intent.setClass(host, DribbbleShot.class); intent.putExtra(DribbbleShot.EXTRA_SHOT, shot); 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()); } }); }
From source file:net.wespot.pim.controller.ImageGridFragment.java
@Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { final Intent intent = new Intent(getActivity(), ImageDetailActivity.class); intent.putExtra(ImageDetailActivity.GENERAL_ITEM_ID, giLocalObject.getId()); intent.putExtra(ImageDetailActivity.RESPONSE_POSITION, (int) position); if (Utils.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(intent, options.toBundle()); } else {//from w ww .j a va2 s . c o m startActivity(intent); } }
From source file:net.wespot.pim.controller.ImageGridFragment.java
@Override public void onListItemClick(View v, int position, ResponseLocalObject item) { final Intent intent = new Intent(getActivity(), ImageDetailActivity.class); intent.putExtra(ImageDetailActivity.GENERAL_ITEM_ID, item.getGeneralItemLocalObject().getId()); intent.putExtra(ImageDetailActivity.RESPONSE_POSITION, position); if (Utils.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(intent, options.toBundle()); } else {/*from w w w . j a v a 2s.c om*/ startActivity(intent); } }
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// w w w . j a v a 2 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; }