|
|
|
@ -24,6 +24,7 @@ import android.content.Context;
|
|
|
|
|
import android.content.res.ColorStateList;
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.ParcelFileDescriptor;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
@ -102,6 +103,8 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
ivAvatar.setImageDrawable(null);
|
|
|
|
|
else
|
|
|
|
|
try {
|
|
|
|
|
Uri uri = Uri.parse(contact.avatar + "/photo");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.content.res.AssetFileDescriptor.getFileDescriptor()' on a null object reference
|
|
|
|
|
java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.content.res.AssetFileDescriptor.getFileDescriptor()' on a null object reference
|
|
|
|
@ -110,13 +113,23 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|
|
|
|
at android.graphics.ImageDecoder.decodeDrawable(ImageDecoder.java:1645)
|
|
|
|
|
at android.widget.ImageView.getDrawableFromUri(ImageView.java:952)
|
|
|
|
|
at android.widget.ImageView.resolveUri(ImageView.java:921)
|
|
|
|
|
|
|
|
|
|
at android.widget.ImageView.setImageURI(ImageView.java:532)
|
|
|
|
|
at androidx.appcompat.widget.AppCompatImageView.setImageURI(SourceFile:116)
|
|
|
|
|
|
|
|
|
|
at android.widget.ImageView.onMeasure(ImageView.java:1056)
|
|
|
|
|
at android.view.View.measure(View.java:23188)
|
|
|
|
|
at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(SourceFile:806)
|
|
|
|
|
*/
|
|
|
|
|
ivAvatar.setImageURI(Uri.parse(contact.avatar + "/photo"));
|
|
|
|
|
ParcelFileDescriptor pfd = context.getContentResolver().openFileDescriptor(uri, "r");
|
|
|
|
|
if (pfd == null)
|
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
|
pfd.close();
|
|
|
|
|
|
|
|
|
|
ivAvatar.setImageURI(uri);
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
ivAvatar.setImageDrawable(null);
|
|
|
|
|
ivAvatar.setImageResource(R.drawable.baseline_broken_image_24);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tvName.setText(contact.name == null ? contact.email : contact.name);
|
|
|
|
|