|
|
@ -85,8 +85,6 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
private SharedPreferences bookmarksFile; |
|
|
|
private ArrayList<Bookmark> topicsBookmarked; |
|
|
|
private ArrayList<Bookmark> boardsBookmarked; |
|
|
|
private static Drawable bookmarked; |
|
|
|
private static Drawable notBookmarked; |
|
|
|
|
|
|
|
//Common UI elements
|
|
|
|
protected Toolbar toolbar; |
|
|
@ -104,18 +102,6 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
if (sessionManager == null) |
|
|
|
sessionManager = BaseApplication.getInstance().getSessionManager(); |
|
|
|
|
|
|
|
if (bookmarked == null) { |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
|
|
|
bookmarked = getResources().getDrawable(R.drawable.ic_bookmark_true_accent_24dp, null); |
|
|
|
} else //noinspection deprecation
|
|
|
|
bookmarked = getResources().getDrawable(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
} |
|
|
|
if (notBookmarked == null) { |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
|
|
|
notBookmarked = getResources().getDrawable(R.drawable.ic_bookmark_false_accent_24dp, null); |
|
|
|
} else //noinspection deprecation
|
|
|
|
notBookmarked = getResources().getDrawable(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
} |
|
|
|
if (topicsBookmarked == null || boardsBookmarked == null) { |
|
|
|
bookmarksFile = getSharedPreferences(BOOKMARKS_SHARED_PREFS, Context.MODE_PRIVATE); |
|
|
|
loadSavedBookmarks(); |
|
|
@ -506,9 +492,9 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
protected void setTopicBookmark(MenuItem thisPageBookmarkMenuButton) { |
|
|
|
this.thisPageBookmarkMenuButton = thisPageBookmarkMenuButton; |
|
|
|
if (thisPageBookmark.matchExists(topicsBookmarked)) { |
|
|
|
thisPageBookmarkMenuButton.setIcon(bookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
} else { |
|
|
|
thisPageBookmarkMenuButton.setIcon(notBookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -518,19 +504,19 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
loadSavedBookmarks(); |
|
|
|
if (thisPageBookmark.matchExists(topicsBookmarked)) { |
|
|
|
thisPageBookmarkMenuButton.setIcon(bookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
} else { |
|
|
|
thisPageBookmarkMenuButton.setIcon(notBookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected void topicMenuBookmarkClick() { |
|
|
|
if (thisPageBookmark.matchExists(topicsBookmarked)) { |
|
|
|
thisPageBookmarkMenuButton.setIcon(notBookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
toggleTopicToBookmarks(thisPageBookmark); |
|
|
|
Toast.makeText(getBaseContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
} else { |
|
|
|
thisPageBookmarkMenuButton.setIcon(bookmarked); |
|
|
|
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
toggleTopicToBookmarks(thisPageBookmark); |
|
|
|
Toast.makeText(getBaseContext(), "Bookmark added", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
@ -538,18 +524,18 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
|
|
|
|
protected void setBoardBookmark(final ImageButton thisPageBookmarkImageButton) { |
|
|
|
if (thisPageBookmark.matchExists(boardsBookmarked)) { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(bookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
} else { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(notBookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
} |
|
|
|
thisPageBookmarkImageButton.setOnClickListener(new View.OnClickListener() { |
|
|
|
@Override |
|
|
|
public void onClick(View view) { |
|
|
|
if (thisPageBookmark.matchExists(boardsBookmarked)) { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(notBookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
Toast.makeText(getBaseContext(), "Bookmark removed", Toast.LENGTH_SHORT).show(); |
|
|
|
} else { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(bookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
Toast.makeText(getBaseContext(), "Bookmark added", Toast.LENGTH_SHORT).show(); |
|
|
|
} |
|
|
|
toggleBoardToBookmarks(thisPageBookmark); |
|
|
@ -562,9 +548,9 @@ public abstract class BaseActivity extends AppCompatActivity { |
|
|
|
return; |
|
|
|
loadSavedBookmarks(); |
|
|
|
if (thisPageBookmark.matchExists(boardsBookmarked)) { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(bookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_true_accent_24dp); |
|
|
|
} else { |
|
|
|
thisPageBookmarkImageButton.setImageDrawable(notBookmarked); |
|
|
|
thisPageBookmarkImageButton.setImageResource(R.drawable.ic_bookmark_false_accent_24dp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|