Пример #1
0
  private void handleHighlightAyah(int sura, int ayah, HighlightType type, boolean scrollToAyah) {
    mImageView.highlightAyah(sura, ayah, type);
    if (scrollToAyah && mQuranPageLayout.canScroll()) {
      final RectF highlightBounds =
          ImageAyahUtils.getYBoundsForHighlight(mCoordinatesData, sura, ayah);
      if (highlightBounds != null) {
        int screenHeight = QuranScreenInfo.getInstance().getHeight();

        Matrix matrix = mImageView.getImageMatrix();
        matrix.mapRect(highlightBounds);

        int currentScrollY = mQuranPageLayout.getCurrentScrollY();
        final boolean topOnScreen =
            highlightBounds.top > currentScrollY
                && highlightBounds.top < currentScrollY + screenHeight;
        final boolean bottomOnScreen =
            highlightBounds.bottom > currentScrollY
                && highlightBounds.bottom < currentScrollY + screenHeight;

        if (!topOnScreen || !bottomOnScreen) {
          int y = (int) highlightBounds.top - (int) (0.05 * screenHeight);
          mQuranPageLayout.smoothScrollLayoutTo(y);
        }
      }
    }
    mImageView.invalidate();
  }
Пример #2
0
  private void handleLongPress(MotionEvent event) {
    QuranAyah result = getAyahFromCoordinates(event.getX(), event.getY());
    if (result != null) {
      mImageView.highlightAyah(result.getSura(), result.getAyah());
      mImageView.invalidate();
      mImageView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);

      // TODO Temporary UI until new UI is implemented
      new ShowAyahMenuTask().execute(result.getSura(), result.getAyah(), mPageNumber);
    }
  }
Пример #3
0
 private void handleHighlightAyah(int sura, int ayah) {
   if (mImageView == null) {
     return;
   }
   mImageView.highlightAyah(sura, ayah);
   if (mScrollView != null) {
     AyahBounds yBounds = mImageView.getYBoundsForCurrentHighlight();
     if (yBounds != null) {
       int screenHeight = QuranScreenInfo.getInstance().getHeight();
       int y = yBounds.getMinY() - (int) (0.05 * screenHeight);
       mScrollView.smoothScrollTo(mScrollView.getScrollX(), y);
     }
   }
   mImageView.invalidate();
 }
 public void highlightAyah(int sura, int ayah) {
   View v = mQuranPage.getCurrentPage();
   HighlightingImageView iv = (HighlightingImageView) v.findViewById(R.id.page_image);
   if (iv != null) {
     HighlightingImageView hi = (HighlightingImageView) iv;
     hi.highlightAyah(sura, ayah);
     if (QuranSettings.getInstance().isAutoScroll()
         && v.getResources().getConfiguration().orientation
             == Configuration.ORIENTATION_LANDSCAPE) {
       AyahBounds yBounds = hi.getYBoundsForCurrentHighlight();
       if (yBounds != null) mQuranPage.scrollToAyah(R.id.page_scroller, yBounds);
     }
     mQuranPage.invalidate();
   }
 }