Java Code Examples for android.widget.ImageView#setTransitionName()

The following examples show how to use android.widget.ImageView#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
Source Project: atlas   File: PhotoAdapter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {
    Photo data = photos.get(position);
    TextView authorview = holder.itemView.findViewById(R.id.author);
    ImageView photoview = holder.itemView.findViewById(R.id.photo);
    holder.setAuthor(data.author);
    photoview.setTransitionName(String.format(photoTransitionFormat, data.id));
    authorview.setText(data.author);
    authorview.setTransitionName(String.format(authorTransitionFormat, data.id));
    holder.setId(data.id);
    Glide.with(layoutInflater.getContext())
            .load(data.getPhotoUrl(requestedPhotoWidth))
            .placeholder(R.color.placeholder)
            .override(ImageSize.NORMAL[0], ImageSize.NORMAL[1])
            .into((ImageView) holder.itemView.findViewById(R.id.photo));
}
 
Example 2
@Override
public Object instantiateItem(ViewGroup container, int position) {
    ImageView imageView = new ImageView(container.getContext());
    imageView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    imageView.setImageURI(uris.get(position));
    DismissFrameLayout layout = new DismissFrameLayout(container.getContext());
    layout.setDismissListener(onDismissListener);
    layout.setLayoutParams(new ViewPager.LayoutParams());
    layout.addView(imageView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        String name = container.getContext()
                .getString(R.string.transition_name, adapterPosition, position);
        imageView.setTransitionName(name);
        imageView.setTag(name);
        if (position == current) {
            setStartPostTransition(imageView);
        }
    }

    container.addView(layout);
    return layout;
}
 
Example 3
@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {
    Photo data = photos.get(position);
    TextView authorview = holder.itemView.findViewById(R.id.author);
    ImageView photoview = holder.itemView.findViewById(R.id.photo);
    holder.setAuthor(data.author);
    photoview.setTransitionName(String.format(photoTransitionFormat, data.id));
    authorview.setText(data.author);
    authorview.setTransitionName(String.format(authorTransitionFormat, data.id));
    holder.setId(data.id);
    Glide.with(layoutInflater.getContext())
            .load(data.getPhotoUrl(requestedPhotoWidth))
            .placeholder(R.color.placeholder)
            .override(ImageSize.NORMAL[0], ImageSize.NORMAL[1])
            .into((ImageView) holder.itemView.findViewById(R.id.photo));
}
 
Example 4
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    App app = activity.getAppByListPosition(position);
    if (null == app) {
        return;
    }
    DetailsActivity.app = app;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ImageView iconView = view.findViewById(R.id.icon);
        String transitionNameIcon = activity.getString(R.string.details_transition_view_name);
        iconView.setTransitionName(transitionNameIcon);
        TextView textView = view.findViewById(R.id.text1);
        String transitionNameText = activity.getString(R.string.details_transition_view_name_text);
        textView.setTransitionName(transitionNameText);
        activity.startActivity(
            DetailsActivity.getDetailsIntent(activity, DetailsActivity.app.getPackageName()),
            ActivityOptionsCompat.makeSceneTransitionAnimation(
                activity,
                new Pair<View, String>(iconView, transitionNameIcon),
                new Pair<View, String>(textView, transitionNameText)
            ).toBundle()
        );
    } else {
        activity.startActivity(DetailsActivity.getDetailsIntent(activity, DetailsActivity.app.getPackageName()));
    }
}
 
Example 5
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(
            R.layout.fragment_artist_detail, container, false);

    artistArt = (ImageView) rootView.findViewById(R.id.artist_art);

    collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    appBarLayout = (AppBarLayout) rootView.findViewById(R.id.app_bar);

    if (getArguments().getBoolean("transition")) {
        artistArt.setTransitionName(getArguments().getString("transition_name"));
    }

    toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    setupToolbar();
    setUpArtistDetails();

    getChildFragmentManager().beginTransaction().replace(R.id.container, ArtistMusicFragment.newInstance(artistID)).commit();


    return rootView;
}
 
Example 6
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_streamer_info);

	// Get the various handles of view and layouts that is part of this view
	streamerImage 			= (ImageView) findViewById(R.id.profileImageView);
	additionalInfoLayout 	= (LinearLayout) findViewById(R.id.additional_info_wrapper);
	streamerInfoName 		= (TextView) findViewById(R.id.twitch_name);
	streamerViewers 		= (TextView) findViewById(R.id.txt_viewers);
	streamerFollowers 		= (TextView) findViewById(R.id.txt_followers);
	toolbar 				= (Toolbar) findViewById(R.id.StreamerInfo_Toolbar);
	additionalToolbar 		= (Toolbar) findViewById(R.id.additional_toolbar);
	mViewPager				= (ViewPager) findViewById(R.id.container);
	mTabs					= (TabLayout) findViewById(R.id.tabs);
	mAppBar					= (AppBarLayout) findViewById(R.id.appbar);
	mFab 					= (FloatingActionButton) findViewById(R.id.fab);

	setSupportActionBar(toolbar);
	if (getSupportActionBar() != null) {
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}

	// Get the StreamerInfo object sent with the intent to open this activity
	Intent intent = getIntent();
	info = intent.getParcelableExtra(getResources().getString(R.string.channel_info_intent_object));

	streamerInfoName		.setText(info.getDisplayName());
	streamerFollowers		.setText(getReadableInt(info.getFollowers()));
	streamerViewers			.setText(getReadableInt(info.getViews()));

	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		streamerImage.setTransitionName(getString(R.string.streamerInfo_transition));
	}

	setUpTabs();
	initStreamerImageAndColors();
	initiateFAB();
}
 
Example 7
@Override
@NonNull
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    final Song song = getItem(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_list, parent, false);
    }

    final TextView songTitle = convertView.findViewById(R.id.title);
    final TextView songInfo = convertView.findViewById(R.id.text);
    final ImageView albumArt = convertView.findViewById(R.id.image);
    final View shortSeparator = convertView.findViewById(R.id.short_separator);

    if (position == getCount() - 1) {
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.GONE);
        }
    } else {
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.VISIBLE);
        }
    }

    songTitle.setText(song.title);
    songInfo.setText(song.albumName);

    SongGlideRequest.Builder.from(Glide.with(activity), song)
            .checkIgnoreMediaStore(activity).build()
            .into(albumArt);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        albumArt.setTransitionName(activity.getString(R.string.transition_album_art));
    }

    final ImageView overflowButton = convertView.findViewById(R.id.menu);
    overflowButton.setOnClickListener(new SongMenuHelper.OnClickSongMenu(activity) {
        @Override
        public Song getSong() {
            return song;
        }

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.action_go_to_album) {
                Pair[] albumPairs = new Pair[]{
                        Pair.create(albumArt, activity.getResources().getString(R.string.transition_album_art))
                };
                NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
                return true;
            }
            return super.onMenuItemClick(item);
        }
    });

    convertView.setActivated(isChecked(song));
    convertView.setOnClickListener(view -> {
        if (isInQuickSelectMode()) {
            toggleChecked(song);
        } else {
            MusicPlayerRemote.openQueue(dataSet, position, true);
        }
    });
    convertView.setOnLongClickListener(view -> {
        toggleChecked(song);
        return true;
    });

    return convertView;
}
 
Example 8
@Override
@NonNull
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    final Song song = getItem(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_list, parent, false);
    }

    final TextView songTitle = convertView.findViewById(R.id.title);
    final TextView songInfo = convertView.findViewById(R.id.text);
    final ImageView albumArt = convertView.findViewById(R.id.image);
    final View shortSeparator = convertView.findViewById(R.id.short_separator);

    if (shortSeparator != null) {
        shortSeparator.setVisibility((position == getCount() - 1) ? View.GONE : View.VISIBLE);
    }

    songTitle.setText(song.title);
    songInfo.setText(song.albumName);

    // TODO This album art loading can be factorized with the decorate() helper function
    if (!MusicPlayerRemote.isPlaying(song)) {
        GlideApp.with(activity)
            .asDrawable()
            .load(VinylGlideExtension.getSongModel(song))
            .transition(VinylGlideExtension.getDefaultTransition())
            .songOptions(song)
            .into(albumArt);
    }
    PlayingSongDecorationUtil.decorate(songTitle, albumArt, null, song, activity, true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        albumArt.setTransitionName(activity.getString(R.string.transition_album_art));
    }

    final ImageView overflowButton = convertView.findViewById(R.id.menu);
    overflowButton.setOnClickListener(new SongMenuHelper.OnClickSongMenu(activity) {
        @Override
        public Song getSong() {
            return song;
        }

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.action_go_to_album) {
                Pair[] albumPairs = new Pair[]{
                        Pair.create(albumArt, activity.getResources().getString(R.string.transition_album_art))
                };
                NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
                return true;
            }
            return super.onMenuItemClick(item);
        }
    });

    convertView.setActivated(isChecked(song));
    convertView.setOnClickListener(view -> {
        if (isInQuickSelectMode()) {
            toggleChecked(song);
        } else {
            MusicPlayerRemote.openQueue(dataSet, position, true);
        }
    });
    convertView.setOnLongClickListener(view -> {
        toggleChecked(song);
        return true;
    });

    return convertView;
}
 
Example 9
@TargetApi(21)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(
            R.layout.fragment_album_detail, container, false);

    albumArt = (ImageView) rootView.findViewById(R.id.album_art);
    artistArt = (ImageView) rootView.findViewById(R.id.artist_art);
    albumTitle = (TextView) rootView.findViewById(R.id.album_title);
    albumDetails = (TextView) rootView.findViewById(R.id.album_details);

    toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);

    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);

    if (getArguments().getBoolean("transition")) {
        albumArt.setTransitionName(getArguments().getString("transition_name"));
    }
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    appBarLayout = (AppBarLayout) rootView.findViewById(R.id.app_bar);
    recyclerView.setEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    album = AlbumLoader.getAlbum(getActivity(), albumID);

    setAlbumart();

    setUpEverything();


    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    AlbumSongsAdapter adapter = (AlbumSongsAdapter) recyclerView.getAdapter();
                    MusicPlayer.playAll(getActivity(), adapter.getSongIds(), 0, albumID, TimberUtils.IdType.Album, true);
                    NavigationUtils.navigateToNowplaying(getActivity(), false);
                }
            }, 150);
        }
    });

    return rootView;
}
 
Example 10
Source Project: Game-of-Thrones   File: DetailActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void initTransitionInImageView(ImageView ivp) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    ivp.setTransitionName(transitionName);
  }
}
 
Example 11
@Override
@NonNull
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    final Song song = getItem(position);
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_list, parent, false);
    }

    final TextView songTitle = convertView.findViewById(R.id.title);
    final TextView songInfo = convertView.findViewById(R.id.text);
    final ImageView albumArt = convertView.findViewById(R.id.image);
    final View shortSeparator = convertView.findViewById(R.id.short_separator);

    if (position == getCount() - 1) {
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.GONE);
        }
    } else {
        if (shortSeparator != null) {
            shortSeparator.setVisibility(View.VISIBLE);
        }
    }

    songTitle.setText(song.title);
    songInfo.setText(song.albumName);

    SongGlideRequest.Builder.from(Glide.with(activity), song)
            .checkIgnoreMediaStore(activity).build()
            .into(albumArt);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        albumArt.setTransitionName(activity.getString(R.string.transition_album_art));
    }

    final ImageView overflowButton = convertView.findViewById(R.id.menu);
    overflowButton.setOnClickListener(new SongMenuHelper.OnClickSongMenu(activity) {
        @Override
        public Song getSong() {
            return song;
        }

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.action_go_to_album) {
                Pair[] albumPairs = new Pair[]{
                        Pair.create(albumArt, activity.getResources().getString(R.string.transition_album_art))
                };
                NavigationUtil.goToAlbum(activity, song.albumId, albumPairs);
                return true;
            }
            return super.onMenuItemClick(item);
        }
    });

    convertView.setActivated(isChecked(song));
    convertView.setOnClickListener(view -> {
        if (isInQuickSelectMode()) {
            toggleChecked(song);
        } else {
            MusicPlayerRemote.openQueue(dataSet, position, true);
        }
    });
    convertView.setOnLongClickListener(view -> {
        toggleChecked(song);
        return true;
    });

    return convertView;
}