From 231b29987d170e83a4662ef7af37918c9c329836 Mon Sep 17 00:00:00 2001 From: Arne Date: Sun, 7 Apr 2024 10:48:15 +0200 Subject: [PATCH] Possible fix crash on image preview from image link --- .../conversations/ui/widget/RichLinkView.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/widget/RichLinkView.java b/src/main/java/eu/siacs/conversations/ui/widget/RichLinkView.java index 7fe1810f14..859e1244ad 100644 --- a/src/main/java/eu/siacs/conversations/ui/widget/RichLinkView.java +++ b/src/main/java/eu/siacs/conversations/ui/widget/RichLinkView.java @@ -63,7 +63,6 @@ public class RichLinkView extends RelativeLayout { this.context = context; } - @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public RichLinkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); this.context = context; @@ -91,7 +90,7 @@ public class RichLinkView extends RelativeLayout { quoteMessage = findViewById(R.id.quote_message); quoteMessage.setBackgroundColor(color); imageView.setAdjustViewBounds(true); - if (meta.getImageurl() != null && !meta.getImageurl().equals("") && !meta.getImageurl().isEmpty()) { + if (meta != null && meta.getImageurl() != null && !meta.getImageurl().equals("") && !meta.getImageurl().isEmpty() && imageView != null) { if (!dataSaverDisabled) { Glide.with(this).load(R.drawable.ic_web_grey600_48).into(imageView); } else { @@ -105,23 +104,19 @@ public class RichLinkView extends RelativeLayout { .into(imageView); } } else { - imageView.setVisibility(VISIBLE); - Glide.with(this) + if (imageView != null) { + imageView.setVisibility(VISIBLE); + Glide.with(this) .load(R.drawable.ic_web_grey600_48) .into(imageView); + } } - if (meta.getTitle().isEmpty() || meta.getTitle().equals("")) { + if (meta != null && (meta.getTitle().isEmpty() || meta.getTitle().equals(""))) { textViewTitle.setVisibility(VISIBLE); textViewTitle.setText(meta.getUrl()); - } else { - textViewTitle.setVisibility(VISIBLE); - textViewTitle.setText(meta.getTitle()); } - if (meta.getDescription().isEmpty() || meta.getDescription().equals("")) { + if (meta != null && (meta.getDescription().isEmpty() || meta.getDescription().equals(""))) { textViewDesp.setVisibility(GONE); - } else { - textViewDesp.setVisibility(VISIBLE); - textViewDesp.setText(meta.getDescription()); } linearLayout.setOnClickListener(view -> {