com.bumptech.glide.request.target.BitmapImageViewTarget Java Examples
The following examples show how to use
com.bumptech.glide.request.target.BitmapImageViewTarget.
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: GirlAdapter.java From GankGirl with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void onBindViewHolder(ViewHolder holder, int position) { GankBean gankBean = mData.get(position); BitmapRequestBuilder<String, Bitmap> requestBuilder = Glide.with(mContext) .load(gankBean.url) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.SOURCE) .transform(new GlideRoundTransform(mContext, 4)) .animate(R.anim.image_alpha_in) .error(R.color.accent); requestBuilder.into(new BitmapImageViewTarget(holder.ivGirlImg){ @Override protected void setResource(Bitmap resource) { holder.ivGirlImg.setOriginalSize(resource.getWidth(), resource.getHeight()); holder.ivGirlImg.setImageBitmap(resource); } }); }
Example #2
Source File: MoviesListingAdapter.java From MovieGuide with MIT License | 6 votes |
@Override public void onBindViewHolder(final ViewHolder holder, int position) { holder.itemView.setOnClickListener(holder); holder.movie = movies.get(position); holder.name.setText(holder.movie.getTitle()); RequestOptions options = new RequestOptions() .centerCrop() .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) .priority(Priority.HIGH); Glide.with(context) .asBitmap() .load(Api.getPosterPath(holder.movie.getPosterPath())) .apply(options) .into(new BitmapImageViewTarget(holder.poster) { @Override public void onResourceReady(Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) { super.onResourceReady(bitmap, transition); Palette.from(bitmap).generate(palette -> setBackgroundColor(palette, holder)); } }); }
Example #3
Source File: ArticleListFragment.java From android-design-template with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup container) { if (convertView == null) { convertView = LayoutInflater.from(getActivity()).inflate(R.layout.list_item_article, container, false); } final DummyContent.DummyItem item = (DummyContent.DummyItem) getItem(position); ((TextView) convertView.findViewById(R.id.article_title)).setText(item.title); ((TextView) convertView.findViewById(R.id.article_subtitle)).setText(item.author); final ImageView img = (ImageView) convertView.findViewById(R.id.thumbnail); Glide.with(getActivity()).load(item.photoId).asBitmap().fitCenter().into(new BitmapImageViewTarget(img) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); img.setImageDrawable(circularBitmapDrawable); } }); return convertView; }
Example #4
Source File: MainListAdapter.java From GankDaily with GNU General Public License v3.0 | 6 votes |
@Override void bindItem(Context context, final Gank gank, final int position) { mTvTime.setText(DateUtil.toDate(gank.publishedAt)); Glide.with(context) .load(gank.url) .asBitmap() .into(new BitmapImageViewTarget(mImageView){ @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); mBkTime.setVisibility(View.VISIBLE); } }); mTvTime.setText(DateUtil.toDate(gank.publishedAt)); mImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mIClickItem.onClickGankItemGirl(gank, mImageView, mTvTime); } }); }
Example #5
Source File: BookReviewsAdapter.java From MaterialHome with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof BookCommentHolder) { List<BookReviewResponse> reviews = reviewsListResponse.getReviews(); Glide.with(UIUtils.getContext()) .load(reviews.get(position).getAuthor().getAvatar()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable); } }); ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getName()); if (reviews.get(position).getRating() != null) { ((BookCommentHolder) holder).ratingBar_hots.setRating(Float.valueOf(reviews.get(position).getRating().getValue())); } ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getSummary()); ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getVotes() + ""); ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split(" ")[0]); } }
Example #6
Source File: EBookReviewsAdapter.java From MaterialHome with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof BookCommentHolder) { List<HotReview.Reviews> reviews = mHotView.getReviews(); Glide.with(UIUtils.getContext()) .load(EBookUtils.getImageUrl(reviews.get(position).getAuthor().getAvatar())) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(UIUtils.getContext().getResources(), resource); circularBitmapDrawable.setCircular(true); ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable); } }); ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getNickname()); ((BookCommentHolder) holder).ratingBar_hots.setRating((float) reviews.get(position).getRating()); ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getContent()); ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getLikeCount() + ""); ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split("T")[0]); } }
Example #7
Source File: GitHubUserActivity.java From gank.io-unofficial-android-client with Apache License 2.0 | 6 votes |
private void setUserInfo() { Glide.with(this) .load(mUserInfo.avatarUrl) .asBitmap() .placeholder(R.drawable.ic_slide_menu_avatar_no_login) .into(new BitmapImageViewTarget(mUserInfoAvatar) { @Override protected void setResource(Bitmap resource) { mUserInfoAvatar.setImageDrawable(RoundedBitmapDrawableFactory .create(GitHubUserActivity.this.getResources(), resource)); } }); mUsername.setText(mUserInfo.name); }
Example #8
Source File: ImageUtil.java From YCAudioPlayer with Apache License 2.0 | 6 votes |
/** * 加载带有圆角的矩形图片 用glide处理 * * @param path 路径 * @param round 圆角半径 * @param resId 加载失败时的图片 * @param target 控件 */ public static void loadImgByPicassoWithRound(final Context activity, String path, final int round, int resId, final ImageView target) { if (path != null && path.length() > 0) { Glide.with(activity) .load(path) .asBitmap() .placeholder(resId) .error(resId) //设置缓存 .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new BitmapImageViewTarget(target) { @Override protected void setResource(Bitmap resource) { super.setResource(resource); RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), resource); //设置圆角弧度 circularBitmapDrawable.setCornerRadius(round); target.setImageDrawable(circularBitmapDrawable); } }); } }
Example #9
Source File: ImageUtils.java From SendBird-Android with MIT License | 6 votes |
/** * Crops image into a circle that fits within the ImageView. */ public static void displayRoundImageFromUrl(final Context context, final String url, final ImageView imageView) { RequestOptions myOptions = new RequestOptions() .centerCrop() .dontAnimate(); Glide.with(context) .asBitmap() .apply(myOptions) .load(url) .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
Example #10
Source File: ImageUtils.java From SendBird-Android with MIT License | 6 votes |
/** * Crops image into a circle that fits within the ImageView. */ public static void displayRoundImageFromUrl(final Context context, final String url, final ImageView imageView) { RequestOptions myOptions = new RequestOptions() .centerCrop() .dontAnimate(); Glide.with(context) .asBitmap() .apply(myOptions) .load(url) .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
Example #11
Source File: BookReviewsAdapter.java From youqu_master with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) { if (holder instanceof BookCommentHolder) { List<BookReviewBean> reviews = reviewsListResponse.getReviews(); Glide.with(BaseApplication.getAppContext()) .load(reviews.get(position).getAuthor().getAvatar()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(((BookCommentHolder) holder).iv_avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(BaseApplication.getAppContext().getResources(), resource); circularBitmapDrawable.setCircular(true); ((BookCommentHolder) holder).iv_avatar.setImageDrawable(circularBitmapDrawable); } }); ((BookCommentHolder) holder).tv_user_name.setText(reviews.get(position).getAuthor().getName()); if (reviews.get(position).getRating() != null) { ((BookCommentHolder) holder).ratingBar_hots.setRating(Float.valueOf(reviews.get(position).getRating().getValue())); } ((BookCommentHolder) holder).tv_comment_content.setText(reviews.get(position).getSummary()); ((BookCommentHolder) holder).tv_favorite_num.setText(reviews.get(position).getVotes() + ""); ((BookCommentHolder) holder).tv_update_time.setText(reviews.get(position).getUpdated().split(" ")[0]); } }
Example #12
Source File: GlideEngine.java From react-native-syan-image-picker with MIT License | 6 votes |
/** * 加载相册目录 * * @param context 上下文 * @param url 图片路径 * @param imageView 承载图片ImageView */ @Override public void loadFolderImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { Glide.with(context) .asBitmap() .load(url) .override(180, 180) .centerCrop() .sizeMultiplier(0.5f) .apply(new RequestOptions().placeholder(R.drawable.picture_image_placeholder)) .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory. create(context.getResources(), resource); circularBitmapDrawable.setCornerRadius(8); imageView.setImageDrawable(circularBitmapDrawable); } }); }
Example #13
Source File: ImageUtil.java From YCVideoPlayer with Apache License 2.0 | 6 votes |
/** * 加载带有圆角的矩形图片 用glide处理 * * @param path 路径 * @param round 圆角半径 * @param resId 加载失败时的图片 * @param target 控件 */ public static void loadImgByPicassoWithRound(final Context activity, String path, final int round, int resId, final ImageView target) { if (path != null && path.length() > 0) { Glide.with(activity) .asBitmap() .load(path) .placeholder(resId) .error(resId) //设置缓存 .diskCacheStrategy(DiskCacheStrategy.ALL) .into(new BitmapImageViewTarget(target) { @Override protected void setResource(Bitmap resource) { super.setResource(resource); RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(activity.getResources(), resource); //设置圆角弧度 circularBitmapDrawable.setCornerRadius(round); target.setImageDrawable(circularBitmapDrawable); } }); } }
Example #14
Source File: GlideEngine.java From PictureSelector with Apache License 2.0 | 6 votes |
/** * 加载相册目录 * * @param context 上下文 * @param url 图片路径 * @param imageView 承载图片ImageView */ @Override public void loadFolderImage(@NonNull Context context, @NonNull String url, @NonNull ImageView imageView) { Glide.with(context) .asBitmap() .load(url) .override(180, 180) .centerCrop() .sizeMultiplier(0.5f) .apply(new RequestOptions().placeholder(R.drawable.picture_image_placeholder)) .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory. create(context.getResources(), resource); circularBitmapDrawable.setCornerRadius(8); imageView.setImageDrawable(circularBitmapDrawable); } }); }
Example #15
Source File: MainActivity.java From AlbumSelector with Apache License 2.0 | 5 votes |
/** * 得到选择的图片路径集合 */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ImageSelector.REQUEST_SELECT_IMAGE) { if (resultCode == RESULT_OK) { ArrayList<String> imagesPath = data.getStringArrayListExtra(ImageSelector.SELECTED_RESULT); if (isAvatorModel && imagesPath != null) { mRlAvator.setVisibility(View.VISIBLE); Glide.with(this) .load(imagesPath.get(0)) .asBitmap() .into(new BitmapImageViewTarget(mIvAvator) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource); circularBitmapDrawable.setCircular(true); mIvAvator.setImageDrawable(circularBitmapDrawable); } }); } else if (imagesPath != null) { mRlAvator.setVisibility(View.GONE); mAdapter.refreshData(imagesPath); } } } }
Example #16
Source File: LeaderBoardAdapter.java From Hillffair17 with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(LeaderBoardViewHolder holder, int position) { LeaderBoardActivity.LeaderBoardUserModel user=users.get(position); holder.username.setText(user.getName().toString()); holder.score.setText("Score: "+Integer.toString(user.getSets().getScore())); Glide.with(context).load(user.getPhoto()).into(holder.photo); final ImageView imageView=holder.photo; Glide.with(context).load(user.getPhoto()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); Integer prsnlscore = user.getSets().getScore(); if(prsnlscore>=800) holder.useraward.setImageResource(R.drawable.trophy_gold); else if(prsnlscore>=600) holder.useraward.setImageResource(R.drawable.trophy_silver); else if(prsnlscore>=450) holder.useraward.setImageResource(R.drawable.trophy_bronze); else if(prsnlscore>=300) holder.useraward.setImageResource(R.drawable.trophy_goldbadge); else if(prsnlscore>=150) holder.useraward.setImageResource(R.drawable.trophy_silverbadge); else if(prsnlscore>0) holder.useraward.setImageResource(R.drawable.trophy_bronzebadge); else if(prsnlscore==0) holder.useraward.setImageResource(R.drawable.trophy_participation); holder.sets.setText("Sets: "+Integer.toString(user.getSets().getSets())); }
Example #17
Source File: ChiefEditorAdapter.java From RxZhihuDaily with MIT License | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.chief_editor_item, parent, false); holder = new ViewHolder(convertView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final ViewHolder Hohholder = holder; if (Hohholder != null) { Glide .with(context) .load(editors.get(position).getAvatar()) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(Hohholder.imgChiefEditorItem) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); Hohholder.imgChiefEditorItem.setImageDrawable(circularBitmapDrawable); } }); } return convertView; }
Example #18
Source File: TrackListData.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
@Override public void bindView(final ViewHolder holder) { holder.name.setText(trackName); if (artists.size() > 0) holder.extra.setText(artists.get(0).artistName); else holder.extra.setText(""); if (!PreferenceUtils.isThumbnails(holder.activity)) holder.image.setVisibility(View.GONE); else { Glide.with(holder.activity).load(trackImage).asBitmap().placeholder(ImageUtils.getVectorDrawable(holder.activity, R.drawable.preload)).thumbnail(0.2f).into(new BitmapImageViewTarget(holder.image) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); if (holder.bg == null) return; Palette.from(resource).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { ValueAnimator animator = ValueAnimator.ofObject(new ArgbEvaluator(), Color.DKGRAY, palette.getDarkVibrantColor(Color.DKGRAY)); animator.setDuration(250); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); holder.bg.setBackgroundColor(color); } }); animator.start(); } }); } }); } }
Example #19
Source File: PlaylistListData.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
@Override public void bindView(final ViewHolder holder) { holder.name.setText(playlistName); holder.extra.setText(String.format("%d %s", tracks, tracks == 1 ? "track" : "tracks")); if (!PreferenceUtils.isThumbnails(holder.activity)) holder.image.setVisibility(View.GONE); else { Glide.with(holder.activity).load(playlistImage).asBitmap().placeholder(ImageUtils.getVectorDrawable(holder.activity, R.drawable.preload)).thumbnail(0.2f).into(new BitmapImageViewTarget(holder.image) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); if (holder.bg == null) return; Palette.from(resource).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { ValueAnimator animator = ValueAnimator.ofObject(new ArgbEvaluator(), Color.DKGRAY, palette.getDarkVibrantColor(Color.DKGRAY)); animator.setDuration(250); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); holder.bg.setBackgroundColor(color); } }); animator.start(); } }); } }); } }
Example #20
Source File: ArtistListData.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
@Override public void bindView(final ViewHolder holder) { holder.name.setText(artistName); holder.extra.setText(String.valueOf(followers) + " followers"); if (!PreferenceUtils.isThumbnails(holder.activity)) holder.image.setVisibility(View.GONE); else { Glide.with(holder.activity).load(artistImage).asBitmap().placeholder(ImageUtils.getVectorDrawable(holder.activity, R.drawable.preload)).thumbnail(0.2f).into(new BitmapImageViewTarget(holder.image) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); if (holder.bg == null) return; Palette.from(resource).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { ValueAnimator animator = ValueAnimator.ofObject(new ArgbEvaluator(), Color.DKGRAY, palette.getDarkVibrantColor(Color.DKGRAY)); animator.setDuration(250); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); holder.bg.setBackgroundColor(color); } }); animator.start(); } }); } }); } }
Example #21
Source File: ImageUtil.java From TouchNews with Apache License 2.0 | 5 votes |
public static void displayCircularImage(final Context context, String url, final ImageView imageView) { Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); }
Example #22
Source File: LeaderBoardAdapter.java From Nimbus with GNU General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(LeaderBoardViewHolder holder, int position) { LeaderBoardActivity.LeaderBoardUserModel user=users.get(position); holder.username.setText(user.getName().toString()); holder.score.setText("Score: "+Integer.toString(user.getSets().getScore())); Glide.with(context).load(user.getPhoto()).into(holder.photo); final ImageView imageView=holder.photo; Glide.with(context).load(user.getPhoto()).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); Integer prsnlscore = user.getSets().getScore(); if(prsnlscore>=800) holder.useraward.setImageResource(R.drawable.trophy_gold); else if(prsnlscore>=600) holder.useraward.setImageResource(R.drawable.trophy_silver); else if(prsnlscore>=450) holder.useraward.setImageResource(R.drawable.trophy_bronze); else if(prsnlscore>=300) holder.useraward.setImageResource(R.drawable.trophy_goldbadge); else if(prsnlscore>=150) holder.useraward.setImageResource(R.drawable.trophy_silverbadge); else if(prsnlscore>0) holder.useraward.setImageResource(R.drawable.trophy_bronzebadge); else if(prsnlscore==0) holder.useraward.setImageResource(R.drawable.trophy_participation); holder.sets.setText("Sets: "+Integer.toString(user.getSets().getSets())); }
Example #23
Source File: MainActivity.java From gank.io-unofficial-android-client with Apache License 2.0 | 5 votes |
public void setUserInfo() { GitHubUserInfo mUserInfo = (GitHubUserInfo) ACache.get(MainActivity.this) .getAsObject(ConstantUtil.CACHE_USER_KEY); if (mUserInfo != null) { isLogin = true; Glide.with(MainActivity.this) .load(mUserInfo.avatarUrl) .asBitmap() .placeholder(R.drawable.ic_slide_menu_avatar_no_login) .into(new BitmapImageViewTarget(mUserAvatar) { @Override protected void setResource(Bitmap resource) { mUserAvatar.setImageDrawable(RoundedBitmapDrawableFactory.create (MainActivity.this.getResources(), resource)); } }); mUserName.setText(mUserInfo.name); mUserBio.setText(mUserInfo.bio); } else { isLogin = false; } }
Example #24
Source File: ApkPresenter.java From TvAppRepo with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item) { Apk application = (Apk) item; final ImageCardView cardView = (ImageCardView) viewHolder.view; Log.d(TAG, "onBindViewHolder"); if (application.getBanner() != null) { cardView.setTitleText(application.getName()); cardView.setContentText(mContext.getString(R.string.version_number, application.getVersionName())); cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT); Glide.with(viewHolder.view.getContext()) .load(!application.getBanner().isEmpty() ? application.getBanner() : application.getIcon()) .asBitmap() .into(new BitmapImageViewTarget(cardView.getMainImageView()) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); Palette.generateAsync(resource, new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { // Here's your generated palette if (palette.getDarkVibrantSwatch() != null) { cardView.findViewById(R.id.info_field).setBackgroundColor( palette.getDarkVibrantSwatch().getRgb()); } } }); } }); } }
Example #25
Source File: AlbumListData.java From Pasta-for-Spotify with Apache License 2.0 | 4 votes |
@Override public void bindView(final ViewHolder holder) { if (holder.artist != null) { if (artists.size() > 0) { holder.artistName.setText(artists.get(0).artistName); holder.artistExtra.setText(albumDate); new Action<ArtistListData>() { @NonNull @Override public String id() { return "gotoArtist"; } @Nullable @Override protected ArtistListData run() throws InterruptedException { return holder.pasta.getArtist(artists.get(0).artistId); } @Override protected void done(@Nullable ArtistListData result) { if (result == null) { holder.pasta.onError(holder.activity, "artist action"); return; } holder.artist.setTag(result); } }.execute(); } else holder.artist.setVisibility(View.GONE); } holder.name.setText(albumName); holder.extra.setText(String.valueOf(tracks) + " track" + (tracks == 1 ? "" : "s")); if (!PreferenceUtils.isThumbnails(holder.pasta)) holder.image.setVisibility(View.GONE); else { Glide.with(holder.pasta).load(albumImage).asBitmap().placeholder(ImageUtils.getVectorDrawable(holder.pasta, R.drawable.preload)).into(new BitmapImageViewTarget(holder.image) { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { super.onResourceReady(resource, glideAnimation); if (holder.bg == null) return; Palette.from(resource).generate(new Palette.PaletteAsyncListener() { @Override public void onGenerated(Palette palette) { ValueAnimator animator = ValueAnimator.ofObject(new ArgbEvaluator(), Color.DKGRAY, palette.getDarkVibrantColor(Color.DKGRAY)); animator.setDuration(250); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int color = (int) animation.getAnimatedValue(); holder.bg.setBackgroundColor(color); holder.artist.setBackgroundColor(Color.argb(255, Math.max(Color.red(color) - 10, 0), Math.max(Color.green(color) - 10, 0), Math.max(Color.blue(color) - 10, 0))); } }); animator.start(); } }); } }); } }
Example #26
Source File: RepCallActivity.java From android with MIT License | 4 votes |
private void setupContactUi(int index, boolean expandLocalSection) { final Contact contact = mIssue.contacts.get(index); contactName.setText(contact.name); // Set the reason for contacting this rep, using default text if no reason is provided. final String contactReasonText = TextUtils.isEmpty(contact.reason) ? getResources().getString(R.string.contact_reason_default) : contact.reason; contactReason.setText(contactReasonText); if (!TextUtils.isEmpty(contact.photoURL)) { repImage.setVisibility(View.VISIBLE); Glide.with(getApplicationContext()) .load(contact.photoURL) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(repImage) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create( repImage.getContext().getResources(), resource); drawable.setCircular(true); drawable.setGravity(Gravity.TOP); repImage.setImageDrawable(drawable); } }); } else { repImage.setVisibility(View.GONE); } phoneNumber.setText(contact.phone); Linkify.addLinks(phoneNumber, Linkify.PHONE_NUMBERS); if (expandLocalSection) { localOfficeButton.setVisibility(View.INVISIBLE); expandLocalOfficeSection(contact); } else { localOfficeSection.setVisibility(View.GONE); localOfficeSection.removeViews(1, localOfficeSection.getChildCount() - 1); if (contact.field_offices == null || contact.field_offices.length == 0) { localOfficeButton.setVisibility(View.GONE); } else { localOfficeButton.setVisibility(View.VISIBLE); localOfficeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { localOfficeButton.setOnClickListener(null); expandLocalOfficeSection(contact); } }); } } // Show a bit about whether they've been contacted yet final List<String> previousCalls = AppSingleton.getInstance(this).getDatabaseHelper() .getCallResults(mIssue.id, contact.id); if (previousCalls.size() > 0) { showContactChecked(previousCalls); } else { contactChecked.setVisibility(View.GONE); contactChecked.setOnClickListener(null); } }
Example #27
Source File: TestFragment.java From glide-support with The Unlicense | 4 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); listView.setAdapter(new SimpleUrlAdapter(Glide.with(this), Arrays.asList( "https://s.yimg.com/pe/vguide/netflix.png", "https://s.yimg.com/pe/vguide/hulu.png", "https://s.yimg.com/pe/vguide/amazon.png", "https://s.yimg.com/pe/vguide/hbo.png", "https://s.yimg.com/pe/vguide/showtime.png", "https://s.yimg.com/pe/vguide/youtube.png", "https://s.yimg.com/pe/vguide/fox.png", "https://s.yimg.com/pe/vguide/cbs.png", "https://s.yimg.com/pe/vguide/nbc.png", "https://s.yimg.com/pe/vguide/abc.png", "https://s.yimg.com/pe/vguide/tbs.png", "https://s.yimg.com/pe/vguide/the-cw.png", "https://s.yimg.com/pe/vguide/crackle.png", "https://s.yimg.com/pe/vguide/a-e.png", "https://s.yimg.com/pe/vguide/abc-family.png", "https://s.yimg.com/pe/vguide/amc.png", "https://s.yimg.com/pe/vguide/cartoon-network.png", "https://s.yimg.com/pe/vguide/adult-swim.png", "https://s.yimg.com/pe/vguide/comedy-central.png", "https://s.yimg.com/pe/vguide/disney.png", "https://s.yimg.com/pe/vguide/lifetime.png", "https://s.yimg.com/pe/vguide/mtv.png", "https://s.yimg.com/pe/vguide/nick-com.png", "https://s.yimg.com/pe/vguide/pbs.png", "https://s.yimg.com/pe/vguide/bravo.png", "https://s.yimg.com/pe/vguide/fx.png", "https://s.yimg.com/pe/vguide/history.png", "https://s.yimg.com/pe/vguide/tnt.png", "https://s.yimg.com/pe/vguide/usa-network.png", "https://s.yimg.com/pe/vguide/vh-1.png", "https://s.yimg.com/pe/vguide/spike.png", "https://s.yimg.com/pe/vguide/bet.png", "https://s.yimg.com/pe/vguide/we-tv.png", "https://s.yimg.com/pe/vguide/food-network.png", "https://s.yimg.com/pe/vguide/epix.png", "https://s.yimg.com/pe/vguide/cinemax.png", "https://s.yimg.com/pe/vguide/xfinity.png" )) { @Override protected View onCreateView(LayoutInflater inflater, ViewGroup parent, int viewType) { return inflater.inflate(R.layout.github_601_item, parent, false); } int tempPosition = -1; @Override public void onBindViewHolder( SimpleViewHolder holder, @SuppressLint("RecyclerView") int position) { tempPosition = position; super.onBindViewHolder(holder, position); } @Override protected void load(Context context, RequestManager glide, String url, ImageView imageView) throws Exception { final String row = "pos" + tempPosition; glide .load(url) .asBitmap() .fitCenter() .listener(new LoggingListener<String, Bitmap>(Log.DEBUG, row)) .into(new LoggingTarget<>(row, Log.VERBOSE, new BitmapImageViewTarget(imageView))) ; } }); }
Example #28
Source File: ImageChunkAdapter.java From glide-support with The Unlicense | 4 votes |
@Override public void onBindViewHolder(ImageChunkViewHolder holder, int position) { int left = 0, top = imageChunkHeight * position; int width = image.x, height = imageChunkHeight; if (position == getItemCount() - 1 && image.y % imageChunkHeight != 0) { height = image.y % imageChunkHeight; // height of last partial row, if any } Rect rect = new Rect(left, top, left + width, top + height); float viewWidth = width * ratio; float viewHeight = height * ratio; final String bind = String.format(Locale.ROOT, "Binding %s w=%d (%d->%f) h=%d (%d->%f)", rect.toShortString(), rect.width(), width, viewWidth, rect.height(), height, viewHeight); Context context = holder.itemView.getContext(); // See https://docs.google.com/drawings/d/1KyOJkNd5Dlm8_awZpftzW7KtqgNR6GURvuF6RfB210g/edit?usp=sharing Glide .with(context) .load(url) .asBitmap() .placeholder(new ColorDrawable(Color.BLUE)) .error(new ColorDrawable(Color.RED)) // overshoot a little so fitCenter uses width's ratio (see minPercentage) .override(Math.round(viewWidth), (int)Math.ceil(viewHeight)) .fitCenter() // Cannot use .imageDecoder, only decoder; see bumptech/glide#708 //.imageDecoder(new RegionStreamDecoder(context, rect)) .decoder(new RegionImageVideoDecoder(context, rect)) .cacheDecoder(new RegionFileDecoder(context, rect)) // Cannot use RESULT cache; see bumptech/glide#707 .diskCacheStrategy(DiskCacheStrategy.SOURCE) .listener(new LoggingListener<String, Bitmap>(bind)) .into(new BitmapImageViewTarget(holder.imageView) { @Override protected void setResource(Bitmap resource) { if (resource != null) { LayoutParams params = view.getLayoutParams(); if (params.height != resource.getHeight()) { params.height = resource.getHeight(); } view.setLayoutParams(params); } super.setResource(resource); } }) ; }
Example #29
Source File: IssueActivity.java From android with MIT License | 4 votes |
private void populateRepView(View repView, Contact contact, final int index, List<String> previousCalls) { TextView contactName = repView.findViewById(R.id.contact_name); final ImageView repImage = repView.findViewById(R.id.rep_image); ImageView contactChecked = repView.findViewById(R.id.contact_done_img); TextView contactReason = repView.findViewById(R.id.contact_reason); TextView contactWarning = repView.findViewById(R.id.contact_warning); contactName.setText(contact.name); contactWarning.setVisibility(View.GONE); if (!TextUtils.isEmpty(contact.area)) { contactReason.setText(contact.area); if (TextUtils.equals(contact.area, "US House") && mIssue.isSplit) { contactWarning.setVisibility(View.VISIBLE); contactWarning.setText(R.string.split_district_warning); } contactReason.setVisibility(View.VISIBLE); } else { contactReason.setVisibility(View.GONE); } if (!TextUtils.isEmpty(contact.photoURL)) { repImage.setVisibility(View.VISIBLE); Glide.with(getApplicationContext()) .load(contact.photoURL) .asBitmap() .centerCrop() .into(new BitmapImageViewTarget(repImage) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create( repImage.getContext().getResources(), resource); drawable.setCircular(true); drawable.setGravity(Gravity.TOP); repImage.setImageDrawable(drawable); } }); } else { repImage.setVisibility(View.GONE); } // Show a bit about whether they've been contacted yet if (previousCalls.size() > 0) { contactChecked.setImageLevel(1); contactChecked.setContentDescription(getResources().getString( R.string.contact_done_img_description)); } else { contactChecked.setImageLevel(0); contactChecked.setContentDescription(null); } repView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplicationContext(), RepCallActivity.class); intent.putExtra(KEY_ISSUE, mIssue); intent.putExtra(RepCallActivity.KEY_ADDRESS, getIntent().getStringExtra(RepCallActivity.KEY_ADDRESS)); intent.putExtra(RepCallActivity.KEY_ACTIVE_CONTACT_INDEX, index); startActivity(intent); } }); }
Example #30
Source File: PeopleRecyclerAdapter.java From mage-android with Apache License 2.0 | 4 votes |
@Override public void onBindViewHolder(final PersonViewHolder viewHolder, int i) { final User user = people.get(i); viewHolder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (personClickListener != null) { personClickListener.onPersonClick(user); } } }); UserLocal userLocal = user.getUserLocal(); GlideApp.with(context) .asBitmap() .load(Avatar.Companion.forUser(user)) .fallback(R.drawable.ic_person_gray_24dp) .centerCrop() .into(new BitmapImageViewTarget(viewHolder.avatar) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(context.getResources(), resource); circularBitmapDrawable.setCircular(true); viewHolder.avatar.setImageDrawable(circularBitmapDrawable); } }); GlideApp.with(context) .load(userLocal.getLocalIconPath()) .centerCrop() .into(viewHolder.icon); viewHolder.name.setText(user.getDisplayName()); Collection<Team> userTeams = teamHelper.getTeamsByUser(user); userTeams.retainAll(eventTeams); Collection<String> teamNames = Collections2.transform(userTeams, new Function<Team, String>() { @Override public String apply(Team team) { return team.getName(); } }); viewHolder.teams.setText(StringUtils.join(teamNames, ", ")); View.OnClickListener clickListener = new View.OnClickListener() { @Override public void onClick(View view) { if (personClickListener != null) { PersonViewHolder holder = (PersonViewHolder) view.getTag(); int position = holder.getLayoutPosition(); personClickListener.onPersonClick(people.get(position)); } } }; }