-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viewing new rub3 permenantly instead of just poping it up #687
Changes from all commits
95f65cc
1d9f8cf
16afeda
a179690
efb02e6
95505a4
251c19d
35ef9a1
e22a589
de92385
cf7a95f
84b8054
dc50e55
67f7c2c
008cf28
a73abc3
ae6ed35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
import com.quran.labs.androidquran.ui.helpers.AyahSelectedListener; | ||
import com.quran.labs.androidquran.ui.helpers.AyahTracker; | ||
import com.quran.labs.androidquran.ui.helpers.HighlightType; | ||
import com.quran.labs.androidquran.ui.helpers.QuranDisplayHelper; | ||
import com.quran.labs.androidquran.ui.helpers.QuranPageWorker; | ||
import com.quran.labs.androidquran.ui.util.ImageAyahUtils; | ||
import com.quran.labs.androidquran.ui.util.PageController; | ||
|
@@ -319,16 +320,18 @@ protected void onPostExecute(RectF[] rect) { | |
if (mRightImageView != null && mLeftImageView != null) { | ||
mRightImageView.setPageBounds(rect[0]); | ||
mLeftImageView.setPageBounds(rect[1]); | ||
Context context = getContext(); | ||
if (mOverlayText && context != null) { | ||
if (mOverlayText && isAdded()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1! Now, since context is not used outside, you could move There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May Allah rewards you for your great effort in improving this app. |
||
Context context = getContext(); | ||
String suraText = QuranInfo.getSuraNameFromPage(context, mPageNumber - 1, true); | ||
String juzText = QuranInfo.getJuzString(context, mPageNumber - 1); | ||
String pageText = QuranUtils.getLocalizedNumber(context, mPageNumber - 1); | ||
mRightImageView.setOverlayText(suraText, juzText, pageText); | ||
String rub3Text =QuranDisplayHelper.displayRub3(context,mPageNumber - 1); | ||
mRightImageView.setOverlayText(suraText, juzText, pageText, rub3Text); | ||
suraText = QuranInfo.getSuraNameFromPage(context, mPageNumber, true); | ||
juzText = QuranInfo.getJuzString(context, mPageNumber); | ||
pageText = QuranUtils.getLocalizedNumber(context, mPageNumber); | ||
mLeftImageView.setOverlayText(suraText, juzText, pageText); | ||
rub3Text = QuranDisplayHelper.displayRub3(context,mPageNumber); | ||
mLeftImageView.setOverlayText(suraText, juzText, pageText, rub3Text); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,29 @@ public static long displayMarkerPopup(Context context, int page, | |
return System.currentTimeMillis(); | ||
} | ||
|
||
// same logic used in displayMarkerPopup method | ||
public static String displayRub3(Context context, int page){ | ||
int rub3 = QuranInfo.getRub3FromPage(page); | ||
if (rub3 == -1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do this check earlier (right after line 78)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
return ""; | ||
} | ||
int hizb = (rub3 / 4) + 1; | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(" , "); | ||
int remainder = rub3 % 4; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the sake of readability (just a suggestion):
|
||
if (remainder == 1) { | ||
sb.append(context.getString(R.string.quran_rob3)).append(' '); | ||
} else if (remainder == 2) { | ||
sb.append(context.getString(R.string.quran_nos)).append(' '); | ||
} else if (remainder == 3) { | ||
sb.append(context.getString(R.string.quran_talt_arb3)).append(' '); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it has too many magic number here, it will be better and more readable if we define 1, 2, 3 as constant variable. |
||
sb.append(context.getString(R.string.quran_hizb)).append(' ') | ||
.append(QuranUtils.getLocalizedNumber(context, hizb)); | ||
|
||
return sb.toString(); | ||
} | ||
|
||
public static PaintDrawable getPaintDrawable(int startX, int endX) { | ||
PaintDrawable drawable = new PaintDrawable(); | ||
drawable.setShape(new RectShape()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1!
There is no point in checking if context is null. If it is null, then something is seriously broken beyond repair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i intentionally added that null check because we were having crashes due to this, so please re-add this back.
because this is in
onPostExecute
, we can easily have a case where the fragment is killed before theAsyncTask
finishes - when theAsyncTask
is done, there is nocontext
because theFragment
is gone, so we should just bail - by not doing this check, we'll crash in the next few lines where we try to use the context to get sura names, etc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
I think, for that scenario, checking if fragment is being removed (
isRemoving()
) or if it is visible (isVisible()
) would fit better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call, i agree. in
QuranPageFragment
, we're checkingisAdded()
and that seems to be working fine (no crash there), so am good with wrapping the entire block with anisAdded()
check.