Prevent crash

This commit is contained in:
M66B 2018-11-07 19:16:31 +00:00
parent 53abb06efa
commit 4ad1bde2e3
2 changed files with 12 additions and 7 deletions

View File

@ -296,13 +296,16 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
boolean photo = false;
if (avatars) {
if (message.avatar != null) {
if (message.avatar != null)
try {
ContentResolver resolver = context.getContentResolver();
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
if (is != null) {
photo = true;
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
}
} catch (SecurityException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
if (!photo && identicons) {

View File

@ -525,6 +525,8 @@ public class ServiceSynchronize extends LifecycleService {
cursor.getLong(0) + "/photo");
mbuilder.setLargeIcon(Icon.createWithContentUri(photo));
}
} catch (SecurityException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
} finally {
if (cursor != null)
cursor.close();