Java Code Examples for android.view.View#setTransitionName()

The following examples show how to use android.view.View#setTransitionName() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@SuppressLint("NewApi")
@Override
void handleElementOnClick(View view) {
    int itemPosition = getRecyclerView().getChildAdapterPosition(view);

    if (itemPosition < 0 || getElements().size() <= itemPosition) {
        return;
    }

    boolean deviceHasLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
    StreamInfo item = getElements().get(itemPosition);
    Intent intent = LiveStreamActivity.createLiveStreamIntent(item, deviceHasLollipop, getContext());

    if (deviceHasLollipop) {
        View sharedView = view.findViewById(R.id.image_stream_preview);
        sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
        final ActivityOptionsCompat options = ActivityOptionsCompat.
                makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));
        activity.startActivity(intent, options.toBundle());
    } else {
        getContext().startActivity(intent);
        activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
    }
}
 
Example 2
@SuppressLint("NewApi")
@Override
void handleElementOnClick(View view) {
	int itemPosition =  getRecyclerView().getChildAdapterPosition(view);

	if (itemPosition < 0 || getElements().size() <= itemPosition) {
		return;
	}

	boolean deviceHasLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
	StreamInfo item = getElements().get(itemPosition);
	Intent intent = LiveStreamActivity.createLiveStreamIntent(item, deviceHasLollipop, getContext());

	if (deviceHasLollipop) {
		View sharedView = view.findViewById(R.id.image_stream_preview);
		sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
		final ActivityOptionsCompat options = ActivityOptionsCompat.
				makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));
		activity.startActivity(intent, options.toBundle());
	} else {
		getContext().startActivity(intent);
		activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
	}
}
 
Example 3
Source Project: Twire   File: VODAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
void handleElementOnClick(final View view) {
    final int itemPosition = getRecyclerView().getChildAdapterPosition(view);
    VideoOnDemand item = getElements().get(itemPosition);
    if (activity instanceof VODActivity) {
        ((VODActivity) activity).startNewVOD(item);
    } else {
        Intent intent = VODActivity.createVODIntent(item, getContext());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            intent.putExtra(getContext().getString(R.string.stream_preview_url), item.getMediumPreview());
            intent.putExtra(getContext().getString(R.string.stream_preview_alpha), hasVodBeenWatched(item.getVideoId()) ? VOD_WATCHED_IMAGE_ALPHA : 1.0f);

            final View sharedView = view.findViewById(R.id.image_stream_preview);
            sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
            final ActivityOptionsCompat options = ActivityOptionsCompat.
                    makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));

            activity.setExitSharedElementCallback(new SharedElementCallback() {
                @SuppressLint("NewApi")
                @Override
                public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                    super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

                    sharedView.animate().alpha(VOD_WATCHED_IMAGE_ALPHA).setDuration(300).start();
                    activity.setExitSharedElementCallback(null);
                }
            });

            activity.startActivity(intent, options.toBundle());
        } else {
            getContext().startActivity(intent);
            activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
        }
    }
}
 
Example 4
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_helper_result);

    Request request = (Request) getIntent().getSerializableExtra(REQUEST_EXTRA_KEY_DATA);
    TextView tvRequest = findViewById(R.id.tv_request);
    if (request != null) {
        tvRequest.setText(request.toString());
    }

    Intent intent = new Intent();
    intent.putExtra(RESULT_EXTRA_KEY_DATA, new Result("Result-name", "Result-value"));
    setResult(Activity.RESULT_OK, intent);

    View btnFinish = findViewById(R.id.btn_finish);
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        btnFinish.setTransitionName("SHARED_ELEMENT");
    }
    btnFinish.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.finishActivity(TestActivityResult.this);
        }
    });

    findViewById(R.id.iv_prop).setBackgroundColor(ResUtils.getAttrColor(this, R.attr.custom_prop));
}
 
Example 5
@Override
void handleElementOnClick(final View view) {
	final int itemPosition =  getRecyclerView().getChildAdapterPosition(view);
	VideoOnDemand item = getElements().get(itemPosition);
	if (activity instanceof VODActivity) {
		((VODActivity) activity).startNewVOD(item);
	} else {
		Intent intent = VODActivity.createVODIntent(item, getContext());

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			intent.putExtra(getContext().getString(R.string.stream_preview_url), item.getMediumPreview());
			intent.putExtra(getContext().getString(R.string.stream_preview_alpha), hasVodBeenWatched(item.getVideoId()) ? VOD_WATCHED_IMAGE_ALPHA : 1.0f);

			final View sharedView = view.findViewById(R.id.image_stream_preview);
			sharedView.setTransitionName(getContext().getString(R.string.stream_preview_transition));
			final ActivityOptionsCompat options = ActivityOptionsCompat.
					makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.stream_preview_transition));

			activity.setExitSharedElementCallback(new SharedElementCallback() {
				@SuppressLint("NewApi")
				@Override
				public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
					super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

					sharedView.animate().alpha(VOD_WATCHED_IMAGE_ALPHA).setDuration(300).start();
					activity.setExitSharedElementCallback(null);
				}
			});

			activity.startActivity(intent, options.toBundle());
		} else {
			getContext().startActivity(intent);
			activity.overridePendingTransition(R.anim.slide_in_bottom_anim, R.anim.fade_out_semi_anim);
		}
	}
}
 
Example 6
@Override
void handleElementOnClick(final View view) {
    int itemPosition = getRecyclerView().getChildAdapterPosition(view);
    final ChannelInfo item = getElements().get(itemPosition);
    final StreamerInfoViewHolder vh = (StreamerInfoViewHolder) getRecyclerView().getChildViewHolder(view);
    final PreviewTarget previewTarget = getTargets().get(vh.getTargetsKey());

    // Create intent for opening StreamerInfo activity. Send the StreamerInfo object with
    // the intent, and flag it to make sure it creates a new task on the history stack
    final Intent intent = new Intent(getContext(), ChannelActivity.class);
    intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), item);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View sharedView = view.findViewById(R.id.profileLogoImageView);
        sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
        final ActivityOptionsCompat options = ActivityOptionsCompat.
                makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

        activity.setExitSharedElementCallback(new SharedElementCallback() {
            @SuppressLint("NewApi")
            @Override
            public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

                if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
                    View element = sharedElements.get(0);
                    Animation anim = new RoundImageAnimation(element.getWidth() / 2, 0, (ImageView) element, previewTarget.getPreview());
                    anim.setDuration(200);
                    anim.setInterpolator(new DecelerateInterpolator());
                    view.startAnimation(anim);
                }
                activity.setExitSharedElementCallback(null);
            }
        });
        activity.startActivity(intent, options.toBundle());
    } else {
        getContext().startActivity(intent);
        if (activity != null) {
            activity.overridePendingTransition(R.anim.slide_in_right_anim, R.anim.fade_out_semi_anim);
        }
    }
}
 
Example 7
Source Project: letv   File: ViewCompatLollipop.java    License: Apache License 2.0 4 votes vote down vote up
public static void setTransitionName(View view, String transitionName) {
    view.setTransitionName(transitionName);
}
 
Example 8
@Override
void handleElementOnClick(final View view) {
	int itemPosition = getRecyclerView().getChildAdapterPosition(view);
	final ChannelInfo item = getElements().get(itemPosition);
	final StreamerInfoViewHolder vh = (StreamerInfoViewHolder) getRecyclerView().getChildViewHolder(view);
	final PreviewTarget previewTarget = getTargets().get(vh.getTargetsKey());

	// Create intent for opening StreamerInfo activity. Send the StreamerInfo object with
	// the intent, and flag it to make sure it creates a new task on the history stack
	final Intent intent = new Intent(getContext(), ChannelActivity.class);
	intent.putExtra(getContext().getResources().getString(R.string.channel_info_intent_object), item);
	intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		View sharedView = view.findViewById(R.id.profileLogoImageView);
		sharedView.setTransitionName(getContext().getString(R.string.streamerInfo_transition));
		final ActivityOptionsCompat options = ActivityOptionsCompat.
				makeSceneTransitionAnimation(activity, sharedView, getContext().getString(R.string.streamerInfo_transition));

		activity.setExitSharedElementCallback(new SharedElementCallback() {
			@SuppressLint("NewApi")
			@Override
			public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
				super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);

				if (!sharedElements.isEmpty() && sharedElements.get(0) != null && previewTarget != null) {
					View element = sharedElements.get(0);
					Animation anim = new RoundImageAnimation(element.getWidth()/2, 0, (ImageView) element, previewTarget.getPreview());
					anim.setDuration(200);
					anim.setInterpolator(new DecelerateInterpolator());
					view.startAnimation(anim);
				}
				activity.setExitSharedElementCallback(null);
			}
		});
		activity.startActivity(intent, options.toBundle());
	} else {
		getContext().startActivity(intent);
		if(activity != null) {
			activity.overridePendingTransition(R.anim.slide_in_right_anim, R.anim.fade_out_semi_anim);
		}
	}
}
 
Example 9
public static void setTransitionName(View view, String transitionName) {
    view.setTransitionName(transitionName);
}
 
Example 10
@Override
public void setTransitionName(@NonNull View v, @Nullable String name) {
    v.setTransitionName(name);
}