|
@@ -627,52 +627,13 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
|
|
|
|
|
|
if (vcard != null) {
|
|
|
|
|
|
- if (checkedVCards.contains(position)) {
|
|
|
- holder.getName().setChecked(true);
|
|
|
-
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
- holder.getName().getCheckMarkDrawable()
|
|
|
- .setColorFilter(ThemeUtils.primaryAccentColor(context), PorterDuff.Mode.SRC_ATOP);
|
|
|
- }
|
|
|
- } else {
|
|
|
- holder.getName().setChecked(false);
|
|
|
-
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
- holder.getName().getCheckMarkDrawable().clearColorFilter();
|
|
|
- }
|
|
|
- }
|
|
|
+ setChecked(checkedVCards.contains(position), holder.getName());
|
|
|
|
|
|
holder.getName().setText(getDisplayName(vcard));
|
|
|
|
|
|
// photo
|
|
|
if (vcard.getPhotos().size() > 0) {
|
|
|
- Photo firstPhoto = vcard.getPhotos().get(0);
|
|
|
- String url = firstPhoto.getUrl();
|
|
|
- byte[] data = firstPhoto.getData();
|
|
|
-
|
|
|
- if (data != null && data.length > 0) {
|
|
|
- Bitmap thumbnail = BitmapFactory.decodeByteArray(data, 0, data.length);
|
|
|
- RoundedBitmapDrawable drawable = BitmapUtils.bitmapToCircularBitmapDrawable(context.getResources(),
|
|
|
- thumbnail);
|
|
|
-
|
|
|
- holder.getBadge().setImageDrawable(drawable);
|
|
|
- } else if (url != null) {
|
|
|
- ImageView badge = holder.getBadge();
|
|
|
- SimpleTarget target = new SimpleTarget<Drawable>() {
|
|
|
- @Override
|
|
|
- public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
|
|
|
- holder.getBadge().setImageDrawable(resource);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onLoadFailed(Exception e, Drawable errorDrawable) {
|
|
|
- super.onLoadFailed(e, errorDrawable);
|
|
|
- holder.getBadge().setImageDrawable(errorDrawable);
|
|
|
- }
|
|
|
- };
|
|
|
- DisplayUtils.downloadIcon(context, url, target, R.drawable.ic_user,
|
|
|
- badge.getWidth(), badge.getHeight());
|
|
|
- }
|
|
|
+ setPhoto(holder.getBadge(), vcard.getPhotos().get(0));
|
|
|
} else {
|
|
|
try {
|
|
|
holder.getBadge().setImageDrawable(
|
|
@@ -690,6 +651,47 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setPhoto(ImageView imageView, Photo firstPhoto) {
|
|
|
+ String url = firstPhoto.getUrl();
|
|
|
+ byte[] data = firstPhoto.getData();
|
|
|
+
|
|
|
+ if (data != null && data.length > 0) {
|
|
|
+ Bitmap thumbnail = BitmapFactory.decodeByteArray(data, 0, data.length);
|
|
|
+ RoundedBitmapDrawable drawable = BitmapUtils.bitmapToCircularBitmapDrawable(context.getResources(),
|
|
|
+ thumbnail);
|
|
|
+
|
|
|
+ imageView.setImageDrawable(drawable);
|
|
|
+ } else if (url != null) {
|
|
|
+ SimpleTarget target = new SimpleTarget<Drawable>() {
|
|
|
+ @Override
|
|
|
+ public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
|
|
|
+ imageView.setImageDrawable(resource);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoadFailed(Exception e, Drawable errorDrawable) {
|
|
|
+ super.onLoadFailed(e, errorDrawable);
|
|
|
+ imageView.setImageDrawable(errorDrawable);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ DisplayUtils.downloadIcon(context, url, target, R.drawable.ic_user, imageView.getWidth(),
|
|
|
+ imageView.getHeight());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setChecked(boolean checked, CheckedTextView checkedTextView) {
|
|
|
+ checkedTextView.setChecked(checked);
|
|
|
+
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
+ if (checked) {
|
|
|
+ checkedTextView.getCheckMarkDrawable()
|
|
|
+ .setColorFilter(ThemeUtils.primaryAccentColor(context), PorterDuff.Mode.SRC_ATOP);
|
|
|
+ } else {
|
|
|
+ checkedTextView.getCheckMarkDrawable().clearColorFilter();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void toggleVCard(ContactListFragment.ContactItemViewHolder holder, int verifiedPosition) {
|
|
|
holder.getName().setChecked(!holder.getName().isChecked());
|
|
|
|