/**
* Lazily apply options to a {@link GlideBuilder} immediately before the Glide singleton is
* created.
* <p>
* <p>
* This method will be called once and only once per implementation.
* </p>
*
* @param context An Application {@link Context}.
* @param builder The {@link GlideBuilder} that will be used to create Glide.
*/
@Override
public void applyOptions(Context context,GlideBuilder builder) {
ActivityManager activityManager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
MemorySizeCalculator calculator = new MemorySizeCalculator(context);
// Increasing cache & pool by 25% - default is 250MB
int memoryCacheSize = (int) (1.25 * calculator.getMemoryCacheSize());
int bitmapPoolSize = (int) (1.25 * calculator.getBitmapPoolSize());
int storageCacheSize = 1024 * 1024 * 350;
if(context.getExternalCacheDir() != null) {
long total = context.getExternalCacheDir().getUsableSpace();
storageCacheSize = (int) (total*0.14);
}
builder.setMemoryCache(new LruResourceCache(memoryCacheSize));
builder.setBitmapPool(new LruBitmapPool(bitmapPoolSize));
builder.setdiskCache(new ExternalCachediskCacheFactory(context,storageCacheSize));
builder.setDecodeFormat(ActivityManagerCompat.isLowRamDevice(activityManager) ?
DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}
项目:okwallet
文件:CrashReporter.java
public static void appendDeviceInfo(final Appendable report,final Context context) throws IOException {
final Resources res = context.getResources();
final android.content.res.Configuration config = res.getConfiguration();
final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
.getSystemService(Context.DEVICE_POLICY_SERVICE);
report.append("Device Model: " + Build.MODEL + "\n");
report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
report.append("Android security patch level: ").append(Build.VERSION.Security_PATCH).append("\n");
report.append("ABIs: ").append(Joiner.on(",").skipNulls().join(Strings.emptyToNull(Build.cpu_ABI),Strings.emptyToNull(Build.cpu_ABI2))).append("\n");
report.append("Board: " + Build.BOARD + "\n");
report.append("Brand: " + Build.BRAND + "\n");
report.append("Device: " + Build.DEVICE + "\n");
report.append("display: " + Build.disPLAY + "\n");
report.append("Finger Print: " + Build.FINGERPRINT + "\n");
report.append("Host: " + Build.HOST + "\n");
report.append("ID: " + Build.ID + "\n");
report.append("Product: " + Build.PRODUCT + "\n");
report.append("Tags: " + Build.TAGS + "\n");
report.append("Time: " + Build.TIME + "\n");
report.append("Type: " + Build.TYPE + "\n");
report.append("User: " + Build.USER + "\n");
report.append("Configuration: " + config + "\n");
report.append("Screen Layout: size "
+ (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
+ (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
report.append("display Metrics: " + res.getdisplayMetrics() + "\n");
report.append("Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass()
+ (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n");
report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
.append(System.getProperty("java.vm.version")).append("\n");
}
项目:cwac-mediarouter
文件:MediaRouter.java
GlobalMediaRouter(Context applicationContext) {
mApplicationContext = applicationContext;
mdisplayManager = displayManagerCompat.getInstance(applicationContext);
mLowRam = ActivityManagerCompat.isLowRamDevice(
(ActivityManager)applicationContext.getSystemService(
Context.ACTIVITY_SERVICE));
// Add the system media route provider for interoperating with
// the framework media router. This one is special and receives
// synchronization messages from the media router.
mSystemProvider = SystemMediaRouteProvider.obtain(applicationContext,this);
addProvider(mSystemProvider);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。