Skip to content

Commit

Permalink
Use lower quality images on low RAM devices. #TNB
Browse files Browse the repository at this point in the history
Change-Id: If2a6d84fdefcd5b957fc65c99e9f36c934eb63be
  • Loading branch information
nickbutcher committed Aug 14, 2015
1 parent b614791 commit dced30a
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.example.android.plaid.ui.util.glide;

import android.app.ActivityManager;
import android.content.Context;

import com.bumptech.glide.Glide;
Expand All @@ -24,18 +25,21 @@
import com.bumptech.glide.module.GlideModule;

/**
* Created by nickbutcher on 3/26/15.
* Configure Glide to set desired image quality.
*/
public class GlideConfiguration implements GlideModule {

@Override
public void applyOptions(Context context, GlideBuilder builder) {
// Apply options to the builder here.
builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
// Prefer higher quality images unless we're on a low RAM device
ActivityManager activityManager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
builder.setDecodeFormat(activityManager.isLowRamDevice() ?
DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
}

@Override
public void registerComponents(Context context, Glide glide) {
// register ModelLoaders here.

}
}

0 comments on commit dced30a

Please sign in to comment.