From f8aeada68f99406b6cd7f3867b6089a202e650d5 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 29 Jun 2022 18:54:08 +0200 Subject: [PATCH] Some fixes --- .../app/fedilab/android/BaseMainActivity.java | 2 +- .../android/activities/ProfileActivity.java | 2 +- .../app/fedilab/android/helper/Helper.java | 27 ++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 2f733a7c..e72396dd 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -612,7 +612,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt binding.profilePicture.setOnClickListener(v -> binding.drawerLayout.openDrawer(GravityCompat.START)); Helper.loadPP(binding.profilePicture, currentAccount); headerMainBinding.accountAcc.setText(String.format("%s@%s", currentAccount.mastodon_account.username, currentAccount.instance)); - if (currentAccount.mastodon_account.display_name.isEmpty()) { + if (currentAccount.mastodon_account.display_name == null || currentAccount.mastodon_account.display_name.isEmpty()) { currentAccount.mastodon_account.display_name = currentAccount.mastodon_account.acct; } headerMainBinding.accountName.setText(currentAccount.mastodon_account.display_name); diff --git a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java index ec1f3a9c..e8d8fc52 100644 --- a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java @@ -348,7 +348,7 @@ public class ProfileActivity extends BaseActivity { binding.accountMoved.setText(spannableString, TextView.BufferType.SPANNABLE); binding.accountMoved.setMovementMethod(LinkMovementMethod.getInstance()); } - if (account.acct.contains("@")) + if (account.acct != null && account.acct.contains("@")) binding.warningMessage.setVisibility(View.VISIBLE); else binding.warningMessage.setVisibility(View.GONE); diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 7fbddaff..6d5454d5 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -1032,17 +1032,26 @@ public class Helper { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false); String targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar; - if (disableGif || (!targetedUrl.endsWith(".gif"))) { - Glide.with(view.getContext()) - .asDrawable() - .load(targetedUrl) - .thumbnail(0.1f) - .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) - .into(view); + if (targetedUrl != null) { + if (disableGif || (!targetedUrl.endsWith(".gif"))) { + Glide.with(view.getContext()) + .asDrawable() + .load(targetedUrl) + .thumbnail(0.1f) + .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) + .into(view); + } else { + Glide.with(view.getContext()) + .asGif() + .load(targetedUrl) + .thumbnail(0.1f) + .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) + .into(view); + } } else { Glide.with(view.getContext()) - .asGif() - .load(targetedUrl) + .asDrawable() + .load(R.drawable.ic_person) .thumbnail(0.1f) .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) .into(view);