-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from jpush/dev
Dev
- Loading branch information
Showing
19 changed files
with
200 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
Android/messagelist/src/main/java/cn/jiguang/imui/utils/BitmapCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package cn.jiguang.imui.utils; | ||
|
||
import android.graphics.Bitmap; | ||
import android.util.LruCache; | ||
|
||
/** | ||
* Created by caiyaoguan on 2017/7/6. | ||
*/ | ||
|
||
public class BitmapCache { | ||
|
||
private LruCache<String, Bitmap> mMemoryCache; | ||
private static BitmapCache mInstance = new BitmapCache(); | ||
|
||
private BitmapCache() { | ||
//获取应用程序的最大内存 | ||
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); | ||
|
||
//用最大内存的1/4来存储图片 | ||
final int cacheSize = maxMemory / 4; | ||
mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { | ||
|
||
//获取每张图片的大小 | ||
@Override | ||
protected int sizeOf(String key, Bitmap bitmap) { | ||
return bitmap.getRowBytes() * bitmap.getHeight() / 1024; | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* 通过此方法来获取NativeImageLoader的实例 | ||
* | ||
* @return NativeImageLoader | ||
*/ | ||
public static BitmapCache getInstance() { | ||
return mInstance; | ||
} | ||
|
||
public void setBitmapCache(String path, Bitmap bitmap) { | ||
if (getBitmapFromMemCache(path) == null && bitmap != null) { | ||
mMemoryCache.put(path, bitmap); | ||
} | ||
} | ||
|
||
/** | ||
* 根据key来获取内存中的图片 | ||
* | ||
* @param key path | ||
* @return bitmap | ||
*/ | ||
public Bitmap getBitmapFromMemCache(String key) { | ||
if (key == null) { | ||
return null; | ||
} else { | ||
return mMemoryCache.get(key); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,3 +365,4 @@ public void onCatalystInstanceDestroy() { | |
mContext.unregisterReceiver(RCTMsgListReceiver); | ||
} | ||
} | ||
ra |
Oops, something went wrong.