Java Code Examples for android.support.v4.app.ActivityOptionsCompat#makeSceneTransitionAnimation()

The following examples show how to use android.support.v4.app.ActivityOptionsCompat#makeSceneTransitionAnimation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NewsListFragment.java    From SimpleNews with Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(View view, int position) {
    if (mData.size() <= 0) {
        return;
    }
    NewsBean news = mAdapter.getItem(position);
    Intent intent = new Intent(getActivity(), NewsDetailActivity.class);
    intent.putExtra("news", news);

    View transitionView = view.findViewById(R.id.ivNews);
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                    transitionView, getString(R.string.transition_news_img));

    ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
}
 
Example 2
Source File: TodoListActivity.java    From todo-android with Apache License 2.0 6 votes vote down vote up
@OnItemLongClick(R.id.todo_list_listview)
boolean onItemLongClick(int position, View view) {
    Todo todo = adapter.getItem(position);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Pair<View, String> pair =
                new Pair<>(view.findViewById(R.id.item_todo_textview), getString(R.string.transition_name_todo_name));
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, pair);

        startActivity(TodoCreateActivity.createIntent(this, todo.getId()), options.toBundle());
    } else {
        startActivity(TodoCreateActivity.createIntent(this, todo.getId()));
    }

    return true;
}
 
Example 3
Source File: ImageAdapter.java    From Panoramic-Screenshot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	
	if (file == null) return;
	
	if (v == image) {
		Intent i = new Intent(mContext, PictureActivity.class);
		i.putExtra(PictureActivity.EXTRA_FILE, file.getAbsolutePath());
		
		if (mContext instanceof Activity) {
			ActivityOptionsCompat o = ActivityOptionsCompat.makeSceneTransitionAnimation(
				(Activity) mContext, image, PictureActivity.TRANSIT_PIC);
			ActivityCompat.startActivity((Activity) mContext, i, o.toBundle());
		} else {
			mContext.startActivity(i);
		}
	}
}
 
Example 4
Source File: AutoSharedElementCallback.java    From native-navigation with MIT License 6 votes vote down vote up
/**
 * Automatically creates activity options with all of the transition views within view.
 */
public static ActivityOptionsCompat getActivityOptions(Activity activity, View view, boolean
    includeSystemUi) {
  List<Pair<View, String>> transitionViews = new ArrayList<>();

  if (VERSION.SDK_INT >= TARGET_API) {
    ViewUtils.findTransitionViews(view, transitionViews);
    if (includeSystemUi) {
      addSystemUi(activity, transitionViews);
    }
  }

  //noinspection unchecked
  return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionViews.toArray
      (new Pair[transitionViews.size()]));
}
 
Example 5
Source File: SignInFragment.java    From android-topeka with Apache License 2.0 6 votes vote down vote up
private void performSignInWithTransition(View v) {
    final Activity activity = getActivity();
    if (v == null || ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Don't run a transition if the passed view is null
        CategorySelectionActivity.start(activity, mPlayer);
        activity.finish();
        return;
    }

    if (ApiLevelHelper.isAtLeast(Build.VERSION_CODES.LOLLIPOP)) {
        activity.getWindow().getSharedElementExitTransition().addListener(
                new TransitionListenerAdapter() {
                    @Override
                    public void onTransitionEnd(Transition transition) {
                        activity.finish();
                    }
                });

        final Pair[] pairs = TransitionHelper.createSafeTransitionParticipants(activity, true,
                new Pair<>(v, activity.getString(R.string.transition_avatar)));
        @SuppressWarnings("unchecked")
        ActivityOptionsCompat activityOptions = ActivityOptionsCompat
                .makeSceneTransitionAnimation(activity, pairs);
        CategorySelectionActivity.start(activity, mPlayer, activityOptions);
    }
}
 
Example 6
Source File: SavedPicsFragment.java    From StatusSaver-for-Whatsapp with Apache License 2.0 6 votes vote down vote up
@Override
public void displayImage(int position, ImageModel imageModel) {

    // Get ImageView at current position, to apply transition effect
    View view = layoutManager.findViewByPosition(position);
    ImageView imageView = (ImageView) view.findViewById(R.id.image_thumbnail);

    Intent intent = new Intent(getActivity(), ImageSliderActivity.class);
    Bundle bundle = new Bundle();
    bundle.putInt(ImageSliderActivity.INTENT_IMAGE_TYPE, ImageSliderActivity.IMAGES_TYPE_SAVED);
    bundle.putParcelable(ImageSliderActivity.INTENT_IMAGE_DATA, imageModel);
    intent.putExtras(bundle);
    intent.putExtra(EXTRA_IMAGE_TRANSITION_NAME, ViewCompat.getTransitionName(imageView));

    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
            getActivity(),
            imageView,
            ViewCompat.getTransitionName(imageView));
    startActivity(intent, options.toBundle());
}
 
Example 7
Source File: CommitDetailActivity.java    From OpenHub with GNU General Public License v3.0 5 votes vote down vote up
public static void show(@NonNull Activity activity, @NonNull String user, @NonNull String repo,
                        @NonNull RepoCommit commit, @NonNull View userAvatar) {
    Intent intent = new Intent(activity, CommitDetailActivity.class);
    intent.putExtras(BundleHelper.builder().put("user", user).put("repo", repo)
            .put("commit", commit).build());
    ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
            .makeSceneTransitionAnimation(activity, userAvatar, "userAvatar");
    activity.startActivity(intent, optionsCompat.toBundle());
}
 
Example 8
Source File: ToolGridFragment.java    From auid2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
    final CaptionedImageView captionedImageView = (CaptionedImageView) view;
    ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(
            getActivity(),
            new Pair<View, String>(captionedImageView.getImageView(), getString(R.string.transition_image_view)),
            new Pair<View, String>(captionedImageView.getTextView(), getString(R.string.transition_text_view))
    );
    ToolListActivity.startActivity(getActivity(), mToolGridAdapter.getItem(position), activityOptions.toBundle());

}
 
Example 9
Source File: DetailActivity.java    From io2015-codelabs with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void launch(Activity activity, String attraction, View heroView) {
    Intent intent = getLaunchIntent(activity, attraction);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, heroView, heroView.getTransitionName());
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
 
Example 10
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
/**
 * 多个共享元素
 */
private void moreToActivityB(){
    Intent intent = new Intent(this, ActivityB.class);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        Pair<View, String> pair1 = new Pair<View, String>(iv, "test_image");
        Pair<View, String> pair2 = new Pair<View, String>(tv, "test_tv");
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this,pair1,pair2);
        startActivity(intent,options.toBundle());

    }else{
        startActivity(intent);
    }
}
 
Example 11
Source File: DetailActivity.java    From io2015-codelabs with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void launch(Activity activity, String attraction, View heroView) {
    Intent intent = getLaunchIntent(activity, attraction);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity, heroView, heroView.getTransitionName());
        ActivityCompat.startActivity(activity, intent, options.toBundle());
    } else {
        activity.startActivity(intent);
    }
}
 
Example 12
Source File: BookDetailActivity.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
/**
 * @param context      activity
 * @param bookItemBean bean
 * @param imageView    imageView
 */
public static void start(Activity context, BookItemBean bookItemBean, ImageView imageView) {
    Intent intent = new Intent(context, BookDetailActivity.class);
    intent.putExtra(INTENT_KEY_BOOK_BOOK_ITEM_BEAN, bookItemBean);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation
            (context, imageView, ResourcesUtils.getString(R.string.transition_book_img));
    //与xml文件对应
    ActivityCompat.startActivity(context, intent, options.toBundle());
}
 
Example 13
Source File: CharacterActivity.java    From Villains-and-Heroes with Apache License 2.0 5 votes vote down vote up
public static void start(@NonNull Activity activity, @NonNull View characterView, @NonNull CharacterVO character) {

        ActivityOptionsCompat options = ActivityOptionsCompat
                .makeSceneTransitionAnimation(activity,
                        characterView, ViewCompat.getTransitionName(characterView));
        Intent intent = new Intent(activity, CharacterActivity.class);
        intent.putExtra(EXTRA_CHARACTER, character);

        ActivityCompat.startActivity(activity, intent, options.toBundle());
    }
 
Example 14
Source File: BasePageJump.java    From Tok-Android with GNU General Public License v3.0 5 votes vote down vote up
protected static void jumpWithTransition(Context context, Intent intent,
    Pair<View, String>... sharedElements) {
    if (context instanceof Activity
        && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
        && sharedElements != null
        && sharedElements.length > 0) {
        ActivityOptionsCompat compat =
            ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context,
                sharedElements);
        ActivityCompat.startActivity(context, intent, compat.toBundle());
    } else {
        jump(context, intent);
    }
}
 
Example 15
Source File: SearchableFragment.java    From Loop with Apache License 2.0 5 votes vote down vote up
@Override
    public void onItemClick(int position, View view) {
        Video video = videosAdapter.getItem(position);
        if (video != null) {
            Intent intent = new Intent(getActivity(), VideoDetailsActivity.class);

            Bundle bundle = new Bundle();
            bundle.putParcelable(LikedVideosFragment.KEY_VIDEO, video);
            intent.putExtras(bundle);

            Pair<View, String> p1 = Pair.create(view.findViewById(R.id.video_thumbnail_iv), "videoTransition");
//                Pair<View, String> p2 = Pair.create((View) view.findViewById(R.id.title_tv), "titleTransition");
//                Pair<View, String> p3 = Pair.create((View) view.findViewById(R.id.subtitle_tv), "subtitleTransition");
//        Pair<View, String> p4 = Pair.create((View)view.findViewById(R.id.uploaded_tv), "uploadedTransition");

//                ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
//                        p1, p2, p3);

            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
                    p1);

//            ActivityCompat.startActivity(getActivity(), intent, options.toBundle());

                startActivity(intent);
        }

    }
 
Example 16
Source File: MeiziAdapter.java    From Gank.io with GNU General Public License v3.0 5 votes vote down vote up
@OnClick(R.id.rl_gank)
void gankClick() {
  ShareElement.shareDrawable = ivMeizi.getDrawable();
  Intent intent = new Intent(context, GankActivity.class);
  intent.putExtra(PanConfig.MEIZI, (Serializable) card.getTag());
  ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
      .makeSceneTransitionAnimation((Activity) context, ivMeizi, PanConfig.TRANSLATE_GIRL_VIEW);
  ActivityCompat.startActivity(context, intent, optionsCompat.toBundle());
}
 
Example 17
Source File: DetailsFragment.java    From mosby with Apache License 2.0 5 votes vote down vote up
@OnClick(R.id.replay) public void onReplayClicked() {

    ActivityOptionsCompat options =
        ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), replayView,
            getString(R.string.shared_write_action));

    intentStarter.showWriteMail(getActivity(), mail, options.toBundle());
  }
 
Example 18
Source File: DetailActivity.java    From GoogleFitExample with Apache License 2.0 5 votes vote down vote up
/**
 * Used to start the activity using a custom animation.
 *
 * @param activity Reference to the Android Activity we are animating from
 * @param transitionView Target view used in the scene transition animation
 * @param workout Type of workout the DetailActivity should load
 */
public static void launch(BaseActivity activity, View transitionView, Workout workout) {
    ActivityOptionsCompat options =
            ActivityOptionsCompat.makeSceneTransitionAnimation(
                    activity, transitionView, EXTRA_IMAGE);
    Intent intent = new Intent(activity, DetailActivity.class);
    intent.putExtra(EXTRA_IMAGE, WorkoutTypes.getImageById(workout.type));
    intent.putExtra(EXTRA_TITLE, WorkoutTypes.getWorkOutTextById(workout.type));
    intent.putExtra(EXTRA_TYPE, workout.type);
    ActivityCompat.startActivity(activity, intent, options.toBundle());
}
 
Example 19
Source File: GirlFragment.java    From GankGirl with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void onItemClick(View view, int position) {
    ActivityOptionsCompat options;
    if (Build.VERSION.SDK_INT >= 21) {
        options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                getActivity(), view, mGirlAdapter.getItem(position)._id);
    } else {
        options = ActivityOptionsCompat.makeScaleUpAnimation(
                view,
                view.getWidth() / 2, view.getHeight() / 2,//拉伸开始的坐标
                0, 0);//拉伸开始的区域大小,这里用(0,0)表示从无到全屏
    }
    ActivityCompat.startActivity(getActivity(), ImagePagerActivity.newIntent(view.getContext(), position, mGirlAdapter.getData()), options.toBundle());
}
 
Example 20
Source File: QuantitySelection.java    From android-kubernetes-blockchain with Apache License 2.0 4 votes vote down vote up
public void getTransactionResult(final String resultId, final int attemptNumber) {
    if (attemptNumber < 60) {
        final Activity activity = this;
        // GET THE TRANSACTION RESULT
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, BACKEND_URL + "/api/results/" + resultId, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        BackendResult backendResult = gson.fromJson(response.toString(), BackendResult.class);

                        // Check status of queued request
                        if (backendResult.status.equals("pending")) {
                            // if it is still pending, check again
                            new Handler().postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    getTransactionResult(resultId,attemptNumber + 1);
                                }
                            },500);
                        } else if (backendResult.status.equals("done")) {
                            // when blockchain is done processing the request, get the contract model and start activity
                            ResultOfMakePurchase resultOfMakePurchase = gson.fromJson(backendResult.result, ResultOfMakePurchase.class);
                            ContractModel contractModel = gson.fromJson(resultOfMakePurchase.result.results.payload, ContractModel.class);

                            // start activity of contract details
                            Intent intent = new Intent(getApplicationContext(), ContractDetails.class);
                            intent.putExtra("CONTRACT_JSON", new Gson().toJson(contractModel, ContractModel.class));

                            Pair<View, String> pair1 = Pair.create(findViewById(R.id.productImageInQuantity),"productImage");
                            ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pair1);

                            activity.startActivity(intent,options.toBundle());
                        } else {
                            Log.d(TAG, "Response is: " + response.toString());
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.d(TAG, "That didn't work!");
            }
        });
        queue.add(jsonObjectRequest);
    }
}