Glide_FTP_Demo,custom Glide AppGlideModule and ModelLoader to load ftp images directly fro android
repositories {
google()
jcenter()
mavenCentral()
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'commons-net:commons-net:3.6' //ftp支持库
自定义AppGlideModule官方文档 https://muyangmin.github.io/glide-docs-cn/doc/configuration.html#applications
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
}
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
registry.prepend(FTPModel.class, InputStream.class,
new FTPModelLoaderFactory(context));
}
@Override
public boolean isManifestParsingEnabled() {
return false;
}
}
String path = "ftp://DSERP:DSERP@192.168.215.150/tryCarCheck/S711039/vimghz__LFV3A23C1J3011237_20190717.jpg";
FTPModel ftpModel = new FTPModel(path);
Glide.with(MainActivity.this).load(ftpModel)
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
.into(imageView);
FTPModel ftpModel = new FTPModel("192.168.215.150", null, "DSERP", "DSERP", "/DMS/S711039/201905/vDriLcsUrlDown_170175cd-8174-46e1-83c6-62e550b4cd45.bmp");
Glide.with(MainActivity.this).load(ftpModel)
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
.into(imageView2);