diff --git a/app/src/main/java/com/quran/labs/androidquran/data/QuranInfo.java b/app/src/main/java/com/quran/labs/androidquran/data/QuranInfo.java index ae8fb8065f..09172ec61e 100644 --- a/app/src/main/java/com/quran/labs/androidquran/data/QuranInfo.java +++ b/app/src/main/java/com/quran/labs/androidquran/data/QuranInfo.java @@ -624,9 +624,9 @@ public static int getPosFromPage(int page, boolean dual) { return position; } - public static String getAyahString(int sura, int ayah, Context cx){ - return getSuraName(cx, sura, true) + " - " - + getAyahTitle(cx) + " " + ayah; + public static String getAyahString(int sura, int ayah, Context context){ + return getSuraName(context, sura, true) + " - " + getAyahTitle(context) + + " " + QuranUtils.getLocalizedNumber(context, ayah); } public static String getSuraNameString(Context context, int page){ diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AddTagDialog.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AddTagDialog.java index afd29513a4..3634105c95 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AddTagDialog.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/AddTagDialog.java @@ -7,6 +7,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; @@ -30,6 +31,7 @@ public static AddTagDialog newInstance(long id, String name) { public AddTagDialog(){ } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Bundle args = getArguments(); @@ -76,7 +78,7 @@ public void onClick(DialogInterface dialog, int which) { } } - dialog.dismiss(); + dismiss(); } }); @@ -84,7 +86,7 @@ public void onClick(DialogInterface dialog, int which) { } public interface OnTagChangedListener { - public void onTagAdded(String name); - public void onTagUpdated(long id, String name); + void onTagAdded(String name); + void onTagUpdated(long id, String name); } } diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java index fe2de942f8..a5d76fcf08 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/JumpFragment.java @@ -15,6 +15,7 @@ import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.text.TextUtils; import android.util.Log; @@ -34,6 +35,7 @@ public class JumpFragment extends DialogFragment { public JumpFragment() { } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Activity activity = getActivity(); @@ -47,7 +49,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { final SpinnerCompat suraSpinner = (SpinnerCompat) layout.findViewById(R.id.sura_spinner); String[] suras = activity.getResources().getStringArray(R.array.sura_names); StringBuilder sb = new StringBuilder(); - for (int i = 1; i < suras.length; i++) { + for (int i = 0; i < suras.length; i++) { sb.append(QuranUtils.getLocalizedNumber(activity, (i + 1))); sb.append(". "); sb.append(suras[i]); @@ -80,10 +82,7 @@ public View getDropDownView(int position, View convertView, ViewGroup parent) { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { boolean handled = false; if (actionId == EditorInfo.IME_ACTION_GO) { - Dialog dialog = getDialog(); - if (dialog != null && dialog.isShowing()) { - dialog.dismiss(); - } + dismiss(); goToPage(input.getText().toString()); handled = true; } @@ -152,7 +151,7 @@ public void onNothingSelected(AdapterViewCompat arg0) { @Override public void onClick(DialogInterface dialog, int which) { try { - dialog.dismiss(); + dismiss(); String text = input.getText().toString(); if (TextUtils.isEmpty(text)) { text = input.getHint().toString(); diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagBookmarkDialog.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagBookmarkDialog.java index 645537ce9d..9eef605480 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagBookmarkDialog.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagBookmarkDialog.java @@ -14,6 +14,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Parcelable; +import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; @@ -178,6 +179,7 @@ else if (tag.mId == -1) { return listview; } + @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); @@ -410,7 +412,7 @@ protected void onPostExecute(Void result) { } if (mShouldDismiss) { - dismiss(); + dismissAllowingStateLoss(); } } } diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagsFragment.java b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagsFragment.java index fe73078a21..c047260617 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagsFragment.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/fragment/TagsFragment.java @@ -130,11 +130,11 @@ private QuranRow[] getTags(){ } List bookmarks = adapter.getBookmarks(true); - List rows = new ArrayList(); + List rows = new ArrayList<>(); - List unTagged = new ArrayList(); + List unTagged = new ArrayList<>(); LongSparseArray> tagMap = - new LongSparseArray>(); + new LongSparseArray<>(); for (Bookmark bookmark : bookmarks){ List bookmarkTags = bookmark.mTags; @@ -144,7 +144,7 @@ private QuranRow[] getTags(){ for (Tag tag : bookmarkTags) { List tagBookmarkList = tagMap.get(tag.mId); if (tagBookmarkList == null) { - List newList = new ArrayList(); + List newList = new ArrayList<>(); newList.add(bookmark); tagMap.put(tag.mId, newList); } else { diff --git a/app/src/main/java/com/quran/labs/androidquran/ui/helpers/FragmentStatePagerAdapter.java b/app/src/main/java/com/quran/labs/androidquran/ui/helpers/FragmentStatePagerAdapter.java index d4e1e9c1d8..131657a824 100644 --- a/app/src/main/java/com/quran/labs/androidquran/ui/helpers/FragmentStatePagerAdapter.java +++ b/app/src/main/java/com/quran/labs/androidquran/ui/helpers/FragmentStatePagerAdapter.java @@ -18,6 +18,8 @@ * Modified for Quran * Modifications List (for ease of merging with upstream later on): * - added getFragmentIfExists() to return a fragment without recreating it + * - catch IllegalStateException in destroyItem + * - catch IllegalStateException in finishUpdate */ import android.os.Bundle;