Skip to content

Commit

Permalink
Glide 4.1.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Sep 5, 2017
1 parent eac9728 commit fb2ce40
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/io/plaidapp/util/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.graphics.Palette;
import android.text.TextPaint;
import android.util.DisplayMetrics;
Expand Down Expand Up @@ -76,7 +77,7 @@ public static RippleDrawable createRipple(@ColorInt int color,
bounded ? new ColorDrawable(Color.WHITE) : null);
}

public static RippleDrawable createRipple(@NonNull Palette palette,
public static RippleDrawable createRipple(@Nullable Palette palette,
@FloatRange(from = 0f, to = 1f) float darkAlpha,
@FloatRange(from = 0f, to = 1f) float lightAlpha,
@ColorInt int fallbackColor,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/plaidapp/util/glide/DribbbleTarget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DribbbleTarget(
}
}

override fun onGenerated(palette: Palette) {
override fun onGenerated(palette: Palette?) {
(view as BadgedFourThreeImageView).foreground = ViewUtils.createRipple(palette, 0.25f, 0.5f,
ContextCompat.getColor(view.context, R.color.mid_grey), true)
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/main/java/io/plaidapp/util/glide/PlaidGlideModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.module.AppGlideModule;
import com.bumptech.glide.request.RequestOptions;

import static android.content.Context.ACTIVITY_SERVICE;
import static com.bumptech.glide.load.DecodeFormat.PREFER_ARGB_8888;
import static com.bumptech.glide.load.DecodeFormat.PREFER_RGB_565;

/**
* Glide module configurations
*/
Expand All @@ -33,12 +36,13 @@ public class PlaidGlideModule extends AppGlideModule {

@Override
public void applyOptions(Context context, GlideBuilder builder) {
final RequestOptions defaultOptions = new RequestOptions();
// Prefer higher quality images unless we're on a low RAM device
ActivityManager activityManager =
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final RequestOptions defaultOptions = new RequestOptions();
defaultOptions.format(activityManager.isLowRamDevice() ?
DecodeFormat.PREFER_RGB_565 : DecodeFormat.PREFER_ARGB_8888);
(ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
defaultOptions.format(activityManager.isLowRamDevice() ? PREFER_RGB_565 : PREFER_ARGB_8888);
// Disable hardware bitmaps as they don't play nicely with Palette
defaultOptions.disallowHardwareConfig();
builder.setDefaultRequestOptions(defaultOptions);
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
'targetSdk' : 26,
'buildTools' : '26.0.1',
'butterknife' : '8.8.1',
'glide' : '4.0.0',
'glide' : '4.1.1',
'kotlin' : '1.1.4-3',
'retrofit' : '2.3.0',
'supportLibrary': '26.0.2'
Expand Down

0 comments on commit fb2ce40

Please sign in to comment.