From daccf9df6a70b1b3fd106465bcc9a063c8db804b Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 18 Jun 2020 19:27:29 +0300 Subject: [PATCH] Bookmarks small fix --- .../java/gr/thmmy/mthmmy/activities/board/BoardActivity.java | 2 +- .../thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java | 2 -- .../thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java | 1 + .../java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java | 5 ++++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java index aedda58b..e9111365 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java @@ -327,7 +327,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo || !Objects.equals(boardTitle, parsedTitle)) { boardTitle = parsedTitle; toolbar.setTitle(boardTitle); - thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), true); + thisPageBookmark = new Bookmark(boardTitle, thisPageBookmark.getId(), thisPageBookmark.isNotificationsEnabled()); setBoardBookmark(findViewById(R.id.bookmark)); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java index ef2b79b6..7054db43 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksActivity.java @@ -26,8 +26,6 @@ import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE; import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; -//TODO proper handling with adapter etc. -//TODO after clicking bookmark and then back button should return to this activity public class BookmarksActivity extends BaseActivity { private static final String TOPIC_URL = "https://www.thmmy.gr/smf/index.php?topic="; private static final String BOARD_URL = "https://www.thmmy.gr/smf/index.php?board="; diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java index 23562e0d..cdd6f714 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarksFragment.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.model.Bookmark; +//TODO refactor using RecyclerView public class BookmarksFragment extends Fragment { enum Type {TOPIC, BOARD} private static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; 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 f9145be5..907b1fb6 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 @@ -155,6 +155,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo } topicPageUrl = ThmmyPage.sanitizeTopicUrl(topicPageUrl); + //TODO if topicTitle provided is null make bookmark button unclickable until title is fetched (also for BoardActivity) thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl), true); //Initializes graphics @@ -671,8 +672,10 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo }); viewModel.getTopicTitle().observe(this, newTopicTitle -> { if (newTopicTitle == null) return; - if (!TextUtils.equals(toolbarTitle.getText(), newTopicTitle)) + if (!TextUtils.equals(toolbarTitle.getText(), newTopicTitle)) { + thisPageBookmark = new Bookmark(newTopicTitle, thisPageBookmark.getId(), thisPageBookmark.isNotificationsEnabled()); toolbarTitle.setText(newTopicTitle); + } }); viewModel.getPageTopicId().observe(this, pageTopicId -> { if (pageTopicId == null) return;