Browse Source

fix bug if photo is URL

tobiaskaminsky 7 years ago
parent
commit
2e69377c52

+ 7 - 5
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java

@@ -66,8 +66,8 @@ import com.owncloud.android.R;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
-import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.jobs.ContactsImportJob;
+import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.ui.TextDrawable;
 import com.owncloud.android.ui.activity.ContactsPreferenceActivity;
 import com.owncloud.android.ui.events.VCardToggleEvent;
@@ -641,11 +641,13 @@ class ContactListAdapter extends RecyclerView.Adapter<ContactListFragment.Contac
             if (vcard.getPhotos().size() > 0) {
                 byte[] data = vcard.getPhotos().get(0).getData();
 
-                Bitmap thumbnail = BitmapFactory.decodeByteArray(data, 0, data.length);
-                RoundedBitmapDrawable drawable = BitmapUtils.bitmapToCircularBitmapDrawable(context.getResources(),
-                        thumbnail);
+                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);
+                    holder.getBadge().setImageDrawable(drawable);
+                }
             } else {
                 try {
                     holder.getBadge().setImageDrawable(