com.bumptech.glide.load.resource.bitmap.CircleCrop Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.bitmap.CircleCrop.
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: MeFragment.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override protected void init() { super.init(); mUser = AVUser.getCurrentUser(User.class); mUserName.setText(mUser.getUsername()); if (mUser.getSlogan() != null) { mSlogan.setText(mUser.getSlogan()); } GlideApp.with(this) .load(mUser.getAvatar()) .transform(new CircleCrop()) .transition(new DrawableTransitionOptions().crossFade()) .placeholder(R.mipmap.ic_launcher_round) .into(mAvatar); }
Example #2
Source File: MeFragment.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_GALLERY_IMAGES: if (resultCode == RESULT_OK) { Uri uri = data.getData(); GlideApp.with(this).load(uri).transform(new CircleCrop()).into(mAvatar); ImageUtils.saveAvatar(getContext(), uri); } break; case REQUEST_CAMERA_IMAGES: if (resultCode == RESULT_OK) { GlideApp.with(getContext()) .load(IMAGE_DIR + mImageName) .transform(new CircleCrop()) .transition(new DrawableTransitionOptions().crossFade()) .into(mAvatar); ImageUtils.saveAvatar(mImageName, IMAGE_DIR + mImageName); } break; } }
Example #3
Source File: QuestionItemView.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
public void bindView(Question question) { mQuestion = question; mUserName.setText(question.getUser().getUsername()); mQuestionTitle.setText(question.getTitle()); if (question.getDescription() == null || question.getDescription().length() == 0) { mQuestionDesc.setVisibility(View.GONE); } else { mQuestionDesc.setVisibility(View.VISIBLE); mQuestionDesc.setText(question.getDescription()); } mAnswerCount.setText(String.valueOf(question.getAnswerCount())); mFavourCount.setText(String.valueOf(question.getFavourCount())); mPublishDate.setText(DateUtils.getDisplayString(getContext(), question.getCreatedAt())); GlideApp.with(this) .load(question.getUser().getAvatar()) .placeholder(R.mipmap.ic_launcher_round) .transform(new CircleCrop()) .into(mAvatar); }
Example #4
Source File: ArticleItemView.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
public void bindView(Article article) { mArticle = article; mUserName.setText(article.getUser().getUsername()); mArticleTitle.setText(article.getTitle()); if (article.getDes() == null || article.getDes().length() == 0) { mArticleDescription.setVisibility(View.GONE); } else { mArticleDescription.setVisibility(View.VISIBLE); mArticleDescription.setText(article.getDes()); } mPublishDate.setText(DateUtils.getDisplayString(getContext(), article.getCreatedAt())); mFavourCount.setText(String.valueOf(article.getFavourCount())); GlideApp.with(this).load(article.getUser().getAvatar()) .placeholder(R.mipmap.ic_launcher_round) .transform(new CircleCrop()).transition(new DrawableTransitionOptions().crossFade()).into(mAvatar); }
Example #5
Source File: SearchRelationshipViewHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void bind(SearchTEContractsModule.Presenter presenter, SearchTeiModel teiModel) { binding.setPresenter(presenter); setTEIData(teiModel.getAttributeValues()); binding.executePendingBindings(); itemView.setOnClickListener(view -> presenter.addRelationship(teiModel.getTei().uid(), null, teiModel.isOnline())); binding.trackedEntityImage.setBackground(AppCompatResources.getDrawable(itemView.getContext(), R.drawable.photo_temp_gray)); File file = new File(teiModel.getProfilePicturePath()); Drawable placeHolderId = ObjectStyleUtils.getIconResource(itemView.getContext(), teiModel.getDefaultTypeIcon(), R.drawable.photo_temp_gray); Glide.with(itemView.getContext()) .load(file) .placeholder(placeHolderId) .error(placeHolderId) .transition(withCrossFade()) .transform(new CircleCrop()) .into(binding.trackedEntityImage); }
Example #6
Source File: TEIDataFragment.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void showTeiImage(String filePath, String defaultIcon) { if (filePath.isEmpty() && defaultIcon.isEmpty()) { binding.cardFront.teiImage.setVisibility(View.GONE); } else { binding.cardFront.teiImage.setVisibility(View.VISIBLE); Glide.with(this) .load(new File(filePath)) .placeholder( ObjectStyleUtils.getIconResource(context, defaultIcon, R.drawable.photo_temp_gray) ) .error( ObjectStyleUtils.getIconResource(context, defaultIcon, R.drawable.photo_temp_gray) ) .transition(withCrossFade()) .transform(new CircleCrop()) .into(binding.cardFront.teiImage); } }
Example #7
Source File: GlideUtil.java From CloudReader with Apache License 2.0 | 5 votes |
/** * 加载圆角图,暂时用到显示头像 */ @BindingAdapter("android:displayCircle") public static void displayCircle(ImageView imageView, String imageUrl) { Glide.with(imageView.getContext()) .load(imageUrl) .transition(DrawableTransitionOptions.withCrossFade(500)) .error(R.drawable.ic_avatar_default) .transform(new CircleCrop()) // .apply(bitmapTransform(new CircleCrop())) // .transform(new GlideCircleTransform()) // .transform(new RoundedCorners(20)) // .transform(new CenterCrop(), new RoundedCorners(20)) .into(imageView); }
Example #8
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadUsingCircleTransformAndPlaceholder(String url, ImageView imageView, @DrawableRes int defaultImagePlaceholder) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(url) .apply(getRequestOptions().transform(new CircleCrop()) .placeholder(defaultImagePlaceholder)) .transition(DrawableTransitionOptions.withCrossFade()) .into(imageView); } else { Log.e(TAG, "::loadUsingCircleTransformAndPlaceholder() Context is null"); } return null; }
Example #9
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadUsingCircleTransform(@NonNull String url, @NonNull ImageView imageView) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(url) .apply(getRequestOptions().transform(new CircleCrop())) .transition(DrawableTransitionOptions.withCrossFade()) .into(imageView); } else { Log.e(TAG, "::loadUsingCircleTransform() Context is null"); } return null; }
Example #10
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadUsingCircleTransform(@DrawableRes int drawableId, ImageView imageView) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(drawableId) .apply(getRequestOptions().transform(new CircleCrop())) .transition(DrawableTransitionOptions.withCrossFade()) .into(imageView); } else { Log.e(TAG, "::loadUsingCircleTransform() Context is null"); } return null; }
Example #11
Source File: ImageLoader.java From aptoide-client-v8 with GNU General Public License v3.0 | 5 votes |
public Target<Drawable> loadWithCircleTransformAndPlaceHolder(String url, ImageView imageView, @DrawableRes int placeHolderDrawableId) { Context context = weakContext.get(); if (context != null) { return Glide.with(context) .load(url) .apply(getRequestOptions().transform(new CircleCrop()) .placeholder(placeHolderDrawableId)) .transition(DrawableTransitionOptions.withCrossFade()) .into(imageView); } else { Log.e(TAG, "::loadWithCircleTransformAndPlaceHolder() Context is null"); } return null; }
Example #12
Source File: GlideManager.java From FastLib with Apache License 2.0 | 5 votes |
/** * 加载圆形图片 * * @param obj * @param iv * @param placeholder 占位图 */ public static void loadCircleImg(Object obj, ImageView iv, Drawable placeholder) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholder) .placeholder(placeholder) .fallback(placeholder) .dontAnimate() .transform(new CircleCrop())).into(iv); }
Example #13
Source File: ImageLoader.java From apollo-DuerOS with Apache License 2.0 | 5 votes |
public static void loadCircle(Context context, ImageView imageView, String url, int placeHolder) { // options RequestOptions options = new RequestOptions() .placeholder(placeHolder) .error(placeHolder) .bitmapTransform(new CircleCrop()); // load Glide.with(context) .load(url) .apply(options) .into(imageView); }
Example #14
Source File: GlideManager.java From UIWidget with Apache License 2.0 | 5 votes |
/** * 加载圆形图片 * * @param obj * @param iv * @param placeholderResource 占位图 */ public static void loadCircleImg(Object obj, ImageView iv, int placeholderResource) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholderResource) .placeholder(placeholderResource) .fallback(placeholderResource) .dontAnimate() .transform(new CircleCrop())).into(iv); }
Example #15
Source File: GlideManager.java From TitleBarView with Apache License 2.0 | 5 votes |
/** * 加载圆形图片 * * @param obj * @param iv * @param placeholderResource 占位图 */ public static void loadCircleImg(Object obj, ImageView iv, int placeholderResource) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholderResource) .placeholder(placeholderResource) .fallback(placeholderResource) .dontAnimate() .transform(new CircleCrop())).into(iv); }
Example #16
Source File: UserAdapter.java From InstaTag with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(@NonNull ViewHolder holder, int position) { User user = userList.get(position); holder.user = user; holder.txtUserName.setText(user.getUserName()); holder.txtFullName.setText(user.getFullName()); Glide .with(context) .load(user.getUrl()) .apply(requestOptions.transforms(new CircleCrop())) .into(holder.imgProfile); }
Example #17
Source File: AudioPlayingButton.java From HaoReader with GNU General Public License v3.0 | 5 votes |
public void setCoverImage(String image) { Glide.with(this).load(image) .apply(new RequestOptions().dontAnimate().centerCrop() .transform(new CenterCrop(), new CircleCrop()) .error(R.drawable.img_cover_default) .placeholder(R.drawable.img_cover_default) .diskCacheStrategy(DiskCacheStrategy.RESOURCE)) .into(ivCover); }
Example #18
Source File: AnswerItemView.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
public void bindView(Answer answer) { mAnswer = answer; mAnswerText.setText(answer.getContent()); mUserName.setText(answer.getUser().getUsername()); Date createAt = answer.getCreatedAt(); mFavourCount.setText(String.valueOf(answer.getLikeCount())); mCommentCount.setText(String.valueOf(answer.getCommentCount())); mPublishDate.setText(DateUtils.getDisplayString(getContext(), createAt)); GlideApp.with(this) .load(answer.getUser().getAvatar()) .placeholder(R.mipmap.ic_launcher_round) .transform(new CircleCrop()) .transition(new DrawableTransitionOptions().crossFade()) .into(mAvatar); }
Example #19
Source File: CommentItemView.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
public void bindView(Comment comment) { mUserName.setText(comment.getUser().getUsername()); mComment.setText(comment.getContent()); GlideApp.with(this).load(comment.getUser().getAvatar()) .transform(new CircleCrop()) .placeholder(R.mipmap.ic_launcher_round) .transition(new DrawableTransitionOptions().crossFade()) .into(mAvatar); mPublishDate.setText(DateUtils.getDisplayString(getContext(), comment.getCreatedAt())); }
Example #20
Source File: ProfileActivity.java From AndroidPlusJava with GNU General Public License v3.0 | 5 votes |
private void updateUserInfo() { getSupportActionBar().setTitle(mProfileUser.getUsername()); mSlogan.setText(mProfileUser.getSlogan()); GlideApp.with(this) .load(mProfileUser.getAvatar()) .placeholder(R.mipmap.ic_launcher_round) .transform(new CircleCrop()).into(mAvatar); }
Example #21
Source File: TyUtils.java From tysq-android with GNU General Public License v3.0 | 5 votes |
public static void initUserPhoto(BitBaseActivity activity, Context context, String url, ImageView imageView) { GlideOptions options = GlideOptions .bitmapTransform(new CircleCrop()) .override(imageView.getWidth()) .error(R.drawable.placeholder_user_photo) .placeholder(R.drawable.placeholder_user_photo); TyUtils.getGlideRequest(activity, context, url, options, imageView); }
Example #22
Source File: TyUtils.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 填充用户头像 */ public static void initUserPhoto(android.support.v4.app.Fragment fragment, Context context, String url, ImageView imageView) { GlideOptions options = GlideOptions .bitmapTransform(new CircleCrop()) .override(imageView.getWidth()) .error(R.drawable.placeholder_user_photo) .placeholder(R.drawable.placeholder_user_photo); TyUtils.getGlideRequest(fragment, context, url, options, imageView); }
Example #23
Source File: TyUtils.java From tysq-android with GNU General Public License v3.0 | 5 votes |
/** * 填充用户头像 */ public static void initUserPhoto(Fragment fragment, Context context, String url, ImageView imageView) { GlideOptions options = GlideOptions .bitmapTransform(new CircleCrop()) .override(imageView.getWidth()) .error(R.drawable.placeholder_user_photo) .placeholder(R.drawable.placeholder_user_photo); TyUtils.getGlideRequest(fragment, context, url, options, imageView); }
Example #24
Source File: SummaryFragment.java From LQRBiliBlili with MIT License | 4 votes |
private void initUpperInfo(Summary.DataBean data) { Summary.DataBean.OwnerBean owner = data.getOwner(); if (owner != null) { ArmsUtils.obtainAppComponentFromContext(_mActivity).imageLoader().loadImage(_mActivity, ImageConfigImpl.builder().url(owner.getFace()).imageView(mIvHeader).transformation(new CircleCrop()).build()); mTvUpperName.setText(owner.getName()); } Summary.DataBean.OwnerExtBean owner_ext = data.getOwner_ext(); if (owner_ext != null) { mTvFans.setText(TextHandleUtil.handleCount2TenThousand(owner_ext.getFans()) + "人关注"); } // 得到视频相关tag tags = data.getTag(); if (tags != null) { // 如果tag数量超过4个,就缩减 if (tags.size() > 4) { newTags = new ArrayList<>(); Collections.sort(tags); for (int i = 0; i < 4; i++) { newTags.add(tags.get(i)); } adapter = new MyTagAdapter(newTags); isTagShrink = true; } else { adapter = new MyTagAdapter(tags); } mTagFlow.setAdapter(adapter); // 箭头的点击事件 changeArrowDown(); mIvTagShrink.setOnClickListener(v -> { if (isTagShrink) { // 切换成多的 if (newTags != null) { adapter = new MyTagAdapter(tags); } changeArrowUp(); } else { // 切换成少的 if (newTags != null) { adapter = new MyTagAdapter(newTags); } changeArrowDown(); } isTagShrink = !isTagShrink; if (newTags != null) { mTagFlow.setAdapter(adapter); } }); } }
Example #25
Source File: SearchTEViewHolder.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void bind(SearchTEContractsModule.Presenter presenter, SearchTeiModel searchTeiModel) { binding.setPresenter(presenter); binding.setOverdue(searchTeiModel.isHasOverdue()); binding.setIsOnline(searchTeiModel.isOnline()); binding.setSyncState(searchTeiModel.getTei().state()); setEnrollment(searchTeiModel.getEnrollments()); setEnrollmentInfo(searchTeiModel.getEnrollmentInfo()); setTEIData(searchTeiModel.getAttributeValues()); binding.trackedEntityImage.setBackground(AppCompatResources.getDrawable(itemView.getContext(), R.drawable.photo_temp_gray)); binding.followUp.setBackground(AppCompatResources.getDrawable(itemView.getContext(), R.drawable.ic_circle_red)); binding.syncState.setOnClickListener(view -> { if (searchTeiModel.getTei().deleted() || searchTeiModel.getSelectedEnrollment() != null && searchTeiModel.getSelectedEnrollment().deleted()) Toast.makeText(itemView.getContext(), itemView.getContext().getString(R.string.record_marked_for_deletion), Toast.LENGTH_SHORT).show(); else presenter.onSyncIconClick(searchTeiModel.getTei().uid()); }); binding.executePendingBindings(); itemView.setOnClickListener(view -> presenter.onTEIClick( searchTeiModel.getTei().uid(), searchTeiModel.getSelectedEnrollment() != null ? searchTeiModel.getSelectedEnrollment().uid() : null, searchTeiModel.isOnline())); File file = new File(searchTeiModel.getProfilePicturePath()); Drawable placeHolderId = ObjectStyleUtils.getIconResource(itemView.getContext(), searchTeiModel.getDefaultTypeIcon(), R.drawable.photo_temp_gray); if (file.exists()) Glide.with(itemView.getContext()) .load(file) .placeholder(placeHolderId) .error(placeHolderId) .transition(withCrossFade()) .transform(new CircleCrop()) .into(binding.trackedEntityImage); else binding.trackedEntityImage.setImageDrawable(placeHolderId); }
Example #26
Source File: PersonalHomePageFragment.java From tysq-android with GNU General Public License v3.0 | 4 votes |
@Override public void onResume() { super.onResume(); if (UserCache.getDefault() == null) { return; } if (userId != UserCache.getDefault().getAccountId()) { mPresenter.getPersonalPage(userId); return; } RequestOptions requestOptions = RequestOptions .bitmapTransform(new CircleCrop()) .error(R.drawable.placeholder_user_photo) .placeholder(R.drawable.placeholder_user_photo); TyUtils.getGlideRequest( this, getContext(), UserCache.getDefault().getHeadUrl(), requestOptions, ivUserPhoto); tvUserName.setText(UserCache.getDefault().getAccount()); judgeOrHideLine(UserCache.getDefault().getCareer(), UserCache.getDefault().getTrade(), UserCache.getDefault().getHomeAddress()); judgeAndSetData(UserCache.getDefault().getCareer(), tvUserCareer); judgeAndSetData(UserCache.getDefault().getTrade(), tvUserTrade); judgeAndSetData(UserCache.getDefault().getHomeAddress(), tvUserAddress); if (UserCache.getDefault().getPersonalProfile().trim().length() <= 0 || UserCache.getDefault().getPersonalProfile() == null) { tvUserDes.setVisibility(View.GONE); } else { tvUserDes.setText(UserCache.getDefault().getPersonalProfile()); } }
Example #27
Source File: PersonalHomePageFragment.java From tysq-android with GNU General Public License v3.0 | 4 votes |
/** * 设置用户信息 */ private void initUserInfo(PersonalPageResp value) { RequestOptions requestOptions = RequestOptions .bitmapTransform(new CircleCrop()) .error(R.drawable.placeholder_user_photo) .placeholder(R.drawable.placeholder_user_photo); TyUtils.getGlideRequest( this, getContext(), value.getAccountInfo().getHeadUrl(), requestOptions, ivUserPhoto ); //放大图片 ivUserPhoto.setOnClickListener(view -> { mJerryImageModel.setBlurryUrl(value.getAccountInfo().getHeadUrl()); mJerryImageModel.setOriginalUrl(value.getAccountInfo().getHeadUrl()); ImageWatcherActivity.startActivity(getContext(), mJerryImageModel); } ); tvUserName.setText(value.getAccountInfo().getAccount()); judgeOrHideLine(value.getAccountInfo().getCareer(), value.getAccountInfo().getTrade(), value.getAccountInfo().getHomeAddress()); judgeAndSetData(value.getAccountInfo().getCareer(), tvUserCareer); judgeAndSetData(value.getAccountInfo().getTrade(), tvUserTrade); judgeAndSetData(value.getAccountInfo().getHomeAddress(), tvUserAddress); if (value.getAccountInfo().getPersonalProfile().trim().length() <= 0 || value.getAccountInfo().getPersonalProfile() == null) { tvUserDes.setVisibility(View.GONE); } else { tvUserDes.setText(value.getAccountInfo().getPersonalProfile()); } setAchievementInfo(tvReadQuantity, TyUtils.formatNum(value.getAccountInfo().getReadedNum()), R.string.personal_achievement_read_quantity); setAchievementInfo(tvCollection, TyUtils.formatNum(value.getAccountInfo().getCollectedNum()), R.string.personal_achievement_collection); //用户是否有登录 if (UserCache.getDefault() == null) { rlFocusSomeOne.setVisibility(View.GONE); ivMenu.setVisibility(View.GONE); } else { rlFocusSomeOne.setVisibility(View.VISIBLE); judgeIsModerator(); if (userId == UserCache.getDefault().getAccountId()) { tvFocusSomeone.setText(R.string.personal_edit_profile); rlFocusSomeOne.setOnClickListener(view1 -> PersonInfoActivity.startActivity(getContext(), PersonInfoActivity.INFO_LIST) ); } else { setFocus(true, value.getAccountInfo().isFollow()); isFollow = value.getAccountInfo().isFollow(); } } Integer gradeResource = Constant.LV_MAP.get(value.getAsset().getGrade()); if (gradeResource == null) { gradeResource = Constant.LV_MAP.get(Constant.DEFAULT_GRADE); } ivLv.setImageDrawable(ContextCompat .getDrawable(getContext(), gradeResource)); setTitle(TyUtils.formatNum(value.getAsset().getArticleNum()), TyUtils.formatNum(value.getAsset().getCommentNum()), TyUtils.formatNum(value.getAsset().getCollectNum()), TyUtils.formatNum(value.getAsset().getAttentionNum()), TyUtils.formatNum(value.getAsset().getFanNum())); for (int i = 0; i < mTabTitle.length; i++) { tabLayout.getTitleView(i).setText(mTabTitle[i]); } }