Handle missing profile photos better.
There were a couple funny behaviors you could run into if you had a contact that previously had a profile photo, but then removed it.master
parent
1df28c6564
commit
048d859881
|
@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
|
|||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.profiles.AvatarHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.MessageDigest;
|
||||
|
@ -30,7 +31,8 @@ public class ProfileContactPhoto implements ContactPhoto {
|
|||
|
||||
@Override
|
||||
public @Nullable Uri getUri(@NonNull Context context) {
|
||||
return Uri.fromFile(AvatarHelper.getAvatarFile(context, address));
|
||||
File avatarFile = AvatarHelper.getAvatarFile(context, address);
|
||||
return avatarFile.exists() ? Uri.fromFile(avatarFile) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact.Phone;
|
||||
|
@ -103,7 +104,11 @@ class ContactFieldAdapter extends RecyclerView.Adapter<ContactFieldAdapter.Conta
|
|||
|
||||
if (field.iconUri != null) {
|
||||
avatar.setVisibility(View.VISIBLE);
|
||||
glideRequests.load(field.iconUri).circleCrop().into(avatar);
|
||||
glideRequests.load(field.iconUri)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.skipMemoryCache(true)
|
||||
.circleCrop()
|
||||
.into(avatar);
|
||||
} else {
|
||||
avatar.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.bumptech.glide.load.data.DataFetcher;
|
|||
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
@ -30,6 +31,8 @@ class ContactPhotoFetcher implements DataFetcher<InputStream> {
|
|||
try {
|
||||
inputStream = contactPhoto.openInputStream(context);
|
||||
callback.onDataReady(inputStream);
|
||||
} catch (FileNotFoundException e) {
|
||||
callback.onDataReady(null);
|
||||
} catch (IOException e) {
|
||||
callback.onLoadFailed(e);
|
||||
}
|
||||
|
|
|
@ -242,8 +242,6 @@ public class MediaUtil {
|
|||
}
|
||||
|
||||
public static boolean hasVideoThumbnail(Uri uri) {
|
||||
Log.i(TAG, "Checking: " + uri);
|
||||
|
||||
if (uri == null || !ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue