Browse Source

Board bookmarks hotfix

pull/61/merge
Ezerous 6 years ago
parent
commit
2cf704b693
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  2. 10
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

6
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -10,7 +10,6 @@ import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.View; import android.view.View;
import android.widget.ImageButton;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
@ -94,7 +93,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);
} }
thisPageBookmark = new Bookmark(boardTitle, "b" + ThmmyPage.getBoardId(boardUrl), true); thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), true);
setBoardBookmark(findViewById(R.id.bookmark)); setBoardBookmark(findViewById(R.id.bookmark));
createDrawer(); createDrawer();
@ -318,7 +317,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
|| !Objects.equals(boardTitle, parsedTitle)) { || !Objects.equals(boardTitle, parsedTitle)) {
boardTitle = parsedTitle; boardTitle = parsedTitle;
toolbar.setTitle(boardTitle); toolbar.setTitle(boardTitle);
thisPageBookmark = new Bookmark(boardTitle, "b" + ThmmyPage.getBoardId(boardUrl), true); thisPageBookmark = new Bookmark(boardTitle, ThmmyPage.getBoardId(boardUrl), true);
setBoardBookmark(findViewById(R.id.bookmark));
} }
parsedTopics.clear(); parsedTopics.clear();

10
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -575,10 +575,10 @@ public abstract class BaseActivity extends AppCompatActivity {
if (boardsBookmarked == null) return; if (boardsBookmarked == null) return;
if (bookmark.matchExists(boardsBookmarked)) { if (bookmark.matchExists(boardsBookmarked)) {
boardsBookmarked.remove(bookmark.findIndex(boardsBookmarked)); boardsBookmarked.remove(bookmark.findIndex(boardsBookmarked));
FirebaseMessaging.getInstance().unsubscribeFromTopic(bookmark.getId()); FirebaseMessaging.getInstance().unsubscribeFromTopic("b" + bookmark.getId());
} else { } else {
boardsBookmarked.add(new Bookmark(bookmark.getTitle(), bookmark.getId(), false)); boardsBookmarked.add(new Bookmark(bookmark.getTitle(), bookmark.getId(), true));
FirebaseMessaging.getInstance().subscribeToTopic(bookmark.getId()); FirebaseMessaging.getInstance().subscribeToTopic("b" + bookmark.getId());
} }
updateBoardBookmarks(); updateBoardBookmarks();
} }
@ -630,9 +630,9 @@ public abstract class BaseActivity extends AppCompatActivity {
updateBoardBookmarks(); updateBoardBookmarks();
if (boardsBookmarked.get(bookmark.findIndex(boardsBookmarked)).isNotificationsEnabled()) if (boardsBookmarked.get(bookmark.findIndex(boardsBookmarked)).isNotificationsEnabled())
FirebaseMessaging.getInstance().subscribeToTopic(bookmark.getId()); FirebaseMessaging.getInstance().subscribeToTopic("b" + bookmark.getId());
else else
FirebaseMessaging.getInstance().unsubscribeFromTopic(bookmark.getId()); FirebaseMessaging.getInstance().unsubscribeFromTopic("b" + bookmark.getId());
return boardsBookmarked.get(bookmark.findIndex(boardsBookmarked)).isNotificationsEnabled(); return boardsBookmarked.get(bookmark.findIndex(boardsBookmarked)).isNotificationsEnabled();
} else } else

Loading…
Cancel
Save