com.bumptech.glide.load.resource.bitmap.FitCenter Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.bitmap.FitCenter.
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: ThumbnailView.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
public ThumbnailView(final Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); inflate(context, R.layout.thumbnail_view, this); this.image = findViewById(R.id.thumbnail_image); this.blurhash = findViewById(R.id.thumbnail_blurhash); this.playOverlay = findViewById(R.id.play_overlay); this.captionIcon = findViewById(R.id.thumbnail_caption_icon); super.setOnClickListener(new ThumbnailClickDispatcher()); if (attrs != null) { TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0); bounds[MIN_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minWidth, 0); bounds[MAX_WIDTH] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxWidth, 0); bounds[MIN_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_minHeight, 0); bounds[MAX_HEIGHT] = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_maxHeight, 0); radius = typedArray.getDimensionPixelSize(R.styleable.ThumbnailView_thumbnail_radius, getResources().getDimensionPixelSize(R.dimen.thumbnail_default_radius)); fit = typedArray.getInt(R.styleable.ThumbnailView_thumbnail_fit, 0) == 1 ? new FitCenter() : new CenterCrop(); typedArray.recycle(); } else { radius = getResources().getDimensionPixelSize(R.dimen.message_corner_collapse_radius); } }
Example #2
Source File: BitmapUtil.java From Silence with GNU General Public License v3.0 | 6 votes |
private static <T> Bitmap createScaledBitmapInto(Context context, T model, int width, int height) throws BitmapDecodingException { final Bitmap rough = Downsampler.AT_LEAST.decode(getInputStreamForModel(context, model), Glide.get(context).getBitmapPool(), width, height, DecodeFormat.PREFER_RGB_565); final Resource<Bitmap> resource = BitmapResource.obtain(rough, Glide.get(context).getBitmapPool()); final Resource<Bitmap> result = new FitCenter(context).transform(resource, width, height); if (result == null) { throw new BitmapDecodingException("unable to transform Bitmap"); } return result.get(); }
Example #3
Source File: SimpleToActivity.java From YcShareElement with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { YcShareElement.setEnterTransitions(this, this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_to); mImageView = findViewById(R.id.s2_img); Glide.with(this) .load(R.drawable.test) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .transform(new FitCenter()) .placeholder(new ColorDrawable(Color.GRAY))) .into(mImageView); YcShareElement.postStartTransition(this); }
Example #4
Source File: SimpleFromActivity.java From YcShareElement with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_from); final ImageView imgView = findViewById(R.id.s1_img); Glide.with(this) .load(R.drawable.test) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .transform(new FitCenter()) .placeholder(new ColorDrawable(Color.GRAY))) .into(imgView); imgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(SimpleFromActivity.this, SimpleToActivity.class); Bundle optionsBundle = YcShareElement.buildOptionsBundle(SimpleFromActivity.this,SimpleFromActivity.this); startActivity(intent, optionsBundle); } }); }
Example #5
Source File: WeatherDailyAdapter.java From MVVMArms with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseBindHolder helper, WeatherDailyResponse.DailyResult.Daily item) { ViewDataBinding binding = helper.getBinding(); binding.setVariable(BR.daily, item); binding.executePendingBindings(); SuperTextView superTextView = helper.getView(R.id.super_item_daily); ArmsUtils.INSTANCE.obtainArmsComponent(mContext).imageLoader() .loadImage(mContext, ImageConfigImpl.builder() .url(String.format(Locale.CHINESE, Api.API_WEATHER_ICON_URL, item.getCodeDay())) .placeholder(R.mipmap.ic_placeholder) .errorPic(R.mipmap.weather_unknown) .transformation(new FitCenter()) .imageView(superTextView.getRightIconIV()) .build()); }
Example #6
Source File: TestFragment.java From glide-support with The Unlicense | 6 votes |
@SuppressWarnings("unchecked") @Override protected void load(Context context) throws Exception { String urlString = "http://web.twisterrob.net/glide/1257_changing.php"; Glide .with(this) .load(new ForceLoadGlideUrl(urlString)) .fitCenter() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) //.placeholder(R.drawable.glide_placeholder) //.error(R.drawable.glide_error) .listener(new LoggingListener<GlideUrl, GlideDrawable>("full")) .thumbnail(Glide .with(this) .load(new CachedGlideUrl(urlString)) .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true) .listener(new LoggingListener<GlideUrl, GlideDrawable>("thumbnail")) .bitmapTransform(new FitCenter(context), new GrayscaleTransformation(context)) .sizeMultiplier(0.25f) ) .into(imageView); }
Example #7
Source File: ImageListCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { super.onBindViewHolder(holder, position); ImageView imageView = holder.itemView.findViewById(R.id.list_item_img); ViewCompat.setTransitionName(imageView, mData.url); setSize(holder.itemView); Glide.with(imageView) .load(mData.url) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new FitCenter()) .placeholder(new ColorDrawable(Color.GRAY))) .into(imageView); }
Example #8
Source File: ImageContentCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(BasePagerViewHolder viewHolder) { ImageView imageView = viewHolder.getView(R.id.content_item_img); ViewCompat.setTransitionName(imageView, mData.url); Bitmap thumbnail = mData.url.equals(BitmapThumbnail.sKey)?BitmapThumbnail.sBitmap:null; Glide.with(imageView) .load(mData.url) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new FitCenter()) .skipMemoryCache(true) .placeholder(thumbnail == null ? new ColorDrawable(Color.GRAY) : new BitmapDrawable(imageView.getResources(), thumbnail))) .into(imageView); }
Example #9
Source File: VideoContentCell.java From YcShareElement with Apache License 2.0 | 5 votes |
@Override protected void onBindViewHolder(BasePagerViewHolder viewHolder) { //COVER final ImageView coverImg = viewHolder.getView(R.id.content_item_video_cover); ViewCompat.setTransitionName(coverImg, mData.url); Glide.with(coverImg) .load(mData.url+"?vframe/jpg/offset/0") .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .transform(new FitCenter()) .placeholder(new ColorDrawable(Color.GRAY))) .into(coverImg); //VIDEO StandardGSYVideoPlayer videoView = viewHolder.getView(R.id.content_item_video); GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder(); gsyVideoOption .setIsTouchWiget(true) .setRotateViewAuto(false) .setLockLand(false) .setAutoFullWithSize(true) .setShowFullAnimation(false) .setNeedLockFull(true) .setUrl(mData.url) .setCacheWithPlay(true) .setLooping(true) .setGSYVideoProgressListener(new GSYVideoProgressListener() { @Override public void onProgress(int progress, int secProgress, int currentPosition, int duration) { if (progress > 0) { coverImg.setVisibility(View.GONE); } } }) .build(videoView); if (mStartPlay) { mStartPlay = false; videoView.startPlayLogic(); } }
Example #10
Source File: MainImageAdapter.java From PixImagePicker with Apache License 2.0 | 5 votes |
public MainImageAdapter(Context context) { this.list = new ArrayList<>(); int size = (Utility.WIDTH / SPAN_COUNT) - (MARGIN / 2); layoutParams = new FrameLayout.LayoutParams(size, size); layoutParams.setMargins(MARGIN, MARGIN - (MARGIN / 2), MARGIN, MARGIN - (MARGIN / 2)); options = new RequestOptions().override(300).transform(new CenterCrop()).transform(new FitCenter()); glide = Glide.with(context); }
Example #11
Source File: InstantImageAdapter.java From PixImagePicker with Apache License 2.0 | 5 votes |
public InstantImageAdapter(Context context) { this.list = new ArrayList<>(); size = Utility.convertDpToPixel(72, context) - 2; padding = (int) (size / 3.5); glide = Glide.with(context); options = new RequestOptions().override(256).transform(new CenterCrop()).transform(new FitCenter()); }
Example #12
Source File: ListContributorsHolder.java From TwrpBuilder with GNU General Public License v3.0 | 5 votes |
public void bind( String email, String name, String photoUrl, String xdaUrl, String gitId, @Nullable String donationUrl, @Nullable String description, String key ) { tvGitId.setText(gitId); tvName.setText(name); tvEmail.setText(email); tvXdaUrl.setText(xdaUrl); if (description != null) { tvDescription.setText(description); tvDescription.setVisibility(View.VISIBLE); } if (donationUrl != null) { tvDonation.setText(donationUrl); tvDonation.setVisibility(View.VISIBLE); } else { tvDonation.setText(""); } Glide.with(context.getApplicationContext()) .load(photoUrl) .apply(new RequestOptions().circleCrop().transform(new FitCenter())) .into(imageViewProfile); }
Example #13
Source File: TestFragment.java From glide-support with The Unlicense | 5 votes |
@Override protected void load(Context context) throws Exception { Glide .with(context) .load(R.drawable.glide) .diskCacheStrategy(DiskCacheStrategy.NONE) // necessary only because I'm loading an APK resource .skipMemoryCache(true) // remove in production, this is just there so it's reproducible quickly .placeholder(R.drawable.glide_placeholder) // delay to see what's going on, in normal usage replace this with .fitCenter() .transform(new FitCenter(context), new DelayBitmapTransformation(1000)) .animate(new PaddingAnimationFactory<>(new DrawableCrossFadeFactory<GlideDrawable>(2000))) .into(imageView) ; }
Example #14
Source File: HtmlChatAdapter.java From glide-support with The Unlicense | 5 votes |
@SuppressWarnings("unchecked") void bind(ChatMessage message) { nameView.setText(message.getUserName()); Context context = avatarView.getContext(); glide.load(message.getAvatarUrl()) .bitmapTransform(new FitCenter(context), new CropCircleTransformation(context)) .listener(new LoggingListener<String, GlideDrawable>()) .into(avatarView); bindEmoticonMessage(messageView, message.getMessage()); }
Example #15
Source File: ImageLoader.java From v2ex with Apache License 2.0 | 4 votes |
/** * Construct a standard ImageLoader object. */ public ImageLoader(Context context) { requestManager = Glide.with(context); mCenterCrop = new CenterCrop(Glide.get(context).getBitmapPool()); mFitCenter = new FitCenter(Glide.get(context).getBitmapPool()); }
Example #16
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 #17
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 #18
Source File: Glide.java From giffun with Apache License 2.0 | 4 votes |
FitCenter getBitmapFitCenter() { return bitmapFitCenter; }
Example #19
Source File: Glide.java From giffun with Apache License 2.0 | 4 votes |
Glide(Engine engine, MemoryCache memoryCache, BitmapPool bitmapPool, Context context, DecodeFormat decodeFormat, DiskCache.Factory diskCacheFactory) { this.engine = engine; this.bitmapPool = bitmapPool; this.memoryCache = memoryCache; this.decodeFormat = decodeFormat; this.diskCacheFactory = diskCacheFactory; loaderFactory = new GenericLoaderFactory(context); mainHandler = new Handler(Looper.getMainLooper()); bitmapPreFiller = new BitmapPreFiller(memoryCache, bitmapPool, decodeFormat); dataLoadProviderRegistry = new DataLoadProviderRegistry(); StreamBitmapDataLoadProvider streamBitmapLoadProvider = new StreamBitmapDataLoadProvider(bitmapPool, decodeFormat); dataLoadProviderRegistry.register(InputStream.class, Bitmap.class, streamBitmapLoadProvider); FileDescriptorBitmapDataLoadProvider fileDescriptorLoadProvider = new FileDescriptorBitmapDataLoadProvider(bitmapPool, decodeFormat); dataLoadProviderRegistry.register(ParcelFileDescriptor.class, Bitmap.class, fileDescriptorLoadProvider); ImageVideoDataLoadProvider imageVideoDataLoadProvider = new ImageVideoDataLoadProvider(streamBitmapLoadProvider, fileDescriptorLoadProvider); dataLoadProviderRegistry.register(ImageVideoWrapper.class, Bitmap.class, imageVideoDataLoadProvider); GifDrawableLoadProvider gifDrawableLoadProvider = new GifDrawableLoadProvider(context, bitmapPool); dataLoadProviderRegistry.register(InputStream.class, GifDrawable.class, gifDrawableLoadProvider); dataLoadProviderRegistry.register(ImageVideoWrapper.class, GifBitmapWrapper.class, new ImageVideoGifDrawableLoadProvider(imageVideoDataLoadProvider, gifDrawableLoadProvider, bitmapPool)); dataLoadProviderRegistry.register(InputStream.class, File.class, new StreamFileDataLoadProvider()); register(File.class, ParcelFileDescriptor.class, new FileDescriptorFileLoader.Factory()); register(File.class, InputStream.class, new StreamFileLoader.Factory()); register(int.class, ParcelFileDescriptor.class, new FileDescriptorResourceLoader.Factory()); register(int.class, InputStream.class, new StreamResourceLoader.Factory()); register(Integer.class, ParcelFileDescriptor.class, new FileDescriptorResourceLoader.Factory()); register(Integer.class, InputStream.class, new StreamResourceLoader.Factory()); register(String.class, ParcelFileDescriptor.class, new FileDescriptorStringLoader.Factory()); register(String.class, InputStream.class, new StreamStringLoader.Factory()); register(Uri.class, ParcelFileDescriptor.class, new FileDescriptorUriLoader.Factory()); register(Uri.class, InputStream.class, new StreamUriLoader.Factory()); register(URL.class, InputStream.class, new StreamUrlLoader.Factory()); register(GlideUrl.class, InputStream.class, new HttpUrlGlideUrlLoader.Factory()); register(byte[].class, InputStream.class, new StreamByteArrayLoader.Factory()); transcoderRegistry.register(Bitmap.class, GlideBitmapDrawable.class, new GlideBitmapDrawableTranscoder(context.getResources(), bitmapPool)); transcoderRegistry.register(GifBitmapWrapper.class, GlideDrawable.class, new GifBitmapWrapperDrawableTranscoder( new GlideBitmapDrawableTranscoder(context.getResources(), bitmapPool))); bitmapCenterCrop = new CenterCrop(bitmapPool); drawableCenterCrop = new GifBitmapWrapperTransformation(bitmapPool, bitmapCenterCrop); bitmapFitCenter = new FitCenter(bitmapPool); drawableFitCenter = new GifBitmapWrapperTransformation(bitmapPool, bitmapFitCenter); }