├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── gradle.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── release │ ├── app-release.apk │ ├── app-release_no_fresco.apk │ └── output.json └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sxu │ │ └── imageloadermanager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sxu │ │ │ └── imageloadermanager │ │ │ ├── ImageLoaderActivity.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── default_placeholder_image.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_image_loader_layout.xml │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── sxu │ └── imageloadermanager │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── imageloader ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sxu │ │ └── imageloader │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sxu │ │ │ ├── imageloader │ │ │ ├── ImageLoaderManager.java │ │ │ ├── WrapImageView.java │ │ │ ├── instance │ │ │ │ ├── FrescoInstance.java │ │ │ │ ├── GlideInstance.java │ │ │ │ ├── ImageLoaderInstance.java │ │ │ │ └── UILInstance.java │ │ │ └── listener │ │ │ │ ├── ImageLoaderListener.java │ │ │ │ └── SimpleImageLoaderListener.java │ │ │ ├── transform │ │ │ ├── GlideBlurTransform.java │ │ │ ├── GlideCircleBitmapTransform.java │ │ │ └── GlideRoundBitmapTransform.java │ │ │ └── utils │ │ │ ├── DiskLruCache.java │ │ │ ├── DiskLruCacheManager.java │ │ │ ├── FastBlurUtil.java │ │ │ ├── StrictLineReader.java │ │ │ └── Util.java │ └── res │ │ └── values │ │ ├── attrs.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── sxu │ └── imageloader │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | !/app/release/ 11 | /keystore/ 12 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liberuman/ImageloaderManager/743c25107bd70f7b32e009401e9496289840e9be/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 36 | 37 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Freeman 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### !!!说明:为了更好地整合图片相关的操作,已将此项目合并到[ImageSet](https://github.com/juhonggang/imageset),后续不再更新。 2 | 3 | 4 | [![](https://jitpack.io/v/JuHonggang/ImageloaderManager.svg)](https://jitpack.io/#JuHonggang/ImageloaderManager) 5 | 6 | ### 背景 7 | 8 | 在APP开发过程,图片加载是一个不可或缺的模块,一般我们都会使用比较成熟的开源库,如Fresco, ImageLoader, Glide等。 这些开源库也都提供了简洁的使用方式,使我们可以快速完成图片的加载过程。但是当我们更换图片加载库时,,会发现项目中到处都引用了,这无疑是一个庞大的工作量。 9 | 为了降低图片加载库在项目中的耦合度,特意对图片加载库进行了二次封装。通过这种方式,我们可快速完成图片加载库的更换工作。 10 | 11 | ### 基本结构 12 | 13 | ![image](http://od186sz8s.bkt.clouddn.com/ImageLoaderManager.png) 14 | 15 | 从结构图中我们可以看出,更换图片加载库只需要设置相应的mLoaderInstance即可。 16 | 17 | ### 添加依赖 18 | 19 | 在项目的build.gradle中添加: 20 | 21 | allprojects { 22 | repositories { 23 | ... 24 | maven { url 'https://jitpack.io' } 25 | } 26 | } 27 | 28 | 在APP模块下的build.gradle中添加依赖: 29 | 30 | dependencies { 31 | implementation 'com.github.JuHonggang:ImageloaderManager:v0.14' 32 | } 33 | 34 | ### 使用 35 | 36 | ImageLoaderManager.getInstance().init(getApplicationContext(), new FrescoInstance()); 37 | ImageLoaderManager.getInstance().displayImage("http://t.cn/RTRKzUt", imageView); 38 | 39 | ### 说明 40 | 41 | 1. ImageLoaderManager提供了统一的接口,至于初始化中怎样配置,只需要在相应的Instance中去实现即可; 42 | 43 | 2. 如需要封装其他的图片加载库,如Picasso, 只需要实现ImageLoaderInstance接口即可; 44 | 45 | 3. 图片加载库在加载图片时都提供了配置项,如设置占位图,失败图,边框等。这些与View相关的配置是以自定义View的形式实现的; 46 | 47 | 4. 由于Fresco加载的目标是SimpleDraweeView,其他的图片加载库为ImageView, 为了提供统一的目标对象,我们使用继承自GenericDraweeView(SimpleDraweeView的父类)的WrapImage作为加载目标。如果你不需要封装Fresco, 那么可将WrapImageView的父类改成ImageView; 48 | 49 | 5. 此库中同时集成了Fresco, ImageLoader, Glide三种图片加载方式,开发中通常不需要都使用,可通过引入module的方式将代码添加到项目中,删除 50 | 不需要的库和代码即可; 51 | 52 | 6. 项目中提供了高斯模糊的几种实现方案:Fresco自带,FastBlur算法,RenderScript。具体的效果可运行项目进行查看。说一下这几种方案使用过程中的感受: 53 | 54 | 55 | > 1. Fresco提供的高斯模糊效果算是这3种方案中最好的,稳定,显示效果细腻; 56 | > 2. FastBlur算法,虽然可通过缩放Bitmap来提高转换效率,但显示效果不如Fresco; 57 | > 3. RenderScript虽然是Android提供的,但是使用体验并不好,在ImageLoader中使用,模糊效果显示异常。在Glide中使用时,对Bitmap缩放后模糊效果显示异常。同时由于有些厂商对这一功能进行了阉割,使用时需要添加so库,为了版本的兼容性,还需要引入v8的兼容包。 58 | > 4. 高斯模糊效果是一个很耗性能的一个操作,很容易引起OOM,所以在使用时应将Bitmap尽可能的缩小,同时选择一个稳定的实现方式。 59 | 60 | ### 修改记录 61 | 62 | 2018.8.30 由于RenderScript实现高斯模糊的方式需要引入额外的jar包和so库,会导致APK体积增加1M多,已从项目删除。如有需要可从修改日期之前的提交记录中 63 | 获取相应的jar/so和代码。 64 | 65 | ### Licence 66 | 67 | > Copyright (c) 2018 Freeman 68 | > 69 | > Permission is hereby granted, free of charge, to any person obtaining a copy 70 | > of this software and associated documentation files (the "Software"), to deal 71 | > in the Software without restriction, including without limitation the rights 72 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 73 | > copies of the Software, and to permit persons to whom the Software is 74 | > furnished to do so, subject to the following conditions: 75 | > 76 | > The above copyright notice and this permission notice shall be included in all 77 | > copies or substantial portions of the Software. 78 | > 79 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 80 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 81 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 82 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 83 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 84 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 85 | > SOFTWARE. 86 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | signingConfigs { 5 | SignConfig { 6 | keyAlias 'ImageLoaderManager' 7 | keyPassword '123456' 8 | storeFile file('../keystore/imageloader.keystore') 9 | storePassword '123456' 10 | } 11 | } 12 | compileSdkVersion 26 13 | defaultConfig { 14 | applicationId "com.sxu.imageloadermanager" 15 | minSdkVersion 14 16 | targetSdkVersion 26 17 | versionCode 1 18 | versionName "1.0" 19 | signingConfig signingConfigs.SignConfig 20 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | debug { 25 | debuggable true 26 | minifyEnabled false 27 | } 28 | 29 | release { 30 | minifyEnabled true 31 | shrinkResources true 32 | zipAlignEnabled true 33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 34 | } 35 | } 36 | } 37 | 38 | dependencies { 39 | implementation fileTree(include: ['*.jar'], dir: 'libs') 40 | implementation 'com.android.support:appcompat-v7:27.0.2' 41 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 42 | testImplementation 'junit:junit:4.12' 43 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 44 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 45 | implementation project(path: ':imageloader') 46 | } 47 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -dontpreverify 23 | -repackageclasses '' 24 | -allowaccessmodification 25 | -optimizations !code/simplification/arithmetic 26 | -keepattributes *Annotation* 27 | -ignorewarnings 28 | 29 | -dontwarn android.support.** 30 | 31 | # 保留系统组件 32 | -keep public class * extends android.app.Activity 33 | -keep public class * extends android.app.Application 34 | -keep public class * extends android.app.Service 35 | -keep public class * extends android.content.BroadcastReceiver 36 | -keep public class * extends android.content.ContentProvider 37 | 38 | # 保留自定义View 39 | -keep public class * extends android.view.View { 40 | public (android.content.Context); 41 | public (android.content.Context, android.util.AttributeSet); 42 | public (android.content.Context, android.util.AttributeSet, int); 43 | public void set*(...); 44 | } 45 | -keepclasseswithmembers class * { 46 | public (android.content.Context, android.util.AttributeSet); 47 | } 48 | -keepclasseswithmembers class * { 49 | public (android.content.Context, android.util.AttributeSet, int); 50 | } 51 | 52 | # 保留点击事件 53 | -keepclassmembers class * extends android.content.Context { 54 | public void *(android.view.View); 55 | public void *(android.view.MenuItem); 56 | } 57 | 58 | -keepclassmembers,allowoptimization enum * { 59 | public static **[] values(); 60 | public static ** valueOf(java.lang.String); 61 | } 62 | 63 | -keepclassmembers class * implements java.io.Serializable { 64 | static final long serialVersionUID; 65 | private static final java.io.ObjectStreamField[] serialPersistentFields; 66 | private void writeObject(java.io.ObjectOutputStream); 67 | private void readObject(java.io.ObjectInputStream); 68 | java.lang.Object writeReplace(); 69 | java.lang.Object readResolve(); 70 | } 71 | 72 | -keepclassmembers class * implements android.os.Parcelable { 73 | static ** CREATOR; 74 | } 75 | 76 | -keepclassmembers class **.R$* { 77 | public static ; 78 | } 79 | 80 | -keepclassmembers class * { 81 | @android.webkit.JavascriptInterface ; 82 | } 83 | 84 | -keepclasseswithmembernames,includedescriptorclasses class * { 85 | native ; 86 | } 87 | -------------------------------------------------------------------------------- /app/release/app-release.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liberuman/ImageloaderManager/743c25107bd70f7b32e009401e9496289840e9be/app/release/app-release.apk -------------------------------------------------------------------------------- /app/release/app-release_no_fresco.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Liberuman/ImageloaderManager/743c25107bd70f7b32e009401e9496289840e9be/app/release/app-release_no_fresco.apk -------------------------------------------------------------------------------- /app/release/output.json: -------------------------------------------------------------------------------- 1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sxu/imageloadermanager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sxu.imageloadermanager; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sxu.imageloadermanager", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/sxu/imageloadermanager/ImageLoaderActivity.java: -------------------------------------------------------------------------------- 1 | package com.sxu.imageloadermanager; 2 | 3 | import android.graphics.Bitmap; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Toast; 8 | 9 | import com.sxu.imageloader.instance.FrescoInstance; 10 | import com.sxu.imageloader.instance.GlideInstance; 11 | import com.sxu.imageloader.ImageLoaderManager; 12 | import com.sxu.imageloader.instance.UILInstance; 13 | import com.sxu.imageloader.WrapImageView; 14 | import com.sxu.imageloader.listener.SimpleImageLoaderListener; 15 | 16 | /** 17 | 18 | * 类或接口的描述信息 19 | * 20 | * @author Freeman 21 | * @date 2017/12/19 22 | */ 23 | 24 | 25 | public class ImageLoaderActivity extends AppCompatActivity { 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_image_loader_layout); 31 | 32 | WrapImageView image = (WrapImageView) findViewById(R.id.image); 33 | WrapImageView blurImage = (WrapImageView) findViewById(R.id.blur_image); 34 | WrapImageView rectangleImage = (WrapImageView) findViewById(R.id.rectangle_image); 35 | WrapImageView circleImage = (WrapImageView) findViewById(R.id.circle_image); 36 | 37 | int type = getIntent().getIntExtra("type", 0); 38 | if (type == 0) { 39 | ImageLoaderManager.getInstance().init(getApplicationContext(), new FrescoInstance()); 40 | } else if (type == 1) { 41 | ImageLoaderManager.getInstance().init(getApplicationContext(), new UILInstance()); 42 | } else if (type == 2) { 43 | ImageLoaderManager.getInstance().init(getApplicationContext(), new GlideInstance()); 44 | } else { 45 | /** 46 | * Nothing 47 | */ 48 | } 49 | 50 | ImageLoaderManager.getInstance().displayImage("http://img5.imgtn.bdimg.com/it/u=3604858831,3357525860&fm=26&gp=0.jpg", image); 51 | ImageLoaderManager.getInstance().displayImage("http://img3.imgtn.bdimg.com/it/u=2942272814,2073526115&fm=26&gp=0.jpg", blurImage); 52 | ImageLoaderManager.getInstance().displayImage("http://img0.imgtn.bdimg.com/it/u=3290825633,1704161465&fm=26&gp=0.jpg", rectangleImage); 53 | ImageLoaderManager.getInstance().displayImage("http://img4.imgtn.bdimg.com/it/u=2408754315,4176997451&fm=26&gp=0.jpg", circleImage); 54 | 55 | findViewById(R.id.download_button).setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | ImageLoaderManager.getInstance().downloadImage(ImageLoaderActivity.this, 59 | "http://img5.imgtn.bdimg.com/it/u=640974225,3115876790&fm=26&gp=0.jpg", 60 | new SimpleImageLoaderListener() { 61 | @Override 62 | public void onCompleted(Bitmap bitmap) { 63 | Toast.makeText(getBaseContext(), "下载成功", Toast.LENGTH_SHORT).show(); 64 | } 65 | 66 | @Override 67 | public void onFailure(Exception e) { 68 | Toast.makeText(getBaseContext(), 69 | "下载失败", Toast.LENGTH_SHORT).show(); 70 | } 71 | }); 72 | } 73 | }); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/com/sxu/imageloadermanager/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.sxu.imageloadermanager; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.RadioGroup; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | private int imageLoaderType; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_main); 17 | 18 | View imageLoaderButton = findViewById(R.id.image_loader_button); 19 | RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radioGroup); 20 | 21 | imageLoaderButton.setOnClickListener(new View.OnClickListener() { 22 | @Override 23 | public void onClick(View v) { 24 | Intent intent = new Intent(getBaseContext(), ImageLoaderActivity.class); 25 | intent.putExtra("type", imageLoaderType); 26 | startActivity(intent); 27 | } 28 | }); 29 | 30 | radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { 31 | @Override 32 | public void onCheckedChanged(RadioGroup group, int checkedId) { 33 | switch (group.getCheckedRadioButtonId()) { 34 | case R.id.fresco_radio: 35 | imageLoaderType = 0; 36 | break; 37 | case R.id.url_radio: 38 | imageLoaderType = 1; 39 | break; 40 | case R.id.glide_radio: 41 | imageLoaderType = 2; 42 | break; 43 | } 44 | } 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/default_placeholder_image.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 11 | 16 | 21 | 26 | 31 | 36 | 41 | 46 | 51 | 56 | 61 | 66 | 71 | 76 | 81 | 86 | 91 | 96 | 101 | 106 | 111 | 116 | 121 | 126 | 131 | 136 | 141 | 146 | 151 | 156 | 161 | 166 | 171 | 172 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_image_loader_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 17 | 29 | 36 | 47 | 58 | 59 |