Ejemplo n.º 1
0
 private QuranRow createRow(Activity activity, long tagId, Bookmark bookmark) {
   QuranRow row;
   if (bookmark.mSura == null) {
     int sura = QuranInfo.getSuraNumberFromPage(bookmark.mPage);
     row =
         new QuranRow(
             QuranInfo.getSuraNameString(activity, bookmark.mPage),
             QuranInfo.getPageSubtitle(activity, bookmark.mPage),
             QuranRow.PAGE_BOOKMARK,
             sura,
             bookmark.mPage,
             R.drawable.bookmark_page);
   } else {
     row =
         new QuranRow(
             QuranInfo.getAyahString(bookmark.mSura, bookmark.mAyah, getActivity()),
             QuranInfo.getPageSubtitle(activity, bookmark.mPage),
             QuranRow.AYAH_BOOKMARK,
             bookmark.mSura,
             bookmark.mAyah,
             bookmark.mPage,
             R.drawable.bookmark_ayah);
   }
   row.tagId = tagId;
   row.bookmarkId = bookmark.mId;
   return row;
 }
Ejemplo n.º 2
0
  private void showAyahMenu(final int sura, final int ayah, final int page, boolean bookmarked) {
    final Activity activity = getActivity();
    if (activity == null) {
      return;
    }

    int[] optionIds = {
      bookmarked ? R.string.unbookmark_ayah : R.string.bookmark_ayah,
      R.string.tag_ayah,
      R.string.translation_ayah,
      R.string.share_ayah,
      R.string.share_ayah_text,
      R.string.copy_ayah,
      R.string.play_from_here
      /*, R.string.ayah_notes*/ }; // TODO Enable notes
    CharSequence[] options = new CharSequence[optionIds.length];
    for (int i = 0; i < optionIds.length; i++) {
      options[i] = activity.getString(optionIds[i]);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(QuranInfo.getAyahString(sura, ayah, activity));
    builder
        .setItems(
            options,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int selection) {
                if (selection == 0) {
                  if (activity != null && activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    pagerActivity.toggleBookmark(sura, ayah, page);
                  }
                } else if (selection == 1) {
                  if (activity != null && activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    FragmentManager fm = pagerActivity.getSupportFragmentManager();
                    TagBookmarkDialog tagBookmarkDialog = new TagBookmarkDialog(sura, ayah, page);
                    tagBookmarkDialog.show(fm, TagBookmarkDialog.TAG);
                  }
                } else if (selection == 2) {
                  mCurrentTask = new ShowTafsirTask(sura, ayah).execute();
                } else if (selection == 3) {
                  mCurrentTask = new ShareQuranApp().execute(sura, ayah);
                } else if (selection == 4) {
                  mCurrentTask = new ShareAyahTask(sura, ayah, false).execute();
                } else if (selection == 5) {
                  mCurrentTask = new ShareAyahTask(sura, ayah, true).execute();
                } else if (selection == 6) {
                  if (activity instanceof PagerActivity) {
                    PagerActivity pagerActivity = (PagerActivity) activity;
                    pagerActivity.playFromAyah(mPageNumber, sura, ayah);
                  }
                }
                /* else if (selection == 5) {
                             new ShowNotesTask(sura, ayah).execute();
                } */
              }
            })
        .setOnCancelListener(
            new DialogInterface.OnCancelListener() {
              @Override
              public void onCancel(DialogInterface dialogInterface) {
                dialogInterface.dismiss();
                mTranslationDialog = null;
              }
            });

    mTranslationDialog = builder.create();
    mTranslationDialog.show();
  }