Commit 7da253ac authored by Thomas's avatar Thomas
Browse files

- Fix crashes in status cache and timeline helper

parent fddccd72
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ public class StatusCache {
        Gson gson = new Gson();
        try {
            return gson.toJson(mastodon_status);
        } catch (Exception e) {
        } catch (Throwable e) {
            return null;
        }
    }
@@ -100,7 +100,7 @@ public class StatusCache {
        Gson gson = new Gson();
        try {
            return gson.toJson(mastodon_notification);
        } catch (Exception e) {
        } catch (Throwable e) {
            return null;
        }
    }
@@ -115,7 +115,7 @@ public class StatusCache {
        Gson gson = new Gson();
        try {
            return gson.toJson(mastodon_conversation);
        } catch (Exception e) {
        } catch (Throwable e) {
            return null;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -2027,7 +2027,7 @@ public class Helper {

                    @Override
                    public void federatedAccount(app.fedilab.android.mastodon.client.entities.api.Account account) {
                        if (account != null && account.username.equalsIgnoreCase("apps")) {
                        if (account != null && "apps".equalsIgnoreCase(account.username)) {

                            MastodonHelper.loadPPMastodon(binding.accountContainer.avatar, account);
                            binding.accountContainer.displayName.setText(account.display_name);
+6 −4
Original line number Diff line number Diff line
@@ -403,11 +403,12 @@ public class SpannableHelper {
                Matcher matcher = Pattern.compile(key, Pattern.LITERAL)
                        .matcher(content);
                while (matcher.find()) {
                    content.setSpan(customEmoji, matcher.start(), matcher.end(), 0);
                    CustomEmoji spanEmoji = new CustomEmoji(new WeakReference<>(view));
                    content.setSpan(spanEmoji, matcher.start(), matcher.end(), 0);
                    Glide.with(view)
                            .asDrawable()
                            .load(url)
                            .into(customEmoji.getTarget(animate, null));
                            .into(spanEmoji.getTarget(animate, null, url));
                }
            }

@@ -1037,10 +1038,11 @@ public class SpannableHelper {
                    CustomEmoji customEmoji = new CustomEmoji(new WeakReference<>(viewWeakReference.get()));
                    content.setSpan(customEmoji, matcher.start(), matcher.end(), 0);
                    if (Helper.isValidContextForGlide(activity)) {
                        String emojiUrl = animate ? emoji.url : emoji.static_url;
                        Glide.with(viewWeakReference.get())
                                .asDrawable()
                                .load(animate ? emoji.url : emoji.static_url)
                                .into(customEmoji.getTarget(animate, null));
                                .load(emojiUrl)
                                .into(customEmoji.getTarget(animate, null, emojiUrl));
                    }
                }
            }
+1 −4
Original line number Diff line number Diff line
@@ -278,9 +278,6 @@ public class TimelineHelper {
            return "";
        }
        try {
            if (rawContent.length() > MAX_CONTENT_LENGTH) {
                rawContent = rawContent.substring(0, MAX_CONTENT_LENGTH);
            }
            String content;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                content = Html.fromHtml(rawContent, Html.FROM_HTML_MODE_LEGACY).toString();
@@ -301,7 +298,7 @@ public class TimelineHelper {
            }
            return content;
        } catch (Throwable e) {
            return rawContent.replaceAll("<[^>]*>", " ").replaceAll("\\s+", " ").trim();
            return rawContent.replaceAll("(?i)<br\\s*/?>", "\n").replaceAll("(?i)</p>", "\n").replaceAll("<[^>]*>", " ").replaceAll(" +", " ").trim();
        }
    }