mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
more error handling for avatar publication
This commit is contained in:
parent
5aa8afdc1c
commit
38f36aa263
@ -285,6 +285,9 @@ public class FileBackend {
|
|||||||
try {
|
try {
|
||||||
Avatar avatar = new Avatar();
|
Avatar avatar = new Avatar();
|
||||||
Bitmap bm = cropCenterSquare(image, size);
|
Bitmap bm = cropCenterSquare(image, size);
|
||||||
|
if (bm==null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
ByteArrayOutputStream mByteArrayOutputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream mByteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
Base64OutputStream mBase64OutputSttream = new Base64OutputStream(mByteArrayOutputStream, Base64.DEFAULT);
|
Base64OutputStream mBase64OutputSttream = new Base64OutputStream(mByteArrayOutputStream, Base64.DEFAULT);
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
||||||
@ -355,7 +358,11 @@ public class FileBackend {
|
|||||||
InputStream is = context.getContentResolver()
|
InputStream is = context.getContentResolver()
|
||||||
.openInputStream(image);
|
.openInputStream(image);
|
||||||
Bitmap input = BitmapFactory.decodeStream(is, null, options);
|
Bitmap input = BitmapFactory.decodeStream(is, null, options);
|
||||||
|
if (input==null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
return cropCenterSquare(input, size);
|
return cropCenterSquare(input, size);
|
||||||
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,9 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
|||||||
if (resultCode == RESULT_OK) {
|
if (resultCode == RESULT_OK) {
|
||||||
if (requestCode == REQUEST_CHOOSE_FILE) {
|
if (requestCode == REQUEST_CHOOSE_FILE) {
|
||||||
this.avatarUri = data.getData();
|
this.avatarUri = data.getData();
|
||||||
|
if (xmppConnectionServiceBound) {
|
||||||
|
loadImageIntoPreview(this.avatarUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,6 +176,12 @@ public class PublishProfilePictureActivity extends XmppActivity {
|
|||||||
protected void loadImageIntoPreview(Uri uri) {
|
protected void loadImageIntoPreview(Uri uri) {
|
||||||
Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
|
Bitmap bm = xmppConnectionService.getFileBackend().cropCenterSquare(
|
||||||
uri, 384);
|
uri, 384);
|
||||||
|
if (bm==null) {
|
||||||
|
disablePublishButton();
|
||||||
|
this.hintOrWarning.setTextColor(getWarningTextColor());
|
||||||
|
this.hintOrWarning.setText(R.string.error_publish_avatar_converting);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.avatar.setImageBitmap(bm);
|
this.avatar.setImageBitmap(bm);
|
||||||
if (support) {
|
if (support) {
|
||||||
enablePublishButton();
|
enablePublishButton();
|
||||||
|
Loading…
Reference in New Issue
Block a user