Fix some crashes
This commit is contained in:
parent
92157dc8dc
commit
6d3148bd51
|
@ -19,6 +19,7 @@ import static app.fedilab.android.BaseMainActivity.instanceInfo;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
@ -191,30 +192,35 @@ public class EditProfileActivity extends BaseActivity {
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == PICK_MEDIA_AVATAR && resultCode == RESULT_OK) {
|
if (requestCode == PICK_MEDIA_AVATAR && resultCode == RESULT_OK) {
|
||||||
binding.avatarProgress.setVisibility(View.VISIBLE);
|
Uri uri = data.getData();
|
||||||
Glide.with(EditProfileActivity.this)
|
if (uri != null) {
|
||||||
.asDrawable()
|
binding.avatarProgress.setVisibility(View.VISIBLE);
|
||||||
.load(data.getData())
|
Glide.with(EditProfileActivity.this)
|
||||||
.thumbnail(0.1f)
|
.asDrawable()
|
||||||
.into(binding.accountPp);
|
.load(uri)
|
||||||
accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, data.getData(), AccountsVM.UpdateMediaType.AVATAR)
|
.thumbnail(0.1f)
|
||||||
.observe(EditProfileActivity.this, account -> {
|
.into(binding.accountPp);
|
||||||
if (account != null) {
|
accountsVM.updateProfilePicture(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, uri, AccountsVM.UpdateMediaType.AVATAR)
|
||||||
sendBroadCast(account);
|
.observe(EditProfileActivity.this, account -> {
|
||||||
binding.avatarProgress.setVisibility(View.GONE);
|
if (account != null) {
|
||||||
currentAccount.mastodon_account = account;
|
sendBroadCast(account);
|
||||||
Helper.recreateMainActivity(EditProfileActivity.this);
|
binding.avatarProgress.setVisibility(View.GONE);
|
||||||
new Thread(() -> {
|
currentAccount.mastodon_account = account;
|
||||||
try {
|
Helper.recreateMainActivity(EditProfileActivity.this);
|
||||||
new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(currentAccount);
|
new Thread(() -> {
|
||||||
} catch (DBException e) {
|
try {
|
||||||
e.printStackTrace();
|
new app.fedilab.android.client.entities.app.Account(EditProfileActivity.this).insertOrUpdate(currentAccount);
|
||||||
}
|
} catch (DBException e) {
|
||||||
}).start();
|
e.printStackTrace();
|
||||||
} else {
|
}
|
||||||
Helper.sendToastMessage(getApplication(), Helper.RECEIVE_TOAST_TYPE_ERROR, getString(R.string.toast_error));
|
}).start();
|
||||||
}
|
} else {
|
||||||
});
|
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) {
|
} else if (requestCode == PICK_MEDIA_HEADER && resultCode == RESULT_OK) {
|
||||||
Glide.with(EditProfileActivity.this)
|
Glide.with(EditProfileActivity.this)
|
||||||
.asDrawable()
|
.asDrawable()
|
||||||
|
|
Loading…
Reference in New Issue