diff options
Diffstat (limited to 'app/src/main/java/app/fedilab/android/activities/TootActivity.java')
-rw-r--r-- | app/src/main/java/app/fedilab/android/activities/TootActivity.java | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/TootActivity.java b/app/src/main/java/app/fedilab/android/activities/TootActivity.java index 569ea9867..b57b77ae5 100644 --- a/app/src/main/java/app/fedilab/android/activities/TootActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/TootActivity.java @@ -207,6 +207,7 @@ import static app.fedilab.android.helper.Helper.THEME_BLACK; import static app.fedilab.android.helper.Helper.THEME_DARK; import static app.fedilab.android.helper.Helper.THEME_LIGHT; import static app.fedilab.android.helper.Helper.countWithEmoji; +import static app.fedilab.android.helper.Helper.isValidContextForGlide; /** @@ -646,7 +647,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, } } - public static String manageMentions(Context context, String userIdReply, Status tootReply) { + public static String manageMentions(String userIdReply, Status tootReply) { String contentView = ""; //Retrieves mentioned accounts + OP and adds them at the beginin of the toot ArrayList<String> mentionedAccountsAdded = new ArrayList<>(); @@ -1340,53 +1341,57 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, it.remove(); } if (fileName != null) { - Glide.with(imageView.getContext()) - .asBitmap() - .load(fileName) - .into(new CustomTarget<Bitmap>() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { - imageView.setImageBitmap(resource); - } + if (isValidContextForGlide(imageView.getContext())) { + Glide.with(imageView.getContext()) + .asBitmap() + .load(fileName) + .into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { + imageView.setImageBitmap(resource); + } - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { - } - }); + } + }); + } } } } else { - String finalUrl = url; - Glide.with(imageView.getContext()) - .asBitmap() - .load(url) - .error(Glide.with(imageView).asBitmap().load(R.drawable.ic_audio_wave)) - .into(new CustomTarget<Bitmap>() { - @Override - public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { - imageView.setImageBitmap(resource); - if (displayWYSIWYG()) { - url_for_media = finalUrl; - Iterator it = filesMap.entrySet().iterator(); - String fileName = null; - while (it.hasNext()) { - Map.Entry pair = (Map.Entry) it.next(); - fileName = (String) pair.getKey(); - it.remove(); - } - if (fileName != null && fileName.contains("fedilabins_")) { - wysiwyg.insertImage(resource); + if (isValidContextForGlide(imageView.getContext())) { + String finalUrl = url; + Glide.with(imageView.getContext()) + .asBitmap() + .load(url) + .error(Glide.with(imageView).asBitmap().load(R.drawable.ic_audio_wave)) + .into(new CustomTarget<Bitmap>() { + @Override + public void onResourceReady(@NonNull Bitmap resource, Transition<? super Bitmap> transition) { + imageView.setImageBitmap(resource); + if (displayWYSIWYG()) { + url_for_media = finalUrl; + Iterator it = filesMap.entrySet().iterator(); + String fileName = null; + while (it.hasNext()) { + Map.Entry pair = (Map.Entry) it.next(); + fileName = (String) pair.getKey(); + it.remove(); + } + if (fileName != null && fileName.contains("fedilabins_")) { + wysiwyg.insertImage(resource); + } } } - } - @Override - public void onLoadCleared(@Nullable Drawable placeholder) { + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { - } - }); + } + }); + } } @@ -2246,8 +2251,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, if (namebar != null && namebar.getParent() != null) ((ViewGroup) namebar.getParent()).removeView(namebar); } - List<Attachment> tmp_attachment = new ArrayList<>(); - tmp_attachment.addAll(attachments); + List<Attachment> tmp_attachment = new ArrayList<>(attachments); attachments.removeAll(tmp_attachment); tmp_attachment.clear(); } @@ -2585,8 +2589,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, if (namebar != null && namebar.getParent() != null) ((ViewGroup) namebar.getParent()).removeView(namebar); } - List<Attachment> tmp_attachment = new ArrayList<>(); - tmp_attachment.addAll(attachments); + List<Attachment> tmp_attachment = new ArrayList<>(attachments); attachments.removeAll(tmp_attachment); tmp_attachment.clear(); } @@ -3069,9 +3072,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, } }); imageView.setTag(attachment.getId()); - imageView.setOnClickListener(view -> { - imageView.setOnClickListener(view1 -> showAddDescription(attachment)); - }); + imageView.setOnClickListener(view -> imageView.setOnClickListener(view1 -> showAddDescription(attachment))); imageView.setOnLongClickListener(view -> { showRemove(imageView.getId()); return false; @@ -3396,7 +3397,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate, private void displayPollPopup() { AlertDialog.Builder alertPoll = new AlertDialog.Builder(TootActivity.this, style); alertPoll.setTitle(R.string.create_poll); - View view = getLayoutInflater().inflate(R.layout.popup_poll, null); + View view = getLayoutInflater().inflate(R.layout.popup_poll, new LinearLayout(TootActivity.this), false); alertPoll.setView(view); Spinner poll_choice = view.findViewById(R.id.poll_choice); Spinner poll_duration = view.findViewById(R.id.poll_duration); |