diff --git a/app/src/main/java/app/fedilab/android/client/entities/nitter/Nitter.java b/app/src/main/java/app/fedilab/android/client/entities/nitter/Nitter.java index 2241b13c..afc88ee4 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/nitter/Nitter.java +++ b/app/src/main/java/app/fedilab/android/client/entities/nitter/Nitter.java @@ -76,7 +76,12 @@ public class Nitter implements Serializable { public static Status convert(Context context, String instance, FeedItem feedItem) { Status status = new Status(); - status.id = feedItem.pubDate; + Matcher matcherLink = Helper.nitterIDPattern.matcher(feedItem.link); + if (matcherLink.find()) { + status.id = matcherLink.group(1); + } else { + status.id = feedItem.pubDate; + } status.content = feedItem.description; status.text = feedItem.title; status.content = status.content.replaceAll("]*src=\"[^\"]+\"[^>]*>", ""); 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 6d5454d5..01049b3b 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -284,6 +284,8 @@ public class Helper { public static final Pattern mediumPattern = Pattern.compile("([\\w@-]*)?\\.?medium.com/@?([/\\w-]+)"); public static final Pattern wikipediaPattern = Pattern.compile("([\\w_-]+)\\.wikipedia.org/(((?!([\"'<])).)*)"); public static final Pattern codePattern = Pattern.compile("code=([\\w-]+)"); + public static final Pattern nitterIDPattern = Pattern.compile("/status/(\\d+)"); + public static final Pattern urlPattern = Pattern.compile( "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,10}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))", diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java index 10fd7ad6..974dbba5 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/timeline/FragmentMastodonTimeline.java @@ -599,6 +599,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter. statuses.pagination = new Pagination(); statuses.pagination.max_id = quickLoad.statuses.get(quickLoad.statuses.size() - 1).id; statuses.pagination.min_id = quickLoad.statuses.get(0).id; + Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> initializeStatusesCommonView(statuses, quickLoad.position); mainHandler.post(myRunnable);