mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-23 23:51:02 +00:00
Use Glide for all contact photo caching
// FREEBIE
This commit is contained in:
@@ -10,8 +10,8 @@ import android.graphics.Rect;
|
||||
import android.graphics.YuvImage;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.*;
|
||||
import android.support.annotation.WorkerThread;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BitmapUtil {
|
||||
private static final int MAX_COMPRESSION_ATTEMPTS = 5;
|
||||
private static final int MIN_COMPRESSION_QUALITY_DECREASE = 5;
|
||||
|
||||
@android.support.annotation.WorkerThread
|
||||
public static <T> byte[] createScaledBytes(Context context, T model, MediaConstraints constraints)
|
||||
throws BitmapDecodingException
|
||||
{
|
||||
@@ -50,7 +51,7 @@ public class BitmapUtil {
|
||||
int attempts = 0;
|
||||
byte[] bytes;
|
||||
|
||||
Bitmap scaledBitmap = GlideApp.with(context)
|
||||
Bitmap scaledBitmap = GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(model)
|
||||
.downsample(DownsampleStrategy.AT_MOST)
|
||||
@@ -91,11 +92,12 @@ public class BitmapUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static <T> Bitmap createScaledBitmap(Context context, T model, int maxWidth, int maxHeight)
|
||||
throws BitmapDecodingException
|
||||
{
|
||||
try {
|
||||
return GlideApp.with(context)
|
||||
return GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(model)
|
||||
.downsample(DownsampleStrategy.AT_MOST)
|
||||
@@ -106,11 +108,12 @@ public class BitmapUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
public static <T> Bitmap createScaledBitmap(Context context, T model, float scale)
|
||||
throws BitmapDecodingException
|
||||
{
|
||||
try {
|
||||
return GlideApp.with(context)
|
||||
return GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(model)
|
||||
.sizeMultiplier(scale)
|
||||
|
||||
@@ -66,7 +66,7 @@ public class MediaUtil {
|
||||
{
|
||||
try {
|
||||
int maxSize = context.getResources().getDimensionPixelSize(R.dimen.media_bubble_height);
|
||||
return GlideApp.with(context)
|
||||
return GlideApp.with(context.getApplicationContext())
|
||||
.asBitmap()
|
||||
.load(new DecryptableUri(masterSecret, uri))
|
||||
.centerCrop()
|
||||
|
||||
@@ -112,6 +112,7 @@ public class TextSecurePreferences {
|
||||
private static final String ALWAYS_RELAY_CALLS_PREF = "pref_turn_only";
|
||||
private static final String PROFILE_KEY_PREF = "pref_profile_key";
|
||||
private static final String PROFILE_NAME_PREF = "pref_profile_name";
|
||||
private static final String PROFILE_AVATAR_ID_PREF = "pref_profile_avatar_id";
|
||||
public static final String READ_RECEIPTS_PREF = "pref_read_receipts";
|
||||
public static final String INCOGNITO_KEYBORAD_PREF = "pref_incognito_keyboard";
|
||||
|
||||
@@ -143,6 +144,14 @@ public class TextSecurePreferences {
|
||||
return getStringPreference(context, PROFILE_NAME_PREF, null);
|
||||
}
|
||||
|
||||
public static void setProfileAvatarId(Context context, int id) {
|
||||
setIntegerPrefrence(context, PROFILE_AVATAR_ID_PREF, id);
|
||||
}
|
||||
|
||||
public static int getProfileAvatarId(Context context) {
|
||||
return getIntegerPreference(context, PROFILE_AVATAR_ID_PREF, 0);
|
||||
}
|
||||
|
||||
public static int getNotificationPriority(Context context) {
|
||||
return Integer.valueOf(getStringPreference(context, NOTIFICATION_PRIORITY_PREF, String.valueOf(NotificationCompat.PRIORITY_HIGH)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user