jp.wasabeef.glide.transformations.RoundedCornersTransformation Java Examples
The following examples show how to use
jp.wasabeef.glide.transformations.RoundedCornersTransformation.
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: UiUtil.java From Ticket-Analysis with MIT License | 6 votes |
public static void setRoundImage(boolean isSkipMemoryCache, ImageView imageView, String imageUrl, int loadingRes, int errorRes, int radius) { if (imageView == null) return; Context context = imageView.getContext(); if (context instanceof Activity) { if (((Activity) context).isFinishing()) { return; } } try { Glide.with(context).load(imageUrl) .placeholder(loadingRes) .crossFade() .diskCacheStrategy(DiskCacheStrategy.ALL) .error(errorRes) .fitCenter() .skipMemoryCache(isSkipMemoryCache) .bitmapTransform(new RoundedCornersTransformation(context, radius, 0, RoundedCornersTransformation.CornerType.ALL)) .into(imageView); } catch (Exception e) { } }
Example #2
Source File: SongAdapter.java From Musicoco with Apache License 2.0 | 5 votes |
private void loadDataAndView(DataHolder dataHolder, ViewHolder holder, int position) { SongInfo info = dataHolder.info; // any mode same final RoundedCornersTransformation rtf = new RoundedCornersTransformation(activity, 15, 0); ImageView image = holder.image; Glide.with(activity.getApplicationContext()) // 要使用 Context,Activity touch DOWN 或正在滚动时不会加载图片 .load(info.getAlbum_path()) .diskCacheStrategy(DiskCacheStrategy.RESULT) .placeholder(R.drawable.default_song) .bitmapTransform(rtf) .crossFade() .into(image); holder.name.setText(info.getTitle()); holder.arts.setText(info.getArtist()); holder.duration.setText(StringUtils.getGenTimeMS((int) info.getDuration())); // multiselection mode holder.check.setChecked(listMode == ListMode.MULTISELECTION && checksIndex.contains(position)); // sort mode if (listMode == ListMode.SORT) { holder.itemView.setBackgroundColor(mainBC); } holder.number.setText(listMode == ListMode.SORT ? "" : String.valueOf(position + 1)); holder.more.setImageDrawable(activity.getDrawable(listMode == ListMode.SORT ? R.drawable.ic_play_list : R.drawable.ic_more_vert_black_24dp)); bindStatAndColors(holder, position, dataHolder.isFavorite); }
Example #3
Source File: TinderCard.java From Tutorials with Apache License 2.0 | 5 votes |
@Resolve private void onResolved(){ MultiTransformation multi = new MultiTransformation( new BlurTransformation(mContext, 30), new RoundedCornersTransformation( mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)); Glide.with(mContext).load(mProfile.getImageUrl()) .bitmapTransform(multi) .into(profileImageView); nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge()); locationNameTxt.setText(mProfile.getLocation()); }
Example #4
Source File: TinderCard.java From Tutorials with Apache License 2.0 | 5 votes |
@Resolve public void onResolved() { Glide.with(mContext).load(mProfile.getImageUrl()) .bitmapTransform(new RoundedCornersTransformation(mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)) .into(profileImageView); nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge()); locationNameTxt.setText(mProfile.getLocation()); mSwipeView.setAlpha(1); }
Example #5
Source File: TinderCard.java From Tutorials with Apache License 2.0 | 5 votes |
@Resolve private void onResolved() { Glide.with(mContext).load(mProfile.getImageUrl()) .bitmapTransform(new RoundedCornersTransformation(mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)) .into(profileImageView); nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge()); locationNameTxt.setText(mProfile.getLocation()); mSwipeView.setAlpha(1); }
Example #6
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); placeholder = transformDrawable( // has white background because it's not transparent, so rounding will be visible ContextCompat.getDrawable(getContext(), R.drawable.glide_jpeg), // transformation to be applied new RoundedCornersTransformation(getContext(), 100, 0), // size of the target in pixels 256 ); }
Example #7
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
/** * 加载自定义封面带圆角 * * @param context 上下文 * @param imgUrl 图片链接 * @param cornerRadius 圆角弧度 * @param imageView view */ public static void loadCornerPicture(Context context, String imgUrl, int cornerRadius, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(R.drawable.icon_user)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(cornerRadius), 0)))) .into(imageView); }
Example #8
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
public static void loadCornerPicture(Context context, String imgUrl, int cornerRadius, int errorResourceId, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(errorResourceId)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(cornerRadius), 0)))) .into(imageView); }
Example #9
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView, int resourceId) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(resourceId)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0)))) .into(imageView); }
Example #10
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 5 votes |
/** * 加载圆角封面,默认4dp */ public static void loadCornerPicture(Context context, String imgUrl, ImageView imageView) { Glide.with(context) .load(imgUrl) .apply(new RequestOptions().error(R.drawable.icon_user)) .apply(RequestOptions.bitmapTransform(new MultiTransformation<Bitmap>(new CenterCrop(), new RoundedCornersTransformation(ConvertUtils.dp2px(4), 0)))) .into(imageView); }
Example #11
Source File: ImageLoadUtils.java From Tok-Android with GNU General Public License v3.0 | 5 votes |
public static void loadRoundImg(Context context, int imgResId, ImageView imgView) { LogUtil.i(TAG, "loadMask imgResId:"); Glide.with(context) .setDefaultRequestOptions(getPortraitOptions()) .load(imgResId) .apply(RequestOptions.bitmapTransform(new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(ScreenUtils.dp2px(context, 4), 0)))) .thumbnail(THUMB_NAIL) .into(imgView); }
Example #12
Source File: TinderCard.java From Tutorials with Apache License 2.0 | 5 votes |
@SwipeHead private void onSwipeHeadCard() { Glide.with(mContext).load(mProfile.getImageUrl()) .bitmapTransform(new RoundedCornersTransformation( mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)) .into(profileImageView); cardView.invalidate(); }
Example #13
Source File: PostVideoActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
private void displaySubredditIcon() { if (iconUrl != null && !iconUrl.equals("")) { mGlide.load(iconUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconGifImageView); } }
Example #14
Source File: PostLinkActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
private void displaySubredditIcon() { if (iconUrl != null && !iconUrl.equals("")) { mGlide.load(iconUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconGifImageView); } }
Example #15
Source File: PostImageActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
private void displaySubredditIcon() { if (iconUrl != null && !iconUrl.equals("")) { mGlide.load(iconUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconGifImageView); } }
Example #16
Source File: PostTextActivity.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
private void displaySubredditIcon() { if (iconUrl != null && !iconUrl.equals("")) { mGlide.load(iconUrl) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(iconGifImageView); } else { mGlide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconGifImageView); } }
Example #17
Source File: AddViewCard.java From Tutorials with Apache License 2.0 | 5 votes |
@Resolve private void onResolved() { Glide.with(mContext).load(mImageUrl) .bitmapTransform(new RoundedCornersTransformation(mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)) .into(addImageView); }
Example #18
Source File: SubredditMultiselectionRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof SubscribedSubredditViewHolder) { ((SubscribedSubredditViewHolder) holder).nameTextView.setText(subscribedSubreddits.get(position).getName()); glide.load(subscribedSubreddits.get(position).getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(((SubscribedSubredditViewHolder) holder).iconImageView); if (subscribedSubreddits.get(position).isSelected()) { ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(true); } else { ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(false); } ((SubscribedSubredditViewHolder) holder).checkBox.setOnClickListener(view -> { if (subscribedSubreddits.get(position).isSelected()) { ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(false); subscribedSubreddits.get(position).setSelected(false); } else { ((SubscribedSubredditViewHolder) holder).checkBox.setChecked(true); subscribedSubreddits.get(position).setSelected(true); } }); ((SubscribedSubredditViewHolder) holder).itemView.setOnClickListener(view -> ((SubscribedSubredditViewHolder) holder).checkBox.performClick()); } }
Example #19
Source File: TinderCard.java From Tutorials with Apache License 2.0 | 5 votes |
@Resolve private void onResolved() { Glide.with(mContext).load(mProfile.getImageUrl()) .bitmapTransform(new RoundedCornersTransformation(mContext, Utils.dpToPx(7), 0, RoundedCornersTransformation.CornerType.TOP)) .into(profileImageView); nameAgeTxt.setText(mProfile.getName() + ", " + mProfile.getAge()); locationNameTxt.setText(mProfile.getLocation()); }
Example #20
Source File: Glide4Loader.java From ImageLoader with Apache License 2.0 | 4 votes |
private Transformation[] getBitmapTransFormations(SingleConfig config) { Transformation[] forms = null; int shapeMode = config.getShapeMode(); List<Transformation> transformations = new ArrayList<>(); if(config.isCropFace()){ // transformations.add(new FaceCenterCrop());//脸部识别 } if(config.getScaleMode() == ScaleMode.CENTER_CROP){ transformations.add(new CenterCrop()); }else{ transformations.add(new FitCenter()); } if(config.isNeedBlur()){ transformations.add(new BlurTransformation( config.getBlurRadius())); } switch (shapeMode){ case ShapeMode.RECT: if(config.getBorderWidth()>0){ } break; case ShapeMode.RECT_ROUND: case ShapeMode.RECT_ROUND_ONLY_TOP: RoundedCornersTransformation.CornerType cornerType = RoundedCornersTransformation.CornerType.ALL; if(shapeMode == ShapeMode.RECT_ROUND_ONLY_TOP){ cornerType = RoundedCornersTransformation.CornerType.TOP; } /*transformations.add(new BorderRoundTransformation2(config.getContext(), config.getRectRoundRadius(), 0,config.getBorderWidth(), config.getContext().getResources().getColor(config.getBorderColor()),0x0b1100));*/ /*if(config.getBorderWidth() > 0 && config.getBorderColor() != 0){ transformations.add(new BorderRoundTransformation(config.getContext(), config.getRectRoundRadius(), 0,config.getBorderWidth(), config.getContext().getResources().getColor(config.getBorderColor()),0x0b1100)); }else {*/ transformations.add(new RoundedCornersTransformation( config.getRectRoundRadius(),config.getBorderWidth(), cornerType)); // } break; case ShapeMode.OVAL: if(config.getBorderWidth() > 0 && config.getBorderColor() != 0){ transformations.add( new CropCircleWithBorderTransformation( config.getBorderWidth(),config.getContext().getResources().getColor(config.getBorderColor()))); }else { transformations.add( new CropCircleTransformation()); } break; default:break; } if(!transformations.isEmpty()){ forms = new Transformation[transformations.size()]; for (int i = 0; i < transformations.size(); i++) { forms[i] = transformations.get(i); } return forms; } return forms; }
Example #21
Source File: RepositoryAdapter.java From UltimateAndroid with Apache License 2.0 | 4 votes |
Transformation<Bitmap> getTransform(int position, Context mContext) { if (position % 19 == 0) { return new CropCircleTransformation(mContext); } else if (position % 19 == 1) { return new RoundedCornersTransformation(mContext, 30, 0, RoundedCornersTransformation.CornerType.BOTTOM); } else if (position % 19 == 2) { return new CropTransformation(mContext, 300, 100, CropTransformation.CropType.BOTTOM); } else if (position % 19 == 3) { return new CropSquareTransformation(mContext); } else if (position % 19 == 4) { return new CropTransformation(mContext, 300, 100, CropTransformation.CropType.CENTER); } else if (position % 19 == 5) { return new ColorFilterTransformation(mContext, Color.argb(80, 255, 0, 0)); } else if (position % 19 == 6) { return new GrayscaleTransformation(mContext); } else if (position % 19 == 7) { return new CropTransformation(mContext, 300, 100); } else if (position % 19 == 8) { return new BlurTransformation(mContext, 25); } else if (position % 19 == 9) { return new ToonFilterTransformation(mContext); } else if (position % 19 == 10) { return new SepiaFilterTransformation(mContext); } else if (position % 19 == 11) { return new ContrastFilterTransformation(mContext, 2.0f); } else if (position % 19 == 12) { return new InvertFilterTransformation(mContext); } else if (position % 19 == 13) { return new PixelationFilterTransformation(mContext, 20); } else if (position % 19 == 14) { return new SketchFilterTransformation(mContext); } else if (position % 19 == 15) { return new SwirlFilterTransformation(mContext, 0.5f, 1.0f, new PointF(0.5f, 0.5f)); } else if (position % 19 == 16) { return new BrightnessFilterTransformation(mContext, 0.5f); } else if (position % 19 == 17) { return new KuwaharaFilterTransformation(mContext, 25); } else if (position % 19 == 18) { return new VignetteFilterTransformation(mContext, new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f); } return null; }
Example #22
Source File: GlideLoader.java From ImageLoader with Apache License 2.0 | 4 votes |
private Transformation[] getBitmapTransFormations(SingleConfig config) { Transformation[] forms = null; int shapeMode = config.getShapeMode(); List<Transformation> transformations = new ArrayList<>(); if(config.isCropFace()){ // transformations.add(new FaceCenterCrop());//脸部识别 } if(config.getScaleMode() == ScaleMode.CENTER_CROP){ transformations.add(new CenterCrop(config.getContext())); }else{ transformations.add(new FitCenter(config.getContext())); } if(config.isNeedBlur()){ transformations.add(new BlurTransformation(config.getContext(), config.getBlurRadius())); } switch (shapeMode){ case ShapeMode.RECT: if(config.getBorderWidth()>0){ } break; case ShapeMode.RECT_ROUND: case ShapeMode.RECT_ROUND_ONLY_TOP: RoundedCornersTransformation.CornerType cornerType = RoundedCornersTransformation.CornerType.ALL; if(shapeMode == ShapeMode.RECT_ROUND_ONLY_TOP){ cornerType = RoundedCornersTransformation.CornerType.TOP; } /*transformations.add(new BorderRoundTransformation2(config.getContext(), config.getRectRoundRadius(), 0,config.getBorderWidth(), config.getContext().getResources().getColor(config.getBorderColor()),0x0b1100));*/ if(config.getBorderWidth() > 0 && config.getBorderColor() != 0){ transformations.add(new BorderRoundTransformation(config.getContext(), config.getRectRoundRadius(), 0,config.getBorderWidth(), config.getContext().getResources().getColor(config.getBorderColor()),0x0b1100)); }else { transformations.add(new RoundedCornersTransformation(config.getContext(), config.getRectRoundRadius(),config.getBorderWidth(), cornerType)); } break; case ShapeMode.OVAL: if(config.getBorderWidth() > 0 && config.getBorderColor() != 0){ transformations.add( new CropCircleWithBorderTransformation(config.getContext(), config.getBorderWidth(),config.getContext().getResources().getColor(config.getBorderColor()))); }else { transformations.add( new CropCircleTransformation(config.getContext())); } break; default:break; } if(!transformations.isEmpty()){ forms = new Transformation[transformations.size()]; for (int i = 0; i < transformations.size(); i++) { forms[i] = transformations.get(i); } return forms; } return forms; }
Example #23
Source File: ThemePreviewPostsFragment.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_theme_preview_posts, container, false); ButterKnife.bind(this, rootView); CustomTheme customTheme = activity.getCustomTheme(); cardView.setBackgroundTintList(ColorStateList.valueOf(customTheme.cardViewBackgroundColor)); Glide.with(this).load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(iconImageView); subredditNameTextView.setTextColor(customTheme.subreddit); usernameTextView.setTextColor(customTheme.username); postTimeTextView.setTextColor(customTheme.secondaryTextColor); titleTextView.setTextColor(customTheme.postTitleColor); contentTextView.setTextColor(customTheme.postContentColor); stickiedPostImageView.setColorFilter(customTheme.stickiedPostIconTint, PorterDuff.Mode.SRC_IN); typeTextView.setBackgroundColor(customTheme.postTypeBackgroundColor); typeTextView.setBorderColor(customTheme.postTypeBackgroundColor); typeTextView.setTextColor(customTheme.postTypeTextColor); spoilerTextView.setBackgroundColor(customTheme.spoilerBackgroundColor); spoilerTextView.setBorderColor(customTheme.spoilerBackgroundColor); spoilerTextView.setTextColor(customTheme.spoilerTextColor); nsfwTextView.setBackgroundColor(customTheme.nsfwBackgroundColor); nsfwTextView.setBorderColor(customTheme.nsfwBackgroundColor); nsfwTextView.setTextColor(customTheme.nsfwTextColor); flairTextView.setBackgroundColor(customTheme.flairBackgroundColor); flairTextView.setBorderColor(customTheme.flairBackgroundColor); flairTextView.setTextColor(customTheme.flairTextColor); awardsTextView.setBackgroundColor(customTheme.awardsBackgroundColor); awardsTextView.setBorderColor(customTheme.awardsBackgroundColor); awardsTextView.setTextColor(customTheme.awardsTextColor); archivedImageView.setColorFilter(customTheme.archivedTint, PorterDuff.Mode.SRC_IN); lockedImageView.setColorFilter(customTheme.lockedIconTint, PorterDuff.Mode.SRC_IN); crosspostImageView.setColorFilter(customTheme.crosspostIconTint, PorterDuff.Mode.SRC_IN); linkTextView.setTextColor(customTheme.secondaryTextColor); progressBar.setIndeterminateTintList(ColorStateList.valueOf(customTheme.colorAccent)); noPreviewLinkImageView.setBackgroundColor(customTheme.noPreviewLinkBackgroundColor); upvoteButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); scoreTextView.setTextColor(customTheme.postIconAndInfoColor); downvoteButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); commentsCountTextView.setTextColor(customTheme.postIconAndInfoColor); Drawable commentIcon = activity.getDrawable(R.drawable.ic_comment_grey_24dp); if (commentIcon != null) { DrawableCompat.setTint(commentIcon, customTheme.postIconAndInfoColor); } commentsCountTextView.setCompoundDrawablesWithIntrinsicBounds(commentIcon, null, null, null); saveButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); shareButton.setColorFilter(customTheme.postIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN); return rootView; }
Example #24
Source File: UserListingRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof UserListingRecyclerViewAdapter.DataViewHolder) { UserData userData = getItem(position); if (userData != null) { ((UserListingRecyclerViewAdapter.DataViewHolder) holder).constraintLayout.setOnClickListener(view -> { Intent intent = new Intent(context, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, userData.getName()); context.startActivity(intent); }); if (!userData.getIconUrl().equals("")) { glide.load(userData.getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(((UserListingRecyclerViewAdapter.DataViewHolder) holder).iconGifImageView); } ((UserListingRecyclerViewAdapter.DataViewHolder) holder).userNameTextView.setText(userData.getName()); new CheckIsFollowingUserAsyncTask(subscribedUserDao, userData.getName(), accountName, new CheckIsFollowingUserAsyncTask.CheckIsFollowingUserListener() { @Override public void isSubscribed() { ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); } @Override public void isNotSubscribed() { ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE); ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setOnClickListener(view -> { UserFollowing.followUser(oauthRetrofit, retrofit, accessToken, userData.getName(), accountName, subscribedUserDao, new UserFollowing.UserFollowingListener() { @Override public void onUserFollowingSuccess() { ((UserListingRecyclerViewAdapter.DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); Toast.makeText(context, R.string.followed, Toast.LENGTH_SHORT).show(); } @Override public void onUserFollowingFail() { Toast.makeText(context, R.string.follow_failed, Toast.LENGTH_SHORT).show(); } }); }); } }).execute(); } } }
Example #25
Source File: SubredditListingRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 4 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (holder instanceof DataViewHolder) { SubredditData subredditData = getItem(position); ((DataViewHolder) holder).constraintLayout.setOnClickListener(view -> callback.subredditSelected(subredditData.getName(), subredditData.getIconUrl())); if (!subredditData.getIconUrl().equals("")) { glide.load(subredditData.getIconUrl()) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .error(glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))) .into(((DataViewHolder) holder).iconGifImageView); } else { glide.load(R.drawable.subreddit_default_icon) .apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))) .into(((DataViewHolder) holder).iconGifImageView); } ((DataViewHolder) holder).subredditNameTextView.setText(subredditData.getName()); new CheckIsSubscribedToSubredditAsyncTask(redditDataRoomDatabase, subredditData.getName(), accountName, new CheckIsSubscribedToSubredditAsyncTask.CheckIsSubscribedToSubredditListener() { @Override public void isSubscribed() { ((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); } @Override public void isNotSubscribed() { ((DataViewHolder) holder).subscribeButton.setVisibility(View.VISIBLE); ((DataViewHolder) holder).subscribeButton.setOnClickListener(view -> { SubredditSubscription.subscribeToSubreddit(oauthRetrofit, retrofit, accessToken, subredditData.getName(), accountName, redditDataRoomDatabase, new SubredditSubscription.SubredditSubscriptionListener() { @Override public void onSubredditSubscriptionSuccess() { ((DataViewHolder) holder).subscribeButton.setVisibility(View.GONE); Toast.makeText(context, R.string.subscribed, Toast.LENGTH_SHORT).show(); } @Override public void onSubredditSubscriptionFail() { Toast.makeText(context, R.string.subscribe_failed, Toast.LENGTH_SHORT).show(); } }); }); } }).execute(); } }