From e697b8edb59a6cf899a10492dd93072253af5616 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Sat, 13 Oct 2018 18:35:32 +0300 Subject: [PATCH] Minor refactoring --- .../activities/board/BoardActivity.java | 2 +- .../bookmarks/TopicBookmarksFragment.java | 23 +++++++++++-------- .../gr/thmmy/mthmmy/base/BaseActivity.java | 3 ++- app/src/main/res/values/strings.xml | 2 +- 4 files changed, 18 insertions(+), 12 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 7251a4f9..edda9537 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 @@ -94,7 +94,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo getSupportActionBar().setDisplayShowHomeEnabled(true); } - thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), false); + thisPageBookmark = new Bookmark(boardTitle, "b" + ThmmyPage.getBoardId(boardUrl), true); setBoardBookmark(findViewById(R.id.bookmark)); createDrawer(); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java index c7a14b84..54659baa 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/TopicBookmarksFragment.java @@ -20,13 +20,18 @@ import java.util.ArrayList; import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.model.Bookmark; +/** + * A {@link Fragment} subclass. + * Use the {@link TopicBookmarksFragment#newInstance} factory method to + * create an instance of this fragment. + */ public class TopicBookmarksFragment extends Fragment { protected static final String ARG_SECTION_NUMBER = "SECTION_NUMBER"; - protected static final String ARG_TOPIC_BOOKMARKS = "BOARD_BOOKMARKS"; + protected static final String ARG_TOPIC_BOOKMARKS = "TOPIC_BOOKMARKS"; - public static final String INTERACTION_CLICK_TOPIC_BOOKMARK = "CLICK_BOARD_BOOKMARK"; + public static final String INTERACTION_CLICK_TOPIC_BOOKMARK = "CLICK_TOPIC_BOOKMARK"; public static final String INTERACTION_TOGGLE_TOPIC_NOTIFICATION = "TOGGLE_TOPIC_NOTIFICATION"; - public static final String INTERACTION_REMOVE_TOPIC_BOOKMARK = "REMOVE_BOARD_BOOKMARK"; + public static final String INTERACTION_REMOVE_TOPIC_BOOKMARK = "REMOVE_TOPIC_BOOKMARK"; ArrayList topicBookmarks = null; @@ -43,11 +48,11 @@ public class TopicBookmarksFragment extends Fragment { * * @return A new instance of fragment Forum. */ - public static TopicBookmarksFragment newInstance(int sectionNumber, String boardBookmarks) { + public static TopicBookmarksFragment newInstance(int sectionNumber, String topicBookmarks) { TopicBookmarksFragment fragment = new TopicBookmarksFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); - args.putString(ARG_TOPIC_BOOKMARKS, boardBookmarks); + args.putString(ARG_TOPIC_BOOKMARKS, topicBookmarks); fragment.setArguments(args); return fragment; } @@ -56,9 +61,9 @@ public class TopicBookmarksFragment extends Fragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { - String bundledBoardBookmarks = getArguments().getString(ARG_TOPIC_BOOKMARKS); - if (bundledBoardBookmarks != null) { - topicBookmarks = Bookmark.arrayFromString(bundledBoardBookmarks); + String bundledTopicBookmarks = getArguments().getString(ARG_TOPIC_BOOKMARKS); + if (bundledTopicBookmarks != null) { + topicBookmarks = Bookmark.arrayFromString(bundledTopicBookmarks); } } @@ -78,7 +83,7 @@ public class TopicBookmarksFragment extends Fragment { Bundle savedInstanceState) { // Inflates the layout for this fragment final View rootView = layoutInflater.inflate(R.layout.fragment_bookmarks, container, false); - //bookmarks_board_container + //bookmarks_topic_container final LinearLayout bookmarksLinearView = rootView.findViewById(R.id.bookmarks_container); if(this.topicBookmarks != null && !this.topicBookmarks.isEmpty()) { diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java index 46dbdba5..e504596d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java @@ -635,7 +635,8 @@ public abstract class BaseActivity extends AppCompatActivity { FirebaseMessaging.getInstance().unsubscribeFromTopic(bookmark.getId()); return boardsBookmarked.get(bookmark.findIndex(boardsBookmarked)).isNotificationsEnabled(); - } + } else + Timber.w("No bookmark match exists!"); return false; } //-------------------------------------------BOOKMARKS END------------------------------------------ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 60a477bc..74940ff2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,7 +14,7 @@ Info OK Cancel - "To use mTHMMY you have to agree to our Privacy Policy by choosing one of the buttons below. Choose \"Yes, I want to help\", if you consent to the collection of anonymized data that will help us improve the app. Otherwise, choose \"Nope, leave me alone\". You can change your preferences any time through the app's Settings. + "To use mTHMMY you have to agree to our Privacy Policy by choosing one of the options below. Choose \"Yes, I want to help\", if you consent to the collection of anonymized data that will help us improve the app. Otherwise, choose \"Nope, leave me alone\". You can change your preferences any time through the app's Settings. thmmy.gr