当前位置:网站首页>Popular framework: the use of glide
Popular framework: the use of glide
2022-07-04 14:23:00 【Y.IU.】
Introduce dependencies
implementation 'com.github.bumptech.glide:glide:4.11.0'
Glide Place holder
- placeholder Pictures displayed when requesting pictures
- error The picture displayed when the request fails ( If not set , On display placeholder Occupation map )
- fallback Requested url by null Pictures shown when ( If not set , On display placeholder Occupation map )
Configure the use of placeholders :
RequestOptions ro = new RequestOptions()
.placeholder( Picture path )
.error( Picture path )
.fallback( Picture path )
Specific use :
Glide.with(fragment/activity/view)
.load(url)
.apply(ro)
.with(imageView);
Transition and transformation
transition :transition
Animation from placeholder to newly loaded picture
Avoid placeholders showing up after animations
DrawableCrossFadeFactory fadeFactory = new DrawableCrossFadeFactory .Builder().setCrossFadeEnabled(true).build();
Implementation code
Glide.with(this)
.load("https://img1.baidu.com/it/u=722430420,1974228945&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500")
.apply(options)
.transition(DrawableTransitionOptions.withCrossFade(fadeFactory).crossFade(1000))
.into(imageView);
transformation :transform
- CircleCrop: Round corners
- RoundedCorners: The four angles are specified uniformly
- GranulaRoundedCorners: The four angles are specified separately
- Rotate: rotate
Implementation code
.transform(new CircleCrop())
Generated API
Introduce dependencies , This dependency is equivalent to a code generator
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
stay Application Introduced in the module of AppGlideModule The implementation of the .( take AppGlideModule Among the configured items )
/** * Configuration class */ @GlideModule public class MyAppModule extends AppGlideModule { }
Click on Bulid -> Make Module … Compile
In the end, it can be passed GlideApp Realization Glide Same effect , And you just need to GlideApp through . Just implement it in the way
GlideApp.with(this)
.load("")
.placeholder(R.drawable.icon1)
.error(R.drawable.icon2)
.fallback(R.drawable.icon3)
.into(imageView);
GlideExtension and GlideOption
If the option set needs to be used frequently , You can configure the class and write GlideExtension and GlideOption Annotations .
@GlideExtension
public class MyAppExtension {
private MyAppExtension() {
// It has to be private
}
@GlideOption
public static BaseRequestOptions<?> defaultImg(BaseRequestOptions<?> options) {
return options.placeholder(R.drawable.icon1)
.error(R.drawable.icon2)
.fallback(R.drawable.icon3);
}
}
Specific use
GlideApp.with(this).load("").defaultImg().into(imageView);
边栏推荐
- Excel快速合并多行数据
- docker-compose公网部署redis哨兵模式
- Visual Studio调试方式详解
- sql优化之查询优化器
- Haobo medical sprint technology innovation board: annual revenue of 260million Yonggang and Shen Zhiqun are the actual controllers
- LifeCycle
- Test process arrangement (2)
- File creation, writing, reading, deletion (transfer) in go language
- 数据湖(十三):Spark与Iceberg整合DDL操作
- Understand chisel language thoroughly 04. Chisel Foundation (I) - signal type and constant
猜你喜欢
Test process arrangement (3)
Excel quickly merges multiple rows of data
迅为IMX6Q开发板QT系统移植tinyplay
Use of tiledlayout function in MATLAB
【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
MATLAB中tiledlayout函数使用
Detailed index of MySQL
ML之shap:基于boston波士顿房价回归预测数据集利用shap值对XGBoost模型实现可解释性案例
[antd step pit] antd form cooperates with input Form The height occupied by item is incorrect
【信息检索】链接分析
随机推荐
NowCoder 反转链表
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
Learn kernel 3: use GDB to track the kernel call chain
Golang uses JSON unmarshal number to interface{} number to become float64 type (turn)
Matters needing attention in overseas game Investment Agency
C# wpf 实现截屏框实时截屏功能
【云原生】我怎么会和这个数据库杠上了?
Detailed index of MySQL
数据埋点的一些问题和想法
[MySQL from introduction to proficiency] [advanced chapter] (V) SQL statement execution process of MySQL
测试流程整理(3)
Install and use MAC redis, connect to remote server redis
How to package QT and share exe
海外游戏代投需要注意的
The game goes to sea and operates globally
Understand chisel language thoroughly 08. Chisel Foundation (V) -- wire, REG and IO, and how to understand chisel generation hardware
sql优化之explain
Vscode common plug-ins summary
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)
Xcode 异常图片导致ipa包增大问题