mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 13:58:40 +00:00
rounded ImageView instead of Bitmap, crop-select
// FREEBIE
This commit is contained in:
@@ -19,15 +19,11 @@ import java.util.Map;
|
||||
|
||||
public class ContactPhotoFactory {
|
||||
|
||||
private static final Object defaultPhotoLock = new Object();
|
||||
private static final Object defaultGroupPhotoLock = new Object();
|
||||
private static final Object defaultPhotoCroppedLock = new Object();
|
||||
private static final Object defaultGroupPhotoCroppedLock = new Object();
|
||||
private static final Object defaultPhotoLock = new Object();
|
||||
private static final Object defaultGroupPhotoLock = new Object();
|
||||
|
||||
private static Bitmap defaultContactPhoto;
|
||||
private static Bitmap defaultGroupContactPhoto;
|
||||
private static Bitmap defaultContactPhotoCropped;
|
||||
private static Bitmap defaultGroupContactPhotoCropped;
|
||||
|
||||
private static final Map<Uri,Bitmap> localUserContactPhotoCache =
|
||||
Collections.synchronizedMap(new LRUCache<Uri,Bitmap>(2));
|
||||
@@ -56,24 +52,6 @@ public class ContactPhotoFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getDefaultContactPhotoCropped(Context context) {
|
||||
synchronized (defaultPhotoCroppedLock) {
|
||||
if (defaultContactPhotoCropped == null)
|
||||
defaultContactPhotoCropped = BitmapUtil.getCircleCroppedBitmap(getDefaultContactPhoto(context));
|
||||
|
||||
return defaultContactPhotoCropped;
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getDefaultGroupPhotoCropped(Context context) {
|
||||
synchronized (defaultGroupPhotoCroppedLock) {
|
||||
if (defaultGroupContactPhotoCropped == null)
|
||||
defaultGroupContactPhotoCropped = BitmapUtil.getCircleCroppedBitmap(getDefaultGroupPhoto(context));
|
||||
|
||||
return defaultGroupContactPhotoCropped;
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap getLocalUserContactPhoto(Context context, Uri uri) {
|
||||
if (uri == null) return getDefaultContactPhoto(context);
|
||||
|
||||
|
||||
@@ -30,12 +30,10 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.FilterQueryProvider;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||
import org.thoughtcrime.securesms.util.BitmapWorkerRunnable;
|
||||
import org.thoughtcrime.securesms.util.BitmapWorkerRunnable.AsyncDrawable;
|
||||
import org.thoughtcrime.securesms.util.TaggedFutureTask;
|
||||
@@ -76,10 +74,9 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
||||
private final LayoutInflater li;
|
||||
private final TypedArray drawables;
|
||||
private final Bitmap defaultPhoto;
|
||||
private final Bitmap defaultCroppedPhoto;
|
||||
private final int scaledPhotoSize;
|
||||
|
||||
private final HashMap<Long, ContactAccessor.ContactData> selectedContacts = new HashMap<Long, ContactAccessor.ContactData>();
|
||||
private final HashMap<Long, ContactAccessor.ContactData> selectedContacts = new HashMap<>();
|
||||
|
||||
public ContactSelectionListAdapter(Context context, Cursor cursor, boolean multiSelect) {
|
||||
super(context, cursor, 0);
|
||||
@@ -89,7 +86,6 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
||||
this.multiSelect = multiSelect;
|
||||
this.defaultPhoto = ContactPhotoFactory.getDefaultContactPhoto(context);
|
||||
this.scaledPhotoSize = context.getResources().getDimensionPixelSize(R.dimen.contact_selection_photo_size);
|
||||
this.defaultCroppedPhoto = BitmapUtil.getScaledCircleCroppedBitmap(defaultPhoto, scaledPhotoSize);
|
||||
}
|
||||
|
||||
public static class ViewHolder {
|
||||
@@ -184,7 +180,7 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
||||
numberLabelSpan.setSpan(new ForegroundColorSpan(drawables.getColor(2, 0xff444444)), contactData.number.length(), numberWithLabel.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||
holder.number.setText(numberLabelSpan);
|
||||
}
|
||||
holder.contactPhoto.setImageBitmap(defaultCroppedPhoto);
|
||||
holder.contactPhoto.setImageBitmap(defaultPhoto);
|
||||
if (contactData.id > -1) loadBitmap(contactData.number, holder.contactPhoto);
|
||||
}
|
||||
|
||||
@@ -237,7 +233,7 @@ public class ContactSelectionListAdapter extends CursorAdapter
|
||||
if (cancelPotentialWork(number, imageView)) {
|
||||
final BitmapWorkerRunnable runnable = new BitmapWorkerRunnable(context, imageView, defaultPhoto, number, scaledPhotoSize);
|
||||
final TaggedFutureTask<?> task = new TaggedFutureTask<Void>(runnable, null, number);
|
||||
final AsyncDrawable asyncDrawable = new AsyncDrawable(context.getResources(), defaultCroppedPhoto, task);
|
||||
final AsyncDrawable asyncDrawable = new AsyncDrawable(defaultPhoto, task);
|
||||
|
||||
imageView.setImageDrawable(asyncDrawable);
|
||||
if (!task.isCancelled()) photoResolver.execute(new FutureTask<Void>(task, null));
|
||||
|
||||
Reference in New Issue
Block a user