├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── drawable │ │ │ │ ├── splash.png │ │ │ │ ├── divider.xml │ │ │ │ └── divider_bg.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── anim │ │ │ │ ├── hold.xml │ │ │ │ ├── right_in.xml │ │ │ │ └── right_out.xml │ │ │ ├── layout │ │ │ │ ├── activity_splash.xml │ │ │ │ └── activity_main.xml │ │ │ └── values-w820dp │ │ │ │ └── dimens.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── acmenxd │ │ │ └── frescoview │ │ │ └── demo │ │ │ ├── SplashActivity.java │ │ │ ├── BaseApplication.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── acmenxd │ │ │ └── frescoview │ │ │ └── demo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── acmenxd │ │ └── frescoview │ │ └── demo │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── frescoview ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── acmenxd │ │ │ └── frescoview │ │ │ ├── FrescoUtils.java │ │ │ ├── FrescoCallback.java │ │ │ ├── FrescoViewDoc.java │ │ │ ├── FrescoManager.java │ │ │ └── FrescoView.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── acmenxd │ │ │ └── frescoview │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── acmenxd │ │ └── frescoview │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── pic └── 1.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── config.gradle ├── .gitignore ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /frescoview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':frescoview' 2 | -------------------------------------------------------------------------------- /pic/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/pic/1.jpg -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FrescoView 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/drawable/splash.png -------------------------------------------------------------------------------- /frescoview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | frescoview 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AcmenXD/FrescoView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /frescoview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/anim/hold.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jun 14 10:26:59 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/anim/right_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/anim/right_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/acmenxd/frescoview/demo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview.demo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /frescoview/src/test/java/com/acmenxd/frescoview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /frescoview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /frescoview/src/main/java/com/acmenxd/frescoview/FrescoUtils.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | /** 6 | * @author AcmenXD 7 | * @version v1.0 8 | * @github https://github.com/AcmenXD 9 | * @date 2018/5/22 17:47 10 | * @detail Fresco工具类 11 | */ 12 | public class FrescoUtils { 13 | /** 14 | * 串拼接 15 | * 16 | * @param strs 可变参数类型 17 | * @return 拼接后的字符串 18 | */ 19 | public static String appendStrs(@NonNull Object... strs) { 20 | StringBuilder sb = new StringBuilder(); 21 | if (strs != null && strs.length > 0) { 22 | for (Object str : strs) { 23 | sb.append(String.valueOf(str)); 24 | } 25 | } 26 | return sb.toString(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def config = rootProject.ext 4 | 5 | android { 6 | compileSdkVersion config.compileSdkVersion 7 | buildToolsVersion config.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion config.minSdkVersion 10 | targetSdkVersion config.targetSdkVersion 11 | applicationId "com.acmenxd.frescoview.demo" 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile config.frescoview 26 | // compile project(':frescoview') 27 | } 28 | -------------------------------------------------------------------------------- /frescoview/src/androidTest/java/com/acmenxd/frescoview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview; 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 | * Instrumentation 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.acmenxd.frescoview.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/acmenxd/frescoview/demo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview.demo; 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 | * Instrumentation 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.acmenxd.frescoview.demo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /frescoview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | def config = rootProject.ext 4 | 5 | android { 6 | compileSdkVersion config.compileSdkVersion 7 | buildToolsVersion config.buildToolsVersion 8 | defaultConfig { 9 | minSdkVersion config.minSdkVersion 10 | targetSdkVersion config.targetSdkVersion 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | dependencies { 23 | compile config.system.appcompatV7 24 | compile config.fresco.fresco 25 | compile config.fresco.fresco_okhttp3 26 | compile config.fresco.fresco_gif 27 | compile config.fresco.fresco_webp 28 | // compile config.fresco.fresco_support 29 | // compile config.fresco.fresco_webpsupport 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /config.gradle: -------------------------------------------------------------------------------- 1 | /** 2 | * build.gradle Module统一配置 3 | */ 4 | ext { 5 | compileSdkVersion = 26 6 | buildToolsVersion = "27.0.3" 7 | minSdkVersion = 14 8 | targetSdkVersion = 26 9 | 10 | // 图片加载库 11 | frescoview = "com.github.AcmenXD:FrescoView:3.0" 12 | 13 | // 系统库 14 | system = [ 15 | appcompatV7 : "com.android.support:appcompat-v7:26.1.0", 16 | ] 17 | 18 | fresco = [ 19 | // facebook推出的图片处理库 20 | fresco : "com.facebook.fresco:fresco:1.0.1", 21 | // 支持okhttp3网络库请求 22 | fresco_okhttp3 : "com.facebook.fresco:imagepipeline-okhttp3:1.0.1", 23 | // 支持gif时需要添加 24 | fresco_gif : "com.facebook.fresco:animated-gif:1.0.1", 25 | // 支持 WebP (静态图+动图),需要添加 26 | fresco_webp : "com.facebook.fresco:animated-webp:1.0.1", 27 | // 在 API < 14(4.0) 上的机器支持 WebP 时,需要添加 28 | fresco_support : "com.facebook.fresco:animated-base-support:1.0.1", 29 | // 支持 WebP 静态图,需要添加 30 | fresco_webpsupport: "com.facebook.fresco:webpsupport:1.0.1", 31 | ] 32 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | .idea/.name 45 | .idea/encodings.xml 46 | .idea/inspectionProfiles/Project_Default.xml 47 | .idea/inspectionProfiles/profiles_settings.xml 48 | .idea/misc.xml 49 | .idea/modules.xml 50 | .idea/scopes/scope_settings.xml 51 | .idea/vcs.xml 52 | .idea/* 53 | 54 | # Keystore files 55 | # Uncomment the following line if you do not want to check your keystore files in. 56 | #*.jks 57 | 58 | # External native build folder generated in Android Studio 2.2 and later 59 | .externalNativeBuild 60 | 61 | # Google Services (e.g. APIs or Firebase) 62 | google-services.json 63 | 64 | # Freeline 65 | freeline.py 66 | freeline/ 67 | freeline_project_description.json 68 | 69 | # fastlane 70 | fastlane/report.xml 71 | fastlane/Preview.html 72 | fastlane/screenshots 73 | fastlane/test_output 74 | fastlane/readme.md -------------------------------------------------------------------------------- /app/src/main/java/com/acmenxd/frescoview/demo/SplashActivity.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview.demo; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.util.Log; 8 | 9 | /** 10 | * @author AcmenXD 11 | * @version v1.0 12 | * @github https://github.com/AcmenXD 13 | * @date 2017/3/31 14:02 14 | * @detail something 15 | */ 16 | public class SplashActivity extends AppCompatActivity { 17 | private Handler mHandler; 18 | private int duration = 2000; 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_splash); 24 | Log.w("AcmenXD","App进入SplashActivity!"); 25 | 26 | long time = 0; 27 | if (BaseApplication.instance().startTime > 0) { 28 | time = System.currentTimeMillis() - BaseApplication.instance().startTime; 29 | BaseApplication.instance().startTime = 0; 30 | } 31 | if (time > duration) { 32 | startNextActivity(); 33 | } else { 34 | mHandler = new Handler(); 35 | mHandler.postDelayed(new Runnable() { 36 | @Override 37 | public void run() { 38 | startNextActivity(); 39 | } 40 | }, duration - time); 41 | } 42 | } 43 | 44 | /** 45 | * 启动下个Activity 46 | */ 47 | private void startNextActivity() { 48 | startActivity(new Intent(SplashActivity.this, MainActivity.class)); 49 | finish(); 50 | } 51 | 52 | @Override 53 | protected void onDestroy() { 54 | super.onDestroy(); 55 | if (mHandler != null) { 56 | mHandler.removeCallbacksAndMessages(null); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 19 | 20 | 24 | 25 | 39 | 40 | -------------------------------------------------------------------------------- /frescoview/src/main/java/com/acmenxd/frescoview/FrescoCallback.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview; 2 | 3 | import android.graphics.drawable.Animatable; 4 | import android.support.annotation.NonNull; 5 | 6 | import com.facebook.drawee.controller.BaseControllerListener; 7 | import com.facebook.imagepipeline.image.ImageInfo; 8 | 9 | /** 10 | * @author AcmenXD 11 | * @version v1.0 12 | * @github https://github.com/AcmenXD 13 | * @date 2017/1/22 10:31 14 | * @detail 图片加载回调 15 | */ 16 | public abstract class FrescoCallback extends BaseControllerListener { 17 | @Override 18 | public final void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { 19 | super.onFinalImageSet(id, imageInfo, animatable); 20 | succeed(id, imageInfo, animatable); 21 | } 22 | 23 | @Override 24 | public final void onFailure(String id, Throwable throwable) { 25 | super.onFailure(id, throwable); 26 | failed(id, throwable); 27 | } 28 | 29 | @Override 30 | public final void onIntermediateImageSet(String id, ImageInfo imageInfo) { 31 | super.onIntermediateImageSet(id, imageInfo); 32 | //如果允许呈现渐进式JPEG,同时图片也是渐进式图片,onIntermediateImageSet会在每个扫描被解码后回调 33 | } 34 | 35 | @Override 36 | public final void onIntermediateImageFailed(String id, Throwable throwable) { 37 | super.onIntermediateImageFailed(id, throwable); 38 | } 39 | 40 | @Override 41 | public final void onRelease(String id) { 42 | super.onRelease(id); 43 | } 44 | 45 | @Override 46 | public final void onSubmit(String id, Object callerContext) { 47 | super.onSubmit(id, callerContext); 48 | } 49 | 50 | /** 51 | * 请求成功被回调 52 | * * 非必须重写函数,如需要进行重写 53 | * 54 | * @param id : 图片的id值 55 | * @param imageInfo : 图片的一些信息,如尺寸等 56 | * @param animatable : 此参数用来操作相关动画,如gif|webp等动画格式 57 | */ 58 | public void succeed(@NonNull String id, @NonNull ImageInfo imageInfo, @NonNull Animatable animatable) { 59 | 60 | } 61 | 62 | /** 63 | * 请求失败被回调 64 | * * 非必须重写函数,如需要进行重写 65 | * 66 | * @param id : 图片的id值 67 | * @param throwable : 错误信息 68 | */ 69 | public void failed(@NonNull String id, @NonNull Throwable throwable) { 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/src/main/java/com/acmenxd/frescoview/demo/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.acmenxd.frescoview.demo; 2 | 3 | import android.app.Application; 4 | import android.content.res.Configuration; 5 | import android.os.Environment; 6 | import android.util.Log; 7 | 8 | import com.acmenxd.frescoview.FrescoManager; 9 | 10 | /** 11 | * @author AcmenXD 12 | * @version v1.0 13 | * @github https://github.com/AcmenXD 14 | * @date 2016/11/22 14:36 15 | * @detail 顶级Application 16 | */ 17 | public final class BaseApplication extends Application { 18 | protected final String TAG = this.getClass().getSimpleName(); 19 | 20 | private static BaseApplication sInstance = null; 21 | // 初始化状态 -> 默认false,初始化完成为true 22 | public boolean isInitFinish = false; 23 | // 记录启动时间 24 | public long startTime = 0; 25 | 26 | public BaseApplication() { 27 | super(); 28 | sInstance = this; 29 | } 30 | 31 | public static synchronized BaseApplication instance() { 32 | if (sInstance == null) { 33 | new RuntimeException("BaseApplication == null ?? you should extends BaseApplication in you app"); 34 | } 35 | return sInstance; 36 | } 37 | 38 | @Override 39 | public void onCreate() { 40 | super.onCreate(); 41 | startTime = System.currentTimeMillis(); 42 | /** 43 | * 配置FrescoView 44 | */ 45 | FrescoManager.LOG_OPEN = true; 46 | FrescoManager.LOG_LEVEL = Log.VERBOSE; 47 | FrescoManager.IMAGE_CACHE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/FrescoView/"; 48 | FrescoManager.MAIN_CACHE_DIR = "MainCache"; 49 | FrescoManager.SMALL_CACHE_DIR = "SmallCache"; 50 | FrescoManager.MAX_DISK_CACHE_SIZE = 50; 51 | FrescoManager.MAX_SMALL_DISK_LOW_CACHE_SIZE = 20; 52 | FrescoManager.init(this); 53 | // 初始化完毕 54 | isInitFinish = true; 55 | } 56 | 57 | @Override 58 | public void onTerminate() { 59 | // 程序终止的时候执行 60 | super.onTerminate(); 61 | } 62 | 63 | @Override 64 | public void onLowMemory() { 65 | // 低内存的时候执行 66 | super.onLowMemory(); 67 | } 68 | 69 | @Override 70 | public void onTrimMemory(int level) { 71 | // 程序在内存清理的时候执行 72 | super.onTrimMemory(level); 73 | } 74 | 75 | @Override 76 | public void onConfigurationChanged(Configuration newConfig) { 77 | // 应用配置变更~ 78 | super.onConfigurationChanged(newConfig); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 |