Skip to content

Commit

Permalink
Use correct locale for bookmarked ayahs. Cleanup.
Browse files Browse the repository at this point in the history
Cleanup dialogs to use dismiss instead of getting the internal dialog
and calling dismiss on that. Also call dismissAllowStateLoss when
dismissing in onPostExecute.
  • Loading branch information
ahmedre committed Apr 12, 2015
1 parent f2b19aa commit e20ed11
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -76,15 +78,15 @@ public void onClick(DialogInterface dialog, int which) {
}
}

dialog.dismiss();
dismiss();
}
});

return builder.create();
}

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,6 +35,7 @@ public class JumpFragment extends DialogFragment {
public JumpFragment() {
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Activity activity = getActivity();
Expand All @@ -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]);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -410,7 +412,7 @@ protected void onPostExecute(Void result) {
}

if (mShouldDismiss) {
dismiss();
dismissAllowingStateLoss();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ private QuranRow[] getTags(){
}
List<Bookmark> bookmarks = adapter.getBookmarks(true);

List<QuranRow> rows = new ArrayList<QuranRow>();
List<QuranRow> rows = new ArrayList<>();

List<Bookmark> unTagged = new ArrayList<Bookmark>();
List<Bookmark> unTagged = new ArrayList<>();
LongSparseArray<List<Bookmark>> tagMap =
new LongSparseArray<List<Bookmark>>();
new LongSparseArray<>();

for (Bookmark bookmark : bookmarks){
List<Tag> bookmarkTags = bookmark.mTags;
Expand All @@ -144,7 +144,7 @@ private QuranRow[] getTags(){
for (Tag tag : bookmarkTags) {
List <Bookmark> tagBookmarkList = tagMap.get(tag.mId);
if (tagBookmarkList == null) {
List<Bookmark> newList = new ArrayList<Bookmark>();
List<Bookmark> newList = new ArrayList<>();
newList.add(bookmark);
tagMap.put(tag.mId, newList);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e20ed11

Please sign in to comment.