From da0c0d1ad1946d1414dfc084591adff189186908 Mon Sep 17 00:00:00 2001 From: renpengfei Date: Wed, 19 May 2021 10:22:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96GlideBitmapPool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 10 +- README.md | 125 ++-- app/build.gradle | 44 -- app/proguard-rules.pro | 17 - .../com/glidebitmappool/ApplicationTest.java | 30 - .../ApplicationTest.java | 30 - app/src/main/AndroidManifest.xml | 39 - .../glidebitmappoolsample/MainActivity.java | 157 ---- app/src/main/res/layout/activity_main.xml | 67 -- app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 3418 -> 0 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 2206 -> 0 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 4842 -> 0 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 7718 -> 0 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 10486 -> 0 bytes app/src/main/res/values-w820dp/dimens.xml | 23 - app/src/main/res/values/colors.xml | 23 - app/src/main/res/values/dimens.xml | 22 - app/src/main/res/values/strings.xml | 20 - app/src/main/res/values/styles.xml | 28 - .../com/glidebitmappool/ExampleUnitTest.java | 32 - assets/gcsamplelog.png | Bin 47656 -> 0 bytes assets/glidebitmappool.png | Bin 105377 -> 0 bytes build.gradle | 48 +- changeLog.md | 11 + {app => entry}/.gitignore | 0 entry/build.gradle | 13 + entry/src/main/config.json | 71 ++ .../com/glidebitmappoolsample/Constants.java | 65 ++ .../glidebitmappoolsample/MainAbility.java | 114 +++ .../glidebitmappoolsample/MyApplication.java | 35 + .../slice/MainAbilitySlice.java | 258 +++++++ .../glidebitmappoolsample/util/FileUtils.java | 142 ++++ .../main/resources/base/element/string.json | 28 + .../base/graphic/background_ability_main.xml | 6 + .../base/graphic/background_button.xml | 6 + .../resources/base/layout/ability_main.xml | 66 ++ entry/src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../src/main/resources/base/media}/test1.png | Bin .../src/main/resources/base/media}/test10.png | Bin .../src/main/resources/base/media}/test11.png | Bin .../src/main/resources/base/media}/test12.png | Bin .../src/main/resources/base/media}/test13.png | Bin .../src/main/resources/base/media}/test14.png | Bin .../src/main/resources/base/media}/test15.png | Bin .../src/main/resources/base/media}/test16.png | Bin .../src/main/resources/base/media}/test17.png | Bin .../src/main/resources/base/media}/test18.png | Bin .../src/main/resources/base/media}/test19.png | Bin .../src/main/resources/base/media}/test2.png | Bin .../src/main/resources/base/media}/test20.png | Bin .../src/main/resources/base/media}/test3.png | Bin .../src/main/resources/base/media}/test4.png | Bin .../src/main/resources/base/media}/test5.png | Bin .../src/main/resources/base/media}/test6.png | Bin .../src/main/resources/base/media}/test7.png | Bin .../src/main/resources/base/media}/test8.png | Bin .../src/main/resources/base/media}/test9.png | Bin entry/src/main/resources/rawfile/icon.png | Bin 0 -> 6790 bytes entry/src/main/resources/rawfile/test1.png | Bin 0 -> 4227 bytes entry/src/main/resources/rawfile/test10.png | Bin 0 -> 1066 bytes entry/src/main/resources/rawfile/test11.png | Bin 0 -> 970 bytes entry/src/main/resources/rawfile/test12.png | Bin 0 -> 972 bytes entry/src/main/resources/rawfile/test13.png | Bin 0 -> 1766 bytes entry/src/main/resources/rawfile/test14.png | Bin 0 -> 1117 bytes entry/src/main/resources/rawfile/test15.png | Bin 0 -> 5491 bytes entry/src/main/resources/rawfile/test16.png | Bin 0 -> 4837 bytes entry/src/main/resources/rawfile/test17.png | Bin 0 -> 3701 bytes entry/src/main/resources/rawfile/test18.png | Bin 0 -> 4817 bytes entry/src/main/resources/rawfile/test19.png | Bin 0 -> 3891 bytes entry/src/main/resources/rawfile/test2.png | Bin 0 -> 3349 bytes entry/src/main/resources/rawfile/test20.png | Bin 0 -> 3390 bytes entry/src/main/resources/rawfile/test3.png | Bin 0 -> 859 bytes entry/src/main/resources/rawfile/test4.png | Bin 0 -> 871 bytes entry/src/main/resources/rawfile/test5.png | Bin 0 -> 1012 bytes entry/src/main/resources/rawfile/test6.png | Bin 0 -> 1129 bytes entry/src/main/resources/rawfile/test7.png | Bin 0 -> 1115 bytes entry/src/main/resources/rawfile/test8.png | Bin 0 -> 1154 bytes entry/src/main/resources/rawfile/test9.png | Bin 0 -> 1096 bytes .../glidebitmappoolsample/ExampleTest.java | 9 + glide-bitmap-pool/build.gradle | 42 -- glide-bitmap-pool/proguard-rules.pro | 17 - .../src/main/AndroidManifest.xml | 25 - .../glidebitmappool/GlideBitmapFactory.java | 406 ----------- .../glidebitmappool/internal/BitmapPool.java | 41 -- .../internal/LruPoolStrategy.java | 37 - .../glidebitmappool/internal/Poolable.java | 26 - .../com/glidebitmappool/internal/Util.java | 138 ---- .../src/main/res/values/strings.xml | 20 - .../com/glidebitmappool/ExampleUnitTest.java | 32 - glide-bitmap-pool/upload.gradle | 101 --- .../.gitignore | 0 glide_bitmap_pool/build.gradle | 13 + glide_bitmap_pool/src/main/config.json | 27 + .../glidebitmappool/GlideBitmapFactory.java | 671 ++++++++++++++++++ .../com/glidebitmappool/GlideBitmapPool.java | 117 +-- .../internal/AttributeStrategy.java | 142 ++-- .../glidebitmappool/internal/BaseKeyPool.java | 41 +- .../glidebitmappool/internal/BitmapPool.java | 66 ++ .../internal/BitmapPoolAdapter.java | 39 +- .../internal/GroupedLinkedMap.java | 105 ++- .../internal/LruBitmapPool.java | 249 ++++--- .../internal/LruPoolStrategy.java | 62 ++ .../glidebitmappool/internal/Poolable.java | 15 + .../internal/SizeConfigStrategy.java | 226 +++--- .../com/glidebitmappool/internal/Util.java | 179 +++++ .../main/resources/base/element/string.json | 8 + gradle.properties | 31 +- gradle/wrapper/gradle-wrapper.jar | Bin 53636 -> 58694 bytes gradle/wrapper/gradle-wrapper.properties | 20 +- gradlew | 109 +-- gradlew.bat | 33 +- settings.gradle | 19 +- 112 files changed, 2608 insertions(+), 1988 deletions(-) delete mode 100644 app/build.gradle delete mode 100644 app/proguard-rules.pro delete mode 100644 app/src/androidTest/java/com/glidebitmappool/ApplicationTest.java delete mode 100644 app/src/androidTest/java/com/glidebitmappoolsample/ApplicationTest.java delete mode 100644 app/src/main/AndroidManifest.xml delete mode 100644 app/src/main/java/com/glidebitmappoolsample/MainActivity.java delete mode 100644 app/src/main/res/layout/activity_main.xml delete mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png delete mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png delete mode 100644 app/src/main/res/values-w820dp/dimens.xml delete mode 100644 app/src/main/res/values/colors.xml delete mode 100644 app/src/main/res/values/dimens.xml delete mode 100644 app/src/main/res/values/strings.xml delete mode 100644 app/src/main/res/values/styles.xml delete mode 100644 app/src/test/java/com/glidebitmappool/ExampleUnitTest.java delete mode 100644 assets/gcsamplelog.png delete mode 100644 assets/glidebitmappool.png create mode 100644 changeLog.md rename {app => entry}/.gitignore (100%) create mode 100644 entry/build.gradle create mode 100644 entry/src/main/config.json create mode 100644 entry/src/main/java/com/glidebitmappoolsample/Constants.java create mode 100644 entry/src/main/java/com/glidebitmappoolsample/MainAbility.java create mode 100644 entry/src/main/java/com/glidebitmappoolsample/MyApplication.java create mode 100644 entry/src/main/java/com/glidebitmappoolsample/slice/MainAbilitySlice.java create mode 100644 entry/src/main/java/com/glidebitmappoolsample/util/FileUtils.java create mode 100644 entry/src/main/resources/base/element/string.json create mode 100644 entry/src/main/resources/base/graphic/background_ability_main.xml create mode 100644 entry/src/main/resources/base/graphic/background_button.xml create mode 100644 entry/src/main/resources/base/layout/ability_main.xml create mode 100644 entry/src/main/resources/base/media/icon.png rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test1.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test10.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test11.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test12.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test13.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test14.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test15.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test16.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test17.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test18.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test19.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test2.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test20.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test3.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test4.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test5.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test6.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test7.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test8.png (100%) mode change 100755 => 100644 rename {app/src/main/res/drawable => entry/src/main/resources/base/media}/test9.png (100%) mode change 100755 => 100644 create mode 100644 entry/src/main/resources/rawfile/icon.png create mode 100644 entry/src/main/resources/rawfile/test1.png create mode 100644 entry/src/main/resources/rawfile/test10.png create mode 100644 entry/src/main/resources/rawfile/test11.png create mode 100644 entry/src/main/resources/rawfile/test12.png create mode 100644 entry/src/main/resources/rawfile/test13.png create mode 100644 entry/src/main/resources/rawfile/test14.png create mode 100644 entry/src/main/resources/rawfile/test15.png create mode 100644 entry/src/main/resources/rawfile/test16.png create mode 100644 entry/src/main/resources/rawfile/test17.png create mode 100644 entry/src/main/resources/rawfile/test18.png create mode 100644 entry/src/main/resources/rawfile/test19.png create mode 100644 entry/src/main/resources/rawfile/test2.png create mode 100644 entry/src/main/resources/rawfile/test20.png create mode 100644 entry/src/main/resources/rawfile/test3.png create mode 100644 entry/src/main/resources/rawfile/test4.png create mode 100644 entry/src/main/resources/rawfile/test5.png create mode 100644 entry/src/main/resources/rawfile/test6.png create mode 100644 entry/src/main/resources/rawfile/test7.png create mode 100644 entry/src/main/resources/rawfile/test8.png create mode 100644 entry/src/main/resources/rawfile/test9.png create mode 100644 entry/src/test/java/com/glidebitmappoolsample/ExampleTest.java delete mode 100644 glide-bitmap-pool/build.gradle delete mode 100644 glide-bitmap-pool/proguard-rules.pro delete mode 100644 glide-bitmap-pool/src/main/AndroidManifest.xml delete mode 100644 glide-bitmap-pool/src/main/java/com/glidebitmappool/GlideBitmapFactory.java delete mode 100644 glide-bitmap-pool/src/main/java/com/glidebitmappool/internal/BitmapPool.java delete mode 100644 glide-bitmap-pool/src/main/java/com/glidebitmappool/internal/LruPoolStrategy.java delete mode 100644 glide-bitmap-pool/src/main/java/com/glidebitmappool/internal/Poolable.java delete mode 100644 glide-bitmap-pool/src/main/java/com/glidebitmappool/internal/Util.java delete mode 100644 glide-bitmap-pool/src/main/res/values/strings.xml delete mode 100644 glide-bitmap-pool/src/test/java/com/glidebitmappool/ExampleUnitTest.java delete mode 100755 glide-bitmap-pool/upload.gradle rename {glide-bitmap-pool => glide_bitmap_pool}/.gitignore (100%) create mode 100644 glide_bitmap_pool/build.gradle create mode 100644 glide_bitmap_pool/src/main/config.json create mode 100644 glide_bitmap_pool/src/main/java/com/glidebitmappool/GlideBitmapFactory.java rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/GlideBitmapPool.java (45%) rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/AttributeStrategy.java (42%) rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/BaseKeyPool.java (43%) create mode 100644 glide_bitmap_pool/src/main/java/com/glidebitmappool/internal/BitmapPool.java rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/BitmapPoolAdapter.java (35%) rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/GroupedLinkedMap.java (66%) rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/LruBitmapPool.java (41%) create mode 100644 glide_bitmap_pool/src/main/java/com/glidebitmappool/internal/LruPoolStrategy.java create mode 100644 glide_bitmap_pool/src/main/java/com/glidebitmappool/internal/Poolable.java rename {glide-bitmap-pool => glide_bitmap_pool}/src/main/java/com/glidebitmappool/internal/SizeConfigStrategy.java (51%) create mode 100644 glide_bitmap_pool/src/main/java/com/glidebitmappool/internal/Util.java create mode 100644 glide_bitmap_pool/src/main/resources/base/element/string.json diff --git a/.gitignore b/.gitignore index d702c5c..603b140 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,14 @@ *.iml .gradle /local.properties -/.idea/workspace.xml +/.idea/caches /.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml .DS_Store /build /captures -/.idea - +.externalNativeBuild +.cxx diff --git a/README.md b/README.md index 75c2fea..395219e 100755 --- a/README.md +++ b/README.md @@ -1,78 +1,56 @@ -# Glide Bitmap Pool +# Glide Bitmap Pool -[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Glide%20Bitmap%20Pool-blue.svg?style=flat)](http://android-arsenal.com/details/1/3740) -[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/amitshekhariitbhu/GlideBitmapPool/blob/master/LICENSE) +**本项目是基于开源项目Glide Bitmap Pool进行openharmony的移植和开发的,可以通过项目标签以及github地址 ( https://github.com/Sunzxyong/GlideBitmapPool ) 追踪到原项目版本** - +## 项目介绍 -### About Glide Bitmap Pool +- 项目名称:GlideBitmapPool工具类 +- 所属系列:openharmony的第三方组件适配移植 +- 功能:用于重用位图内存的内存管理库 +- 项目移植状态:已完成 +- 调用差异:openharmony与原库内存展示有差异 +- 开发版本:sdk5,DevEco Studio2.1 beta4 +- 原项目Doc地址: -Glide Bitmap Pool is a memory management library for reusing the bitmap memory. As it reuses bitmap memory , so -no more GC calling again and again , hence smooth running application. It uses inBitmap while decoding the bitmap -on the supported android versions. All the version use-cases has been handled to optimize it better. +## 项目介绍 -* [Glide](https://github.com/bumptech/glide) , [Fresco](https://github.com/facebook/fresco) and [Fast Android Networking](https://github.com/amitshekhariitbhu/Fast-Android-Networking) uses Bitmap Pool Concept to -load images efficiently. +- 编程语言:Java -### Why use this library ? +## 安装教程 -An Image heavy Application decodes many images , so there will be continuous allocation and deallocation -of memory in application , and that results in very frequent calling of GC(Garbage Collector). And -finally because of very frequent calling of GC , the application UI freezes. -Use Bitmap pool to avoid continuous allocation and deallocation of memory in application -and reduce GC overhead that will result in smooth running application. -Suppose we have to load few bitmap in Android Application. -When we load bitmapOne , it will allocate the memory for bitmapOne. -Then if we don’t need bitmapOne , do not recycle bitmap (as if you recycle, it will make GC to be called) , -so use this bitmapOne as an inBitmap for bitmapTwo so that , the same memory can be reused for bitmapTwo. -In this way , we can avoid continuous allocation and deallocation of memory in application and reduce GC overhead. -But the problem is that there are few restrictions as android version less than Honeycomb does not supports it , -few android version less than Kitkat only when we use inSampleSize = 1 , above that it supports -completely and few other issues. -So , all these types of cases are handled in this library - -* [Detail Explanation can be found here](https://medium.com/@amitshekhar/how-to-use-bitmap-pool-in-android-56c71a55533c#.m41wqfk8h) - -#### GET RID OF : GC_FOR_ALLOC freed 1568K, 23% free 37664K/48844K, paused 141ms, total 143ms - (whenever you see this log , your application is lagging) - - - -### Show some :heart: -* Be sure to click the "Star" button in the upper right of this page. :smile: - -[![GitHub stars](https://img.shields.io/github/stars/amitshekhariitbhu/GlideBitmapPool.svg?style=social&label=Star)](https://github.com/amitshekhariitbhu/GlideBitmapPool) [![GitHub forks](https://img.shields.io/github/forks/amitshekhariitbhu/GlideBitmapPool.svg?style=social&label=Fork)](https://github.com/amitshekhariitbhu/GlideBitmapPool/fork) [![GitHub followers](https://img.shields.io/github/followers/amitshekhariitbhu.svg?style=social&label=Follow)](https://github.com/amitshekhariitbhu) -[![Twitter Follow](https://img.shields.io/twitter/follow/amitiitbhu.svg?style=social)](https://twitter.com/amitiitbhu) - -## Requirements +1. 下载GlideBitmapPool的har包GlideBitmapPool-ohos.har(位于:https://gitee.com/chinasoft_ohos/GlideBitmapPool/releases/glidebitmappool)。 +2. 启动 DevEco Studio,将下载的har包,导入工程目录“entry->libs”下。 +3. 在moudle级别下的build.gradle文件中添加依赖,在dependences标签中增加对libs目录下har包的引用。 +``` +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + compile(name:'ShadowLayout-ohos', ext:'har') +} +``` -Glide Bitmap Pool can be included in any Android or Java application. +如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, -Glide Bitmap Pool supports Android 2.3 (Gingerbread) and later. +并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 -## Using Glide Bitmap Pool in your application +## 使用说明 -Add this in your build.gradle -```groovy -compile 'com.amitshekhar.android:glide-bitmap-pool:0.0.1' -``` -Then initialize it in onCreate() Method of application class, : ```java GlideBitmapPool.initialize(10 * 1024 * 1024); // 10mb max memory size ``` ### Decoding the bitmap from file path ```java -Bitmap bitmap = GlideBitmapFactory.decodeFile(filePath); +PixelMap pixelMap = GlideBitmapFactory.decodeFile(filePath); ``` ### Decoding the bitmap from resources ```java -Bitmap bitmap = GlideBitmapFactory.decodeResource(getResources(), R.drawable.testImage); +PixelMap pixelMap = GlideBitmapFactory.decodeResource(getContext(), ResourceTable.Media_test1); ``` ### Decoding the down sample bitmap ```java -Bitmap bitmap = GlideBitmapFactory.decodeFile(filePath,100,100); +PixelMap pixelMap = GlideBitmapFactory.decodeFile(filePath,100,100); ``` ### Making the bitmap available for recycle or reuse @@ -82,7 +60,7 @@ GlideBitmapPool.putBitmap(bitmap); ### Getting the empty bitmap from the pool ```java -Bitmap bitmap = GlideBitmapPool.getBitmap(width, height, config); +PixelMap pixelMap = GlideBitmapPool.getBitmap(width, height, config); ``` ### Clearing or Trimming Memory @@ -94,14 +72,10 @@ GlideBitmapPool.trimMemory(level); ### Migrating to Glide Bitmap Pool ```java // ------ decoding ------- +// new code +PixelMap pixelMap = GlideBitmapFactory.decodeResource(getContext(), ResourceTable.Media_test1); -// old code -Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test1); - -// new code -Bitmap bitmap = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test1); - -// ------ recycling ------- +// ------ recycling ------- // old code bitmap.recycle(); @@ -110,12 +84,8 @@ bitmap.recycle(); GlideBitmapPool.putBitmap(bitmap); // ------ creating a bitmap ------- - -// old code -Bitmap bitmap = Bitmap.create(width, height, config); - // new code -Bitmap bitmap = GlideBitmapPool.getBitmap(width, height, config); +PixelMap pixelMap = GlideBitmapPool.getBitmap(width, height, config); ``` ### Important @@ -127,24 +97,20 @@ Bitmap bitmap = GlideBitmapPool.getBitmap(width, height, config); // use GlideBitmapPool.getBitmap(width, height, config); as it returns bitmap from the pool that can be reused. ``` -### Credits and references -* [Glide](https://github.com/bumptech/glide) - As it uses the same bitmap pool that is used by [Glide](https://github.com/bumptech/glide) -* [Managing Bitmap Memory](https://developer.android.com/training/displaying-bitmaps/manage-memory.html) -* [Loading Large Bitmaps Efficiently](https://developer.android.com/training/displaying-bitmaps/load-bitmap.html) -### TODO -* More Optimization with further updates. +## 测试信息 +CodeCheck代码测试无异常 -### Contact - Let's become friend -- [Twitter](https://twitter.com/amitiitbhu) -- [Github](https://github.com/amitshekhariitbhu) -- [Medium](https://medium.com/@amitshekhar) -- [Facebook](https://www.facebook.com/amit.shekhar.iitbhu) +CloudTest代码测试无异常 -### Have an issue or need a feature in Glide Bitmap Pool -- Best way to do so is - [Create an issue](https://github.com/amitshekhariitbhu/GlideBitmapPool/issues/new) +火绒安全病毒安全检测通过 -### License +当前版本demo功能与原组件基本无差异 + +## 版本迭代 +- 0.0.1-SNAPSHOT + +## 版权和许可信息 ``` Copyright (C) 2016 Amit Shekhar Copyright (C) 2011 Android Open Source Project @@ -160,7 +126,4 @@ Bitmap bitmap = GlideBitmapPool.getBitmap(width, height, config); WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -``` - -### Contributing to Glide Bitmap Pool -Just make pull request. You are in! \ No newline at end of file +``` \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index ad67144..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016 Amit Shekhar - * Copyright (C) 2011 Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'com.android.application' - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" - - defaultConfig { - applicationId "com.glidebitmappool" - minSdkVersion 15 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.4.0' - compile project(':glide-bitmap-pool') -} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 6b7a2bf..0000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/app/src/androidTest/java/com/glidebitmappool/ApplicationTest.java b/app/src/androidTest/java/com/glidebitmappool/ApplicationTest.java deleted file mode 100644 index b4c28d8..0000000 --- a/app/src/androidTest/java/com/glidebitmappool/ApplicationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 Amit Shekhar - * Copyright (C) 2011 Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.glidebitmappool; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/com/glidebitmappoolsample/ApplicationTest.java b/app/src/androidTest/java/com/glidebitmappoolsample/ApplicationTest.java deleted file mode 100644 index e5b8bc2..0000000 --- a/app/src/androidTest/java/com/glidebitmappoolsample/ApplicationTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 Amit Shekhar - * Copyright (C) 2011 Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.glidebitmappoolsample; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index c20d66a..0000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/glidebitmappoolsample/MainActivity.java b/app/src/main/java/com/glidebitmappoolsample/MainActivity.java deleted file mode 100644 index a0e724f..0000000 --- a/app/src/main/java/com/glidebitmappoolsample/MainActivity.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2016 Amit Shekhar - * Copyright (C) 2011 Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.glidebitmappoolsample; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.os.Bundle; -import android.os.Environment; -import android.support.v7.app.AppCompatActivity; -import android.view.View; - -import com.glidebitmappool.GlideBitmapFactory; -import com.glidebitmappool.GlideBitmapPool; - -import java.io.File; - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - GlideBitmapPool.initialize(10 * 1024 * 1024); - } - - public void normalResource(View view) { - new Thread(new Runnable() { - @Override - public void run() { - Bitmap bitmap1 = BitmapFactory.decodeResource(getResources(), R.drawable.test1); - bitmap1.recycle(); - Bitmap bitmap2 = BitmapFactory.decodeResource(getResources(), R.drawable.test2); - bitmap2.recycle(); - Bitmap bitmap3 = BitmapFactory.decodeResource(getResources(), R.drawable.test3); - bitmap3.recycle(); - Bitmap bitmap4 = BitmapFactory.decodeResource(getResources(), R.drawable.test4); - bitmap4.recycle(); - Bitmap bitmap5 = BitmapFactory.decodeResource(getResources(), R.drawable.test5); - bitmap5.recycle(); - Bitmap bitmap6 = BitmapFactory.decodeResource(getResources(), R.drawable.test6); - bitmap6.recycle(); - Bitmap bitmap7 = BitmapFactory.decodeResource(getResources(), R.drawable.test7); - bitmap7.recycle(); - Bitmap bitmap8 = BitmapFactory.decodeResource(getResources(), R.drawable.test8); - bitmap8.recycle(); - Bitmap bitmap9 = BitmapFactory.decodeResource(getResources(), R.drawable.test9); - bitmap9.recycle(); - Bitmap bitmap10 = BitmapFactory.decodeResource(getResources(), R.drawable.test10); - bitmap10.recycle(); - } - }).start(); - } - - public void normalFile(View view) { - new Thread(new Runnable() { - @Override - public void run() { - String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Download" + File.separator + "test"; - for (int i = 1; i <= 10; i++) { - Bitmap bitmap = BitmapFactory.decodeFile(path + i + ".png"); - bitmap.recycle(); - } - } - }).start(); - } - - public void resourceOptimized(View view) { - - new Thread(new Runnable() { - @Override - public void run() { - Bitmap bitmap1 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test1); - GlideBitmapPool.putBitmap(bitmap1); - - Bitmap bitmap2 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test2); - GlideBitmapPool.putBitmap(bitmap2); - - Bitmap bitmap3 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test3); - GlideBitmapPool.putBitmap(bitmap3); - - Bitmap bitmap4 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test4); - GlideBitmapPool.putBitmap(bitmap4); - - Bitmap bitmap5 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test5); - GlideBitmapPool.putBitmap(bitmap5); - - Bitmap bitmap6 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test6); - GlideBitmapPool.putBitmap(bitmap6); - - Bitmap bitmap7 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test7); - GlideBitmapPool.putBitmap(bitmap7); - - Bitmap bitmap8 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test8); - GlideBitmapPool.putBitmap(bitmap8); - - Bitmap bitmap9 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test9); - GlideBitmapPool.putBitmap(bitmap9); - - Bitmap bitmap10 = GlideBitmapFactory.decodeResource(getResources(), R.drawable.test10); - GlideBitmapPool.putBitmap(bitmap10); - } - }).start(); - } - - public void fileOptimized(View view) { - new Thread(new Runnable() { - @Override - public void run() { - try { - String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Download" + File.separator + "test"; - for (int i = 1; i <= 10; i++) { - Bitmap bitmap = GlideBitmapFactory.decodeFile(path + i + ".png"); - GlideBitmapPool.putBitmap(bitmap); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }).start(); - } - - public void downSample(View view) { - new Thread(new Runnable() { - @Override - public void run() { - try { - String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Download" + File.separator + "test"; - for (int i = 1; i <= 10; i++) { - Bitmap bitmap = GlideBitmapFactory.decodeFile(path + i + ".png", 100, 100); - GlideBitmapPool.putBitmap(bitmap); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }).start(); - } - - public void clearMemory(View view) { - GlideBitmapPool.clearMemory(); - } -} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index da7d39c..0000000 --- a/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - -