Exemplo n.º 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();
  }
Exemplo n.º 2
0
 private void handlePress(MotionEvent event, EventType eventType) {
   QuranAyah result =
       ImageAyahUtils.getAyahFromCoordinates(
           mCoordinatesData, mImageView, event.getX(), event.getY());
   if (result != null && ayahSelectedListener != null) {
     SuraAyah suraAyah = new SuraAyah(result.getSura(), result.getAyah());
     ayahSelectedListener.onAyahSelected(eventType, suraAyah, this);
   }
 }
Exemplo n.º 3
0
 @Override
 public AyahToolBar.AyahToolBarPosition getToolBarPosition(
     int sura, int ayah, int toolBarWidth, int toolBarHeight) {
   final List<AyahBounds> bounds =
       mCoordinatesData == null ? null : mCoordinatesData.get(sura + ":" + ayah);
   final int screenWidth = mImageView == null ? 0 : mImageView.getWidth();
   if (bounds != null && screenWidth > 0) {
     final int screenHeight = QuranScreenInfo.getInstance().getHeight();
     AyahToolBar.AyahToolBarPosition position =
         ImageAyahUtils.getToolBarPosition(
             bounds,
             mImageView.getImageMatrix(),
             screenWidth,
             screenHeight,
             toolBarWidth,
             toolBarHeight);
     // If we're in landscape mode (wrapped in SV) update the y-offset
     position.yScroll = 0 - mQuranPageLayout.getCurrentScrollY();
     return position;
   }
   return null;
 }