Java Code Examples for androidx.core.view.ViewCompat#setTransitionName()
The following examples show how to use
androidx.core.view.ViewCompat#setTransitionName() .
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: ContactsActivity.java From YcShareElement with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { final ImageView avatarImg = holder.itemView.findViewById(R.id.contacts_avatar); final TextView nameTxt = holder.itemView.findViewById(R.id.contacts_name); final Contacts item = mContactsList.get(position); Glide.with(avatarImg).load(item.avatarRes).apply(RequestOptions.circleCropTransform()).into(avatarImg); nameTxt.setText(item.name); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gotoDetailActivity(item, avatarImg, nameTxt); } }); ViewCompat.setTransitionName(avatarImg,"avatar:"+item.name); ViewCompat.setTransitionName(nameTxt,"name:"+item.name); }
Example 2
Source File: TransitionDetailActivity.java From android-test with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.transition_detail); // Retrieve the correct Item instance, using the ID provided in the Intent mTransitionActivityItem = TransitionActivityItem.getItem(getIntent().getIntExtra(EXTRA_PARAM_ID, 0)); mHeaderImageView = (ImageView) findViewById(R.id.imageview_header); mHeaderTitle = (TextView) findViewById(R.id.textview_title); /** * Set the name of the view's which will be transition to, using the static values above. * This could be done in the layout XML, but exposing it via static variables allows easy * querying from other Activities */ ViewCompat.setTransitionName(mHeaderImageView, VIEW_NAME_HEADER_IMAGE); ViewCompat.setTransitionName(mHeaderTitle, VIEW_NAME_HEADER_TITLE); loadItem(); }
Example 3
Source File: LocalPlayerActivity.java From CastVideos-android with Apache License 2.0 | 6 votes |
private void loadViews() { mVideoView = (VideoView) findViewById(R.id.videoView1); mTitleView = (TextView) findViewById(R.id.titleTextView); mDescriptionView = (TextView) findViewById(R.id.descriptionTextView); mDescriptionView.setMovementMethod(new ScrollingMovementMethod()); mAuthorView = (TextView) findViewById(R.id.authorTextView); mStartText = (TextView) findViewById(R.id.startText); mStartText.setText(Utils.formatMillis(0)); mEndText = (TextView) findViewById(R.id.endText); mSeekbar = (SeekBar) findViewById(R.id.seekBar1); mPlayPause = (ImageView) findViewById(R.id.playPauseImageView); mLoading = (ProgressBar) findViewById(R.id.progressBar1); mControllers = findViewById(R.id.controllers); mContainer = findViewById(R.id.container); mCoverArt = (NetworkImageView) findViewById(R.id.coverArtView); ViewCompat.setTransitionName(mCoverArt, getString(R.string.transition_image)); mPlayCircle = (ImageButton) findViewById(R.id.play_circle); mPlayCircle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { togglePlayback(); } }); }
Example 4
Source File: DetailActivity.java From animation-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.details); // Retrieve the correct Item instance, using the ID provided in the Intent mItem = Item.getItem(getIntent().getIntExtra(EXTRA_PARAM_ID, 0)); mHeaderImageView = findViewById(R.id.imageview_header); mHeaderTitle = findViewById(R.id.textview_title); // BEGIN_INCLUDE(detail_set_view_name) /* * Set the name of the view's which will be transition to, using the static values above. * This could be done in the layout XML, but exposing it via static variables allows easy * querying from other Activities */ ViewCompat.setTransitionName(mHeaderImageView, VIEW_NAME_HEADER_IMAGE); ViewCompat.setTransitionName(mHeaderTitle, VIEW_NAME_HEADER_TITLE); // END_INCLUDE(detail_set_view_name) loadItem(); }
Example 5
Source File: TransitionContainerTransformDemoFragment.java From material-components-android with Apache License 2.0 | 5 votes |
private void addTransitionableTarget(View view, @IdRes int id) { View target = view.findViewById(id); if (target != null) { ViewCompat.setTransitionName(target, String.valueOf(id)); target.setOnClickListener(this::showEndFragment); } }
Example 6
Source File: PlayEmptyControlActivity.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
private void initTransition() { if (isTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { postponeEnterTransition(); ViewCompat.setTransitionName(videoPlayer, IMG_TRANSITION); addTransitionListener(); startPostponedEnterTransition(); } else { videoPlayer.startPlayLogic(); } }
Example 7
Source File: TransitionContainerTransformViewDemoFragment.java From material-components-android with Apache License 2.0 | 5 votes |
private void addTransitionableTarget(@NonNull View view, @IdRes int id) { View target = view.findViewById(id); if (target != null) { ViewCompat.setTransitionName(target, String.valueOf(id)); if (id == R.id.end_card) { target.setOnClickListener(v -> showStartView()); } else { target.setOnClickListener(this::showEndView); } } }
Example 8
Source File: SharedElementLaunchedActivity.java From PhotoDraweeView with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initWindowTransitions(); setContentView(R.layout.activity_shared_element_launched); PhotoDraweeView draweeView = findViewById(R.id.photo_drawee_view); ViewCompat.setTransitionName(draweeView, SharedElementActivity.SHARED_ELEMENT_NAME); draweeView.setPhotoUri(Uri.parse("res:///" + R.drawable.panda)); draweeView.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { onBackPressed(); } }); }
Example 9
Source File: AlbumsAdapter.java From material-components-android with Apache License 2.0 | 5 votes |
public void bind(Album album) { // Use a unique transition name so this item can be used as a shared element when // transitioning to the album details screen. ViewCompat.setTransitionName(container, album.title); container.setOnClickListener(v -> listener.onAlbumClicked(container, album)); albumImage.setImageResource(album.cover); albumTitle.setText(album.title); albumArtist.setText(album.artist); if (albumDuration != null) { albumDuration.setText(album.duration); } }
Example 10
Source File: CommentListActivity.java From NewFastFrame with Apache License 2.0 | 5 votes |
private void initSharedElement() { supportPostponeEnterTransition(); ViewCompat.setTransitionName(headerView, "header"); headerAvatar.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { headerAvatar.getViewTreeObserver().removeOnPreDrawListener(this); supportStartPostponedEnterTransition(); return true; } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setExitSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { View view = null; if (headerDisplay != null) { view = headerDisplay.getLayoutManager().findViewByPosition(index); } if (view != null) { sharedElements.clear(); sharedElements.put(((ImageShareInfoHolder.ImageShareAdapter) headerDisplay.getAdapter()) .getData(index), view); index = -1; } } }); } presenter.registerEvent(PhotoPreEvent.class, photoPreEvent -> { if (photoPreEvent.getFlag() == ConstantUtil.COMMENT_LIST_FLAG) { index = photoPreEvent.getIndex(); } }); }
Example 11
Source File: PlayPickActivity.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
private void initTransition() { if (isTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { postponeEnterTransition(); ViewCompat.setTransitionName(videoPlayer, IMG_TRANSITION); addTransitionListener(); startPostponedEnterTransition(); } else { videoPlayer.startPlayLogic(); } }
Example 12
Source File: ImageContentCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(BasePagerViewHolder viewHolder) { ImageView imageView = viewHolder.getView(R.id.content_item_img); ViewCompat.setTransitionName(imageView, mData.url); Bitmap thumbnail = mData.url.equals(BitmapThumbnail.sKey)?BitmapThumbnail.sBitmap:null; Glide.with(imageView) .load(mData.url) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new FitCenter()) .skipMemoryCache(true) .placeholder(thumbnail == null ? new ColorDrawable(Color.GRAY) : new BitmapDrawable(imageView.getResources(), thumbnail))) .into(imageView); }
Example 13
Source File: ImageFrescoContentCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(BasePagerViewHolder viewHolder) { Fresco.getImagePipeline().evictFromCache(Uri.parse(mData.url)); SimpleDraweeView imageView = viewHolder.getView(R.id.content_item_img); ViewCompat.setTransitionName(imageView, mData.url); Bitmap thumbnail = mData.url.equals(BitmapThumbnail.sKey)?BitmapThumbnail.sBitmap:null; GenericDraweeHierarchy hierarchy = imageView.getHierarchy(); hierarchy.setPlaceholderImage(new BitmapDrawable(imageView.getResources(),thumbnail), ScalingUtils.ScaleType.FIT_CENTER); hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); imageView.setImageURI(mData.url); }
Example 14
Source File: VideoListCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { super.onBindViewHolder(holder, position); SimpleDraweeView simpleDraweeView = holder.itemView.findViewById(R.id.list_item_video); ViewCompat.setTransitionName(simpleDraweeView, mData.url); setSize(holder.itemView); showWebp(simpleDraweeView, mData.webpUrl, true); }
Example 15
Source File: ImageListCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { super.onBindViewHolder(holder, position); ImageView imageView = holder.itemView.findViewById(R.id.list_item_img); ViewCompat.setTransitionName(imageView, mData.url); setSize(holder.itemView); Glide.with(imageView) .load(mData.url) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new FitCenter()) .placeholder(new ColorDrawable(Color.GRAY))) .into(imageView); }
Example 16
Source File: DetailActivity.java From YcShareElement with Apache License 2.0 | 5 votes |
private void setData(){ TextView descTxt = findViewById(R.id.desc); Contacts item = getIntent().getParcelableExtra(ContactsActivity.KEY_CONTACTS); Glide.with(mAvatarImg).load(item.avatarRes).apply(RequestOptions.circleCropTransform()).into(mAvatarImg); mNameTxt.setText(item.name); descTxt.setText(item.desc); ViewCompat.setTransitionName(mAvatarImg,"avatar:"+item.name); ViewCompat.setTransitionName(mNameTxt,"name:"+item.name); }
Example 17
Source File: KittenGridAdapter.java From AndroidNavigation with MIT License | 5 votes |
@Override public void onBindViewHolder(final KittenViewHolder viewHolder, final int position) { switch (position % 6) { case 0: viewHolder.image.setImageResource(R.drawable.placekitten_1); break; case 1: viewHolder.image.setImageResource(R.drawable.placekitten_2); break; case 2: viewHolder.image.setImageResource(R.drawable.placekitten_3); break; case 3: viewHolder.image.setImageResource(R.drawable.placekitten_4); break; case 4: viewHolder.image.setImageResource(R.drawable.placekitten_5); break; case 5: viewHolder.image.setImageResource(R.drawable.placekitten_6); break; } // It is important that each shared element in the source screen has a unique transition name. // For example, we can't just give all the images in our grid the transition name "kittenImage" // because then we would have conflicting transition names. // By appending "_image" to the position, we can support having multiple shared elements in each // grid cell in the future. ViewCompat.setTransitionName(viewHolder.image, String.valueOf(position) + "_image"); viewHolder.image.setOnClickListener(v -> mListener.onKittenClicked(viewHolder, position)); }
Example 18
Source File: PlayActivity.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
private void initTransition() { if (isTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { postponeEnterTransition(); ViewCompat.setTransitionName(videoPlayer, IMG_TRANSITION); addTransitionListener(); startPostponedEnterTransition(); } else { videoPlayer.startPlayLogic(); } }
Example 19
Source File: MountState.java From litho with Apache License 2.0 | 4 votes |
private static void setTransitionName(View view, @Nullable String transitionName) { ViewCompat.setTransitionName(view, transitionName); }
Example 20
Source File: ChatActivity.java From FChat with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat); parent_view = findViewById(android.R.id.content); pfbd = new ParseFirebaseData(this); set = new SettingsAPI(this); // animation transition ViewCompat.setTransitionName(parent_view, KEY_FRIEND); // initialize conversation data Intent intent = getIntent(); friend = (Friend) intent.getExtras().getSerializable(KEY_FRIEND); initToolbar(); iniComponen(); chatNode_1 = set.readSetting(Constants.PREF_MY_ID) + "-" + friend.getId(); chatNode_2 = friend.getId() + "-" + set.readSetting(Constants.PREF_MY_ID); valueEventListener=new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { Log.d(Constants.LOG_TAG,"Data changed from activity"); if (dataSnapshot.hasChild(chatNode_1)) { chatNode = chatNode_1; } else if (dataSnapshot.hasChild(chatNode_2)) { chatNode = chatNode_2; } else { chatNode = chatNode_1; } items.clear(); items.addAll(pfbd.getMessagesForSingleUser(dataSnapshot.child(chatNode))); //Here we are traversing all the messages and mark all received messages read for (DataSnapshot data : dataSnapshot.child(chatNode).getChildren()) { if (data.child(Constants.NODE_RECEIVER_ID).getValue().toString().equals(set.readSetting(Constants.PREF_MY_ID))) { data.child(Constants.NODE_IS_READ).getRef().runTransaction(new Transaction.Handler() { @NonNull @Override public Transaction.Result doTransaction(@NonNull MutableData mutableData) { mutableData.setValue(true); return Transaction.success(mutableData); } @Override public void onComplete(@Nullable DatabaseError databaseError, boolean b, @Nullable DataSnapshot dataSnapshot) { } }); } } // TODO: 12/09/18 Change it to recyclerview mAdapter = new ChatDetailsListAdapter(ChatActivity.this, items); listview.setAdapter(mAdapter); listview.requestFocus(); registerForContextMenu(listview); } @Override public void onCancelled(DatabaseError databaseError) { new CustomToast(ChatActivity.this).showError(getString(R.string.error_could_not_connect)); } }; ref = FirebaseDatabase.getInstance().getReference(Constants.MESSAGE_CHILD); ref.addValueEventListener(valueEventListener); // for system bar in lollipop if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Tools.systemBarLolipop(this); } }