public void checkBookmark(SurahName surahName) { if (GLOBAL.bookmarkedStore != null) { Set<String> bookmarkSet = null; bookmarkSet = GLOBAL.bookmarkedStore.getStringSet("bookmarkSet", null); if (bookmarkSet != null) { if (bookmarkSet.contains(surahName.getSurahNo())) { imgBookMark.setImageDrawable(context.getResources().getDrawable(R.drawable.bookmark_50)); } else { imgBookMark.setImageDrawable( context.getResources().getDrawable(R.drawable.bookmark_empty_50)); } } else { SharedPreferences.Editor editor = GLOBAL.bookmarkedStore.edit(); bookmarkSet = new HashSet<>(); editor.putStringSet("bookmarkSet", bookmarkSet); editor.commit(); checkBookmark(surahName); } } else { GLOBAL.bookmarkedStore = context.getSharedPreferences("bookmarkedStore", Context.MODE_PRIVATE); checkBookmark(surahName); } }
public void setItemText(SurahName surahName, Map<String, String> bookMarkStoreSurah) { int[] androidColors = context.getResources().getIntArray(R.array.androidcolors); int randomAndroidColor = androidColors[new Random().nextInt(androidColors.length)]; int brown_500 = context.getResources().getColor(R.color.brown_500); card.setBackgroundColor(randomAndroidColor); card.setTag(surahName); txtSurahNo.setText(surahName.getSurahNo()); txtSurahNo.setTypeface(GLOBAL.getTypefaceTrans()); txtSurahNo.setTextSize(20); txtSurahNo.setTextColor(Color.DKGRAY); txtSurahName.setText(surahName.getSurahName()); txtSurahName.setTypeface(GLOBAL.getTypefaceTrans()); txtSurahName.setTextSize(23); txtSurahName.setTextColor(randomAndroidColor); txtAyahNo.setText(surahName.getVerseNo()); txtAyahNo.setTypeface(GLOBAL.getTypefaceTrans()); txtAyahNo.setTextSize(15); txtAyahNo.setTextColor(brown_500); checkBookmark(surahName); }