We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://drive.google.com/file/d/0B-GeS9MutjJONFJFYTV5cTNON2c/view
The text was updated successfully, but these errors were encountered:
解决OOM问题,自测已没问题,初始化Fresco时,要添加如下内容: private void initFresco() { ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); ImagePipelineConfig imagePipelineConfig = ImagePipelineConfig .newBuilder(getApplicationContext()) .setDownsampleEnabled(true) .setBitmapMemoryCacheParamsSupplier(new LollipopBitmapMemoryCacheParamsSupplier(activityManager)) .build();
Fresco.initialize(getApplicationContext(), imagePipelineConfig); }
public class LollipopBitmapMemoryCacheParamsSupplier implements Supplier {
private ActivityManager activityManager; public LollipopBitmapMemoryCacheParamsSupplier(ActivityManager activityManager) { this.activityManager = activityManager; } @Override public MemoryCacheParams get() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return new MemoryCacheParams(getMaxCacheSize(), 56, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
// 不确定用哪个 // return new MemoryCacheParams(getMaxCacheSize(), 1, 1, 1, 1); } else { return new MemoryCacheParams( getMaxCacheSize(), 256, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); } }
private int getMaxCacheSize() { final int maxMemory = Math.min(activityManager.getMemoryClass() * ByteConstants.MB, Integer.MAX_VALUE); if (maxMemory < 32 * ByteConstants.MB) { return 4 * ByteConstants.MB; } else if (maxMemory < 64 * ByteConstants.MB) { return 6 * ByteConstants.MB; } else { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD) { return 8 * ByteConstants.MB; } else { return maxMemory / 4; } } }
}
Sorry, something went wrong.
No branches or pull requests
https://drive.google.com/file/d/0B-GeS9MutjJONFJFYTV5cTNON2c/view
The text was updated successfully, but these errors were encountered: