|
|
@ -27,11 +27,11 @@ 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 BookmarkActivity extends BaseActivity { |
|
|
|
public class BookmarksActivity extends BaseActivity { |
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
setContentView(R.layout.activity_bookmark); |
|
|
|
setContentView(R.layout.activity_bookmarks); |
|
|
|
|
|
|
|
//Initialize toolbar
|
|
|
|
toolbar = findViewById(R.id.toolbar); |
|
|
@ -47,8 +47,8 @@ public class BookmarkActivity extends BaseActivity { |
|
|
|
|
|
|
|
//Creates the adapter that will return a fragment for each section of the activity
|
|
|
|
SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); |
|
|
|
sectionsPagerAdapter.addFragment(TopicBookmarksFragment.newInstance(1, Bookmark.arrayToString(getTopicsBookmarked())), "Topics"); |
|
|
|
sectionsPagerAdapter.addFragment(BoardBookmarksFragment.newInstance(2, Bookmark.arrayToString(getBoardsBookmarked())), "Boards"); |
|
|
|
sectionsPagerAdapter.addFragment(BookmarksTopicFragment.newInstance(1, Bookmark.arrayToString(getTopicsBookmarked())), "Topics"); |
|
|
|
sectionsPagerAdapter.addFragment(BookmarksBoardFragment.newInstance(2, Bookmark.arrayToString(getBoardsBookmarked())), "Boards"); |
|
|
|
|
|
|
|
//Sets up the ViewPager with the sections adapter.
|
|
|
|
ViewPager viewPager = findViewById(R.id.bookmarks_container); |
|
|
@ -66,8 +66,8 @@ public class BookmarkActivity extends BaseActivity { |
|
|
|
|
|
|
|
public boolean onTopicInteractionListener(String interactionType, Bookmark bookmarkedTopic) { |
|
|
|
switch (interactionType) { |
|
|
|
case TopicBookmarksFragment.INTERACTION_CLICK_TOPIC_BOOKMARK: |
|
|
|
Intent intent = new Intent(BookmarkActivity.this, TopicActivity.class); |
|
|
|
case BookmarksTopicFragment.INTERACTION_CLICK_TOPIC_BOOKMARK: |
|
|
|
Intent intent = new Intent(BookmarksActivity.this, TopicActivity.class); |
|
|
|
Bundle extras = new Bundle(); |
|
|
|
extras.putString(BUNDLE_TOPIC_URL, "https://www.thmmy.gr/smf/index.php?topic=" |
|
|
|
+ bookmarkedTopic.getId() + "." + 2147483647); |
|
|
@ -75,11 +75,11 @@ public class BookmarkActivity extends BaseActivity { |
|
|
|
intent.putExtras(extras); |
|
|
|
startActivity(intent); |
|
|
|
break; |
|
|
|
case TopicBookmarksFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: |
|
|
|
case BookmarksTopicFragment.INTERACTION_TOGGLE_TOPIC_NOTIFICATION: |
|
|
|
return toggleNotification(bookmarkedTopic); |
|
|
|
case TopicBookmarksFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: |
|
|
|
case BookmarksTopicFragment.INTERACTION_REMOVE_TOPIC_BOOKMARK: |
|
|
|
removeBookmark(bookmarkedTopic); |
|
|
|
Toast.makeText(BookmarkActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(BookmarksActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
break; |
|
|
|
} |
|
|
|
return true; |
|
|
@ -87,8 +87,8 @@ public class BookmarkActivity extends BaseActivity { |
|
|
|
|
|
|
|
public boolean onBoardInteractionListener(String interactionType, Bookmark bookmarkedBoard) { |
|
|
|
switch (interactionType) { |
|
|
|
case BoardBookmarksFragment.INTERACTION_CLICK_BOARD_BOOKMARK: |
|
|
|
Intent intent = new Intent(BookmarkActivity.this, BoardActivity.class); |
|
|
|
case BookmarksBoardFragment.INTERACTION_CLICK_BOARD_BOOKMARK: |
|
|
|
Intent intent = new Intent(BookmarksActivity.this, BoardActivity.class); |
|
|
|
Bundle extras = new Bundle(); |
|
|
|
extras.putString(BUNDLE_BOARD_URL, "https://www.thmmy.gr/smf/index.php?board=" |
|
|
|
+ bookmarkedBoard.getId() + ".0"); |
|
|
@ -96,11 +96,11 @@ public class BookmarkActivity extends BaseActivity { |
|
|
|
intent.putExtras(extras); |
|
|
|
startActivity(intent); |
|
|
|
break; |
|
|
|
case BoardBookmarksFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: |
|
|
|
case BookmarksBoardFragment.INTERACTION_TOGGLE_BOARD_NOTIFICATION: |
|
|
|
return toggleNotification(bookmarkedBoard); |
|
|
|
case BoardBookmarksFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: |
|
|
|
case BookmarksBoardFragment.INTERACTION_REMOVE_BOARD_BOOKMARK: |
|
|
|
removeBookmark(bookmarkedBoard); |
|
|
|
Toast.makeText(BookmarkActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(BookmarksActivity.this, "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
break; |
|
|
|
} |
|
|
|
return true; |