From 084dd5a2d6a55b747e2d1990747bb31c7baed910 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 12 Nov 2017 20:25:40 +0200 Subject: [PATCH] Fixes for quotes dateTime and roll back on recent topics scroll to bottom --- .../mthmmy/activities/main/MainActivity.java | 2 -- .../main/recent/RecentFragment.java | 7 +++++- .../activities/topic/TopicActivity.java | 23 ++----------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java index f5fbf87d..45ea0fc9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java @@ -35,7 +35,6 @@ import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWN import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_THUMBNAIL_URL; import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_URL; import static gr.thmmy.mthmmy.activities.profile.ProfileActivity.BUNDLE_PROFILE_USERNAME; -import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_FOCUS_TO_LAST_POST; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; @@ -117,7 +116,6 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF Intent i = new Intent(MainActivity.this, TopicActivity.class); i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl()); i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getSubject()); - i.putExtra(BUNDLE_FOCUS_TO_LAST_POST, true); startActivity(i); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index 10166c30..3191cbb9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -167,7 +167,12 @@ public class RecentFragment extends BaseFragment { matcher = pattern.matcher(dateTime); if (matcher.find()) { dateTime = matcher.group(1); - dateTime = dateTime.replaceAll(":[0-5][0-9] ", " "); + if (dateTime.contains(" am") || dateTime.contains(" pm") || + dateTime.contains(" πμ") || dateTime.contains(" μμ")) { + dateTime = dateTime.replaceAll(":[0-5][0-9] ", " "); + } else { + dateTime=dateTime.substring(0,dateTime.lastIndexOf(":")); + } if (!dateTime.contains(",")) { dateTime = dateTime.replaceAll(".+? ([0-9])", "$1"); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 9210f599..ecffb2f2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -81,10 +81,6 @@ public class TopicActivity extends BaseActivity { * The key to use when putting topic's title String to {@link TopicActivity}'s Bundle. */ public static final String BUNDLE_TOPIC_TITLE = "TOPIC_TITLE"; - /** - * The key to use when activity should scroll to bottom, for example when coming from recent. - */ - public static final String BUNDLE_FOCUS_TO_LAST_POST = "BUNDLE_FOCUS_TO_LAST_POST"; private static TopicTask topicTask; private MaterialProgressBar progressBar; private TextView toolbarTitle; @@ -107,7 +103,6 @@ public class TopicActivity extends BaseActivity { * bundle one and gets rendered in the toolbar. */ private String parsedTitle; - private Boolean focusToLastPost; private RecyclerView recyclerView; /** * Holds the url of this page @@ -208,7 +203,6 @@ public class TopicActivity extends BaseActivity { Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show(); finish(); } - focusToLastPost = extras.getBoolean(BUNDLE_FOCUS_TO_LAST_POST); thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl)); @@ -649,10 +643,6 @@ public class TopicActivity extends BaseActivity { pageIndicator.setText(String.valueOf(thisPage) + "/" + String.valueOf(numberOfPages)); pageRequestValue = thisPage; - if (focusToLastPost) { - recyclerView.scrollToPosition(postsList.size() - 1); - } - paginationEnabled(true); break; case NETWORK_ERROR: @@ -820,17 +810,8 @@ public class TopicActivity extends BaseActivity { try { Response response = client.newCall(request).execute(); - document = Jsoup.parse(response.body().string()); - String html = document.outerHtml(); - if (Build.VERSION.SDK_INT >= 24) { - buildedQuotes += Html.fromHtml( - html.substring(html.indexOf(""), html.indexOf("")), - Html.FROM_HTML_MODE_LEGACY).toString(); - } else { - buildedQuotes += Html.fromHtml( - html.substring(html.indexOf(""), html.indexOf(""))) - .toString(); - } + String body = response.body().string(); + buildedQuotes += body.substring(body.indexOf("") + 7, body.indexOf("")); buildedQuotes += "\n\n"; } catch (IOException | Selector.SelectorParseException e) { Timber.e(e, "Quote building failed.");