some fixes

This commit is contained in:
Thomas 2022-06-30 18:19:01 +02:00
parent d5a8612ece
commit c3f2c78678
3 changed files with 9 additions and 1 deletions

View File

@ -76,7 +76,12 @@ public class Nitter implements Serializable {
public static Status convert(Context context, String instance, FeedItem feedItem) { public static Status convert(Context context, String instance, FeedItem feedItem) {
Status status = new Status(); Status status = new Status();
Matcher matcherLink = Helper.nitterIDPattern.matcher(feedItem.link);
if (matcherLink.find()) {
status.id = matcherLink.group(1);
} else {
status.id = feedItem.pubDate; status.id = feedItem.pubDate;
}
status.content = feedItem.description; status.content = feedItem.description;
status.text = feedItem.title; status.text = feedItem.title;
status.content = status.content.replaceAll("<img [^>]*src=\"[^\"]+\"[^>]*>", ""); status.content = status.content.replaceAll("<img [^>]*src=\"[^\"]+\"[^>]*>", "");

View File

@ -284,6 +284,8 @@ public class Helper {
public static final Pattern mediumPattern = Pattern.compile("([\\w@-]*)?\\.?medium.com/@?([/\\w-]+)"); 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 wikipediaPattern = Pattern.compile("([\\w_-]+)\\.wikipedia.org/(((?!([\"'<])).)*)");
public static final Pattern codePattern = Pattern.compile("code=([\\w-]+)"); 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( 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`!()\\[\\]{};:'\".,<>?«»“”‘’]))", "(?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`!()\\[\\]{};:'\".,<>?«»“”‘’]))",

View File

@ -599,6 +599,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
statuses.pagination = new Pagination(); statuses.pagination = new Pagination();
statuses.pagination.max_id = quickLoad.statuses.get(quickLoad.statuses.size() - 1).id; statuses.pagination.max_id = quickLoad.statuses.get(quickLoad.statuses.size() - 1).id;
statuses.pagination.min_id = quickLoad.statuses.get(0).id; statuses.pagination.min_id = quickLoad.statuses.get(0).id;
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> initializeStatusesCommonView(statuses, quickLoad.position); Runnable myRunnable = () -> initializeStatusesCommonView(statuses, quickLoad.position);
mainHandler.post(myRunnable); mainHandler.post(myRunnable);