Fix some crashes

This commit is contained in:
Thomas 2022-11-05 15:06:21 +01:00
parent 92157dc8dc
commit 6d3148bd51
1 changed files with 30 additions and 24 deletions

View File

@ -19,6 +19,7 @@ import static app.fedilab.android.BaseMainActivity.instanceInfo;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
@ -191,13 +192,15 @@ public class EditProfileActivity extends BaseActivity {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_MEDIA_AVATAR && resultCode == RESULT_OK) {
Uri uri = data.getData();
if (uri != null) {
binding.avatarProgress.setVisibility(View.VISIBLE);
Glide.with(EditProfileActivity.this)
.asDrawable()
.load(data.getData())
.load(uri)
.thumbnail(0.1f)
.into(binding.accountPp);
accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, data.getData(), AccountsVM.UpdateMediaType.AVATAR)
accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, uri, AccountsVM.UpdateMediaType.AVATAR)
.observe(EditProfileActivity.this, account -> {
if (account != null) {
sendBroadCast(account);
@ -215,6 +218,9 @@ public class EditProfileActivity extends BaseActivity {
Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
}
});
} else {
Toasty.error(EditProfileActivity.this, getString(R.string.toast_error), Toasty.LENGTH_LONG).show();
}
} else if (requestCode == PICK_MEDIA_HEADER && resultCode == RESULT_OK) {
Glide.with(EditProfileActivity.this)
.asDrawable()