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