├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── timg.jpg │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── 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-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── layout_include.xml │ │ │ │ ├── layout_include_merge.xml │ │ │ │ ├── activity_context.xml │ │ │ │ ├── activity_image_optimization.xml │ │ │ │ ├── activity_merge_layout.xml │ │ │ │ ├── view_stub_imageview.xml │ │ │ │ ├── activity_handler.xml │ │ │ │ ├── activity_code_optimization_demo.xml │ │ │ │ ├── activity_electric_quantity_optimization.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_net_work_optimization.xml │ │ │ │ ├── activity_java_four_ways_of_reference.xml │ │ │ │ └── activity_layout_optimization.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── shiming │ │ │ │ └── performanceoptimization │ │ │ │ ├── code_optimization │ │ │ │ ├── MyBroadcaseRecriver.java │ │ │ │ ├── soft_reference │ │ │ │ │ ├── Employee.java │ │ │ │ │ └── EmployeeCache.java │ │ │ │ ├── ContextActivity.java │ │ │ │ ├── SingleInstance.java │ │ │ │ ├── HandlerActivity.java │ │ │ │ ├── JavaFourWaysOfReferenceActivity.java │ │ │ │ └── CodeOptimizationActivity.java │ │ │ │ ├── network_optimization │ │ │ │ ├── NetworkType.java │ │ │ │ ├── NetworkUtils.java │ │ │ │ └── NetWorkOptimizationActivity.java │ │ │ │ ├── MyApplication.java │ │ │ │ ├── layout_Optimization │ │ │ │ ├── MergeLayoutActivity.java │ │ │ │ └── LayoutOptimizationActivity.java │ │ │ │ ├── electric_quantity_optimization │ │ │ │ ├── MyReceiver.java │ │ │ │ ├── CrashHandler.java │ │ │ │ └── ElectricQuantityOptimizationActivity.java │ │ │ │ ├── image_optimization │ │ │ │ └── ImageOptimizationActivity.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── shiming │ │ │ └── performanceoptimization │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── shiming │ │ └── performanceoptimization │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── image ├── 智图.png ├── ~运算符.png ├── .g.png.png ├── 地理的位置.png ├── 地理的位置old.png ├── HashMap的原理.png ├── 微信图片_20180503210246.png ├── 微信图片_20180503210312.png ├── 微信图片_20180503210315.png ├── 微信图片_20180503210319.png ├── 微信图片_20180503210324.png ├── 微信图片_20180503210328.png ├── 微信图片_20180503210331.png ├── 微信图片_20180503210334.png ├── 微信图片_20180503210337.png ├── 微信图片_20180503210342.png ├── 微信图片_20180503210345.png ├── 微信图片_20180503210427.png ├── 微信图片_201805032104271.png ├── 微信图片_2018050321042710.png ├── 微信图片_2018050321042711.png ├── 微信图片_2018050321042712.png ├── 微信图片_2018050321042713.png ├── 微信图片_2018050321042714.png ├── 微信图片_2018050321042715.png ├── 微信图片_2018050321042716.png ├── 微信图片_2018050321042717.png ├── 微信图片_2018050321042718.png ├── 微信图片_2018050321042719.png ├── 微信图片_201805032104272.png ├── 微信图片_2018050321042720.png ├── 微信图片_2018050321042721.png ├── 微信图片_2018050321042722.png ├── 微信图片_2018050321042723.png ├── 微信图片_2018050321042724.png ├── 微信图片_2018050321042725.png ├── 微信图片_2018050321042726.png ├── 微信图片_2018050321042727.png ├── 微信图片_2018050321042728.png ├── 微信图片_2018050321042729.png ├── 微信图片_201805032104273.png ├── 微信图片_2018050321042730.png ├── 微信图片_2018050321042731.png ├── 微信图片_2018050321042732.png ├── 微信图片_2018050321042733.png ├── 微信图片_2018050321042734.png ├── 微信图片_2018050321042735.png ├── 微信图片_2018050321042736.png ├── 微信图片_2018050321042737.png ├── 微信图片_2018050321042738.png ├── 微信图片_201805032104274.png ├── 微信图片_201805032104275.png ├── 微信图片_201805032104276.png ├── 微信图片_201805032104277.png ├── 微信图片_201805032104278.png └── 微信图片_201805032104279.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── .idea ├── vcs.xml ├── modules.xml ├── gradle.xml └── misc.xml ├── android └── location │ └── annotations.xml ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /image/智图.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/智图.png -------------------------------------------------------------------------------- /image/~运算符.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/~运算符.png -------------------------------------------------------------------------------- /image/.g.png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/.g.png.png -------------------------------------------------------------------------------- /image/地理的位置.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/地理的位置.png -------------------------------------------------------------------------------- /image/地理的位置old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/地理的位置old.png -------------------------------------------------------------------------------- /image/HashMap的原理.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/HashMap的原理.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | OptimizationAndroid 3 | 4 | -------------------------------------------------------------------------------- /image/微信图片_20180503210246.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210246.png -------------------------------------------------------------------------------- /image/微信图片_20180503210312.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210312.png -------------------------------------------------------------------------------- /image/微信图片_20180503210315.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210315.png -------------------------------------------------------------------------------- /image/微信图片_20180503210319.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210319.png -------------------------------------------------------------------------------- /image/微信图片_20180503210324.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210324.png -------------------------------------------------------------------------------- /image/微信图片_20180503210328.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210328.png -------------------------------------------------------------------------------- /image/微信图片_20180503210331.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210331.png -------------------------------------------------------------------------------- /image/微信图片_20180503210334.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210334.png -------------------------------------------------------------------------------- /image/微信图片_20180503210337.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210337.png -------------------------------------------------------------------------------- /image/微信图片_20180503210342.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210342.png -------------------------------------------------------------------------------- /image/微信图片_20180503210345.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210345.png -------------------------------------------------------------------------------- /image/微信图片_20180503210427.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_20180503210427.png -------------------------------------------------------------------------------- /image/微信图片_201805032104271.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104271.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042710.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042710.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042711.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042711.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042712.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042712.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042713.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042713.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042714.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042714.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042715.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042715.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042716.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042716.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042717.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042717.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042718.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042718.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042719.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042719.png -------------------------------------------------------------------------------- /image/微信图片_201805032104272.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104272.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042720.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042720.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042721.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042721.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042722.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042722.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042723.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042723.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042724.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042724.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042725.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042725.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042726.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042726.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042727.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042727.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042728.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042728.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042729.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042729.png -------------------------------------------------------------------------------- /image/微信图片_201805032104273.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104273.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042730.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042730.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042731.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042731.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042732.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042732.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042733.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042733.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042734.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042734.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042735.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042735.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042736.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042736.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042737.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042737.png -------------------------------------------------------------------------------- /image/微信图片_2018050321042738.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_2018050321042738.png -------------------------------------------------------------------------------- /image/微信图片_201805032104274.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104274.png -------------------------------------------------------------------------------- /image/微信图片_201805032104275.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104275.png -------------------------------------------------------------------------------- /image/微信图片_201805032104276.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104276.png -------------------------------------------------------------------------------- /image/微信图片_201805032104277.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104277.png -------------------------------------------------------------------------------- /image/微信图片_201805032104278.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104278.png -------------------------------------------------------------------------------- /image/微信图片_201805032104279.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/image/微信图片_201805032104279.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/timg.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.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/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Shimingli/PerformanceOptimizationForAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri May 04 14:38:52 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 | -------------------------------------------------------------------------------- /android/location/annotations.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_include.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_include_merge.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_context.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/shiming/performanceoptimization/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization; 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 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/code_optimization/MyBroadcaseRecriver.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.code_optimization; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | /** 8 | * author: Created by shiming on 2018/4/28 16:21 9 | * mailbox:lamshiming@sina.com 10 | */ 11 | 12 | public class MyBroadcaseRecriver extends BroadcastReceiver { 13 | /** 14 | * 15 | * @param context 第三类的context 16 | * @param intent 17 | */ 18 | @Override 19 | public void onReceive(Context context, Intent intent) { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_image_optimization.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_merge_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/network_optimization/NetworkType.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.network_optimization; 2 | 3 | /** 4 | * author: Created by shiming on 2018/4/28 10:52 5 | * mailbox:lamshiming@sina.com 6 | * des:网络连接类型常量 7 | */ 8 | 9 | public class NetworkType { 10 | /** 11 | * 无网络连接 12 | */ 13 | public static final int TYPE_UNKNOWN = -1; 14 | /** 15 | * 2G 16 | */ 17 | public static final int TYPE_2G = 0; 18 | /** 19 | * 3G 20 | */ 21 | public static final int TYPE_3G = 1; 22 | /** 23 | * 4G 24 | */ 25 | public static final int TYPE_4G = 2; 26 | /** 27 | * WIFI 28 | */ 29 | public static final int TYPE_WIFI = 3; 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/MyApplication.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization; 2 | 3 | import android.app.Application; 4 | 5 | import com.shiming.performanceoptimization.electric_quantity_optimization.CrashHandler; 6 | 7 | /** 8 | * author: Created by shiming on 2018/5/3 14:48 9 | * mailbox:lamshiming@sina.com 10 | */ 11 | 12 | public class MyApplication extends Application { 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | /** 17 | * 程序会重新启动,如果点击电量优化,App崩溃了,请给与全部权限, 18 | * 还要在开发者模式里面给与位置信息模拟的设置,如果崩溃了, 19 | * 你也可以发现app会自动的重新启动,这是AlarmManager的应用,注意看MyApplication里面的代码,tks 20 | */ 21 | CrashHandler.getInstance().initCrashHandler(this); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | android.enableAapt2=false 15 | sdk.dir=sdk -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/layout_Optimization/MergeLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.layout_Optimization; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | 6 | import com.shiming.performanceoptimization.R; 7 | 8 | /** 9 | * merge 标签 在某些场景下可以减少布局的层次,由于所有的Activity的根布局都是fragment DecorView PhoneWindow 事件的传递,包括设置setContentView 等的方法---> 我会写一篇文章独立解释安卓事件的源码解析,会更加清楚的介绍这个类,所以,当独立的一个布局文件最外层是FrameLayout的时候,并且和这个布局不需要设置 background 或者 padding的时候,可以使用标签来代替FrameLayout布局。另外一种的情况可以使用《merge》便签的情况是当前布局作为另外一个布局的子布局 10 | */ 11 | public class MergeLayoutActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_merge_layout); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/code_optimization/soft_reference/Employee.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.code_optimization.soft_reference; 2 | 3 | /** 4 | * author: Created by shiming on 2018/5/2 14:49 5 | * mailbox:lamshiming@sina.com 6 | */ 7 | 8 | public class Employee { 9 | private String id;// 雇员的标识号码 10 | private String name;// 雇员姓名 11 | private String department;// 该雇员所在部门 12 | private String Phone;// 该雇员联系电话 13 | private int salary;// 该雇员薪资 14 | private String origin;// 该雇员信息的来源 15 | 16 | // 构造方法 17 | public Employee(String id) { 18 | this.id = id; 19 | getDataFromlnfoCenter(); 20 | } 21 | // 到数据库中取得雇员信息 22 | private void getDataFromlnfoCenter() { 23 | // 和数据库建立连接井查询该雇员的信息,将查询结果赋值 24 | // 给name,department,plone,salary等变量 25 | // 同时将origin赋值为"From DataBase" 26 | } 27 | 28 | public String getID() { 29 | return id; 30 | } 31 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/view_stub_imageview.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 12 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/shiming/performanceoptimization/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization; 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.shiming.performanceoptimization", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/electric_quantity_optimization/MyReceiver.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.electric_quantity_optimization; 2 | 3 | import android.app.Activity; 4 | import android.content.BroadcastReceiver; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.widget.Toast; 8 | 9 | 10 | 11 | /** 12 | * author: Created by shiming on 2018/5/3 14:28 13 | * mailbox:lamshiming@sina.com 14 | */ 15 | public class MyReceiver extends BroadcastReceiver { 16 | @Override 17 | public void onReceive(Context context, Intent intent) { 18 | 19 | String msg = intent.getStringExtra("msg"); 20 | System.out.println("shiming " + msg) ; 21 | Toast.makeText(context,msg,Toast.LENGTH_SHORT).show(); 22 | 23 | // ElectricQuantityOptimizationActivity context1 = (ElectricQuantityOptimizationActivity) context; 24 | // context1.startActivity(intent); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_handler.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "27.0.3" 6 | defaultConfig { 7 | applicationId "com.shiming.performanceoptimization" 8 | minSdkVersion 15 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:26.1.0' 25 | compile 'com.android.support.constraint:constraint-layout:1.1.0' 26 | testCompile 'junit:junit:4.12' 27 | androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', { 28 | exclude group: 'com.android.support', module: 'support-annotations' 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/code_optimization/ContextActivity.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.code_optimization; 2 | 3 | import android.app.Application; 4 | import android.content.ContentProvider; 5 | import android.content.Context; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.os.Bundle; 8 | 9 | import com.shiming.performanceoptimization.R; 10 | /** 11 | * author: Created by shiming on 2018/4/28 10:52 12 | * mailbox:lamshiming@sina.com 13 | */ 14 | public class ContextActivity extends AppCompatActivity { 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_context); 20 | 21 | //Context的种类 22 | //Application 全局唯一的Context实例 23 | Application application = getApplication(); 24 | Context applicationContext = application.getApplicationContext(); 25 | //不同的Activity,得到这个Context,是独立的,不会进行复用 26 | Context baseContext = this.getBaseContext(); 27 | 28 | MyBroadcaseRecriver myBroadcaseRecriver = new MyBroadcaseRecriver(); 29 | 30 | //ContentProvider 中的Context 31 | 32 | /** 33 | *如果创建单利必须需要使用到context对象 34 | */ 35 | //这样不会内存泄露,不用改动单利类中代码 36 | SingleInstance.getSingleInstance(getApplication().getApplicationContext()); 37 | 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/shiming/performanceoptimization/code_optimization/SingleInstance.java: -------------------------------------------------------------------------------- 1 | package com.shiming.performanceoptimization.code_optimization; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * author: Created by shiming on 2018/4/28 16:36 7 | * mailbox:lamshiming@sina.com 8 | * 单例模式,如果不得不传入Context,由于单例一直存在会导致Activity或者是Service的单例引用,从而不会被垃圾回收, 9 | * Activity中的关联的View和数据结构也不会被释放,正确的方式应该使用Application中的Context 10 | */ 11 | 12 | class SingleInstance { 13 | // 这才是 标准的一个 单利模式 14 | private static volatile SingleInstance sSingleInstance; 15 | private final Context mContext; 16 | 17 | private SingleInstance(Context context){ 18 | mContext = context; 19 | } 20 | // 因为每次调用实例都需要判断同步锁,很多项目包括很多人都是用这种的 21 | // 双重判断校验的方法,这种的方法看似很完美的解决了效率的问题,但是它 22 | // 在并发量不多,安全性不太高的情况下能完美的运行,但是, 23 | // 在jvm编译的过程中会出现指令重排的优化过程,这就会导致singleton实际上 24 | // 没有被初始化,就分配了内存空间,也就是说singleton!=null但是又没有被初始化, 25 | // 这就会导致返回的singletonthird返回的是不完整的 26 | public static SingleInstance getSingleInstance(Context context){ 27 | if (sSingleInstance==null){ 28 | synchronized (SingleInstance.class){ 29 | if (sSingleInstance==null) { 30 | // TODO: 2018/4/28 注意外面传入的conext对象是否,是哪个 31 | sSingleInstance= new SingleInstance(context); 32 | //第二种是改动代码,使用application 中的context变量 33 | sSingleInstance= new SingleInstance(context.getApplicationContext()); 34 | 35 | } 36 | } 37 | 38 | } 39 | return sSingleInstance; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_code_optimization_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 17 | 18 |