-
Notifications
You must be signed in to change notification settings - Fork 883
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
Conversation
} | ||
|
||
public void setOverlayText(String suraText, String juzText, String pageText) { | ||
public void setOverlayText(String suraText, String juzText, String pageText,String rub3Text) { |
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.
space
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.
Please check the code style and adhere to the rules used in existing code.
@@ -178,6 +181,7 @@ public void setOverlayText(String suraText, String juzText, String pageText) { | |||
mOverlayParams.suraText = suraText; | |||
mOverlayParams.juzText = juzText; | |||
mOverlayParams.pageText = pageText; | |||
mOverlayParams.rub3Text=rub3Text; |
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.
space
canvas.drawText(mOverlayParams.rub3Text, | ||
getWidth() / 2.0f, mOverlayParams.topBaseline, | ||
mOverlayParams.paint); | ||
} |
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.
space: does not seem to align with other lines
@@ -39,6 +39,29 @@ public static Response getQuranPage(OkHttpClient okHttpClient, | |||
return response; | |||
} | |||
|
|||
// same logic used in displayMarkerPopup method | |||
public static String displayRub3(Context context, int page) | |||
{ |
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.
Please use the same line as method declaration for opening bracket
@@ -39,6 +39,29 @@ public static Response getQuranPage(OkHttpClient okHttpClient, | |||
return response; | |||
} | |||
|
|||
// same logic used in displayMarkerPopup method |
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 think, for this comment to make sense, displayRub3()
needs to come below/after displayMarkerPopup()
@@ -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) { |
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 the AsyncTask
finishes - when the AsyncTask
is done, there is no context
because the Fragment
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 checking isAdded()
and that seems to be working fine (no crash there), so am good with wrapping the entire block with an isAdded()
check.
i am not against this patch conceptually, but have a few suggestions (aside from addressing the comments) - i think this will look strange in the top middle. my suggestion instead is either: |
(oh, and most importantly, jazakumAllah khairan for doing this!) |
First, I'm sorry about not following some styling rules. |
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.
changes done
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.
spacing change done
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.
Removed unnecessary duplicate and clarified more on the comment
@@ -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) { |
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.
Please add isAdded()
check.
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.
oh, sorry I totally forgot that.
now added.
int hizb = (rub3 / 4) + 1; | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(" , "); | ||
if (rub3 == -1) { |
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.
Can we do this check earlier (right after line 78)?
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.
Done.
if (rub3 == -1) { | ||
return ""; | ||
} | ||
int remainder = rub3 % 4; |
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.
For the sake of readability (just a suggestion):
switch(rub3%4) {
case 1:
sb.append(context.getString(R.string.quran_rob3)).append(' ');
break;
case 2:
sb.append(context.getString(R.string.quran_nos)).append(' ');
break;
case 3:
sb.append(context.getString(R.string.quran_talt_arb3)).append(' ');
break;
default: // case 0
// do nothing
}
No need for this check, as it's already checked in 'QuranDisplayHelper.displayRub3' method
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.
edited
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 comment
The 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.
@@ -320,15 +321,17 @@ protected void onPostExecute(RectF[] rect) { | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
+1! Now, since context is not used outside, you could move Context context = getContext();
to inside the brackets (your original change). Sorry for sounding like nitpicking :(
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.
May Allah rewards you for your great effort in improving this app.
@@ -178,6 +181,7 @@ public void setOverlayText(String suraText, String juzText, String pageText) { | |||
mOverlayParams.suraText = suraText; | |||
mOverlayParams.juzText = juzText; | |||
mOverlayParams.pageText = pageText; | |||
mOverlayParams.rub3Text=rub3Text; |
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.
spacing is not fixed yet
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.
Now fixed
merging to unblock, jazakAllah khairan. |
Asalamu 3alaikum,
The current situation:
When the user reaches a new rub3, a toast will pop up showing this rub3 number. If the user took some time reading the current page and wanted to know in which rub3 he was, he has to swipe left and then swipe right to show the toast again and I think that this is not user-friendly.
The suggested change:
There is a space in the top middle of the page, so why we don't show the current rub3 in this space upon reaching it.
Wa jazakum allaho khairan.