From 49a74f57a5d57c5cf11178e5fbd5e8773515674b Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Sun, 25 Feb 2018 15:41:45 +0100 Subject: [PATCH] fix a crash in ComposeActivity when trying to share images while logged out --- .../keylesspalace/tusky/ComposeActivity.java | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 7a3f452a..6a3384b3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -204,6 +204,32 @@ public final class ComposeActivity extends BaseActivity actionBar.setHomeAsUpIndicator(closeIcon); } + // setup the account image + AccountEntity activeAccount = TuskyApplication.getAccountManager().getActiveAccount(); + + if(activeAccount != null) { + + ImageView composeAvatar = findViewById(R.id.composeAvatar); + + if(TextUtils.isEmpty(activeAccount.getProfilePictureUrl())) { + composeAvatar.setImageResource(R.drawable.avatar_default); + } else { + Picasso.with(this).load(activeAccount.getProfilePictureUrl()) + .transform(new RoundedTransformation(7, 0)) + .error(R.drawable.avatar_default) + .placeholder(R.drawable.avatar_default) + .into(composeAvatar); + } + + composeAvatar.setContentDescription( + getString(R.string.compose_active_account_description, + activeAccount.getFullName())); + + } else { + // do not do anything when not logged in, activity will be finished in super.onCreate() anyway + return; + } + // Setup the interface buttons. floatingBtn.setOnClickListener(v -> onSendClicked()); floatingBtn.setOnLongClickListener(v -> saveDraft()); @@ -450,28 +476,6 @@ public final class ComposeActivity extends BaseActivity } } - AccountEntity activeAccount = TuskyApplication.getAccountManager().getActiveAccount(); - - if(activeAccount != null) { - - ImageView composeAvatar = findViewById(R.id.composeAvatar); - - if(TextUtils.isEmpty(activeAccount.getProfilePictureUrl())) { - composeAvatar.setImageResource(R.drawable.avatar_default); - } else { - Picasso.with(this).load(activeAccount.getProfilePictureUrl()) - .transform(new RoundedTransformation(7, 0)) - .error(R.drawable.avatar_default) - .placeholder(R.drawable.avatar_default) - .into(composeAvatar); - } - - composeAvatar.setContentDescription( - getString(R.string.compose_active_account_description, - activeAccount.getFullName())); - - } - } @Override