@Override protected BitmapDrawable doInBackground(Integer... params) { data = params[0]; Bitmap bitmap = QuranDisplayHelper.getQuranPage(mContext, mWidthParam, data); if (bitmap == null) { if (QuranScreenInfo.getInstance().isTablet(mContext)) { Log.w(TAG, "tablet got bitmap null, trying alternate width..."); String param = QuranScreenInfo.getInstance().getWidthParam(); if (param.equals(mWidthParam)) { param = QuranScreenInfo.getInstance().getTabletWidthParam(); } bitmap = QuranDisplayHelper.getQuranPage(mContext, param, data); if (bitmap == null) { Log.w(TAG, "bitmap still null, giving up..."); } } Log.w(TAG, "got bitmap back as null..."); } BitmapDrawable drawable = null; if (bitmap != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { drawable = new BitmapDrawable(mResources, bitmap); } else { drawable = new RecyclingBitmapDrawable(mResources, bitmap); } addBitmapToCache(data + mWidthParam, drawable); } return drawable; }
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(); }
private void downloadImage() { final Activity activity = getActivity(); if (activity instanceof PagerActivity) { QuranPageWorker worker = ((PagerActivity) activity).getQuranPageWorker(); pageLoadTask = worker.loadPage( QuranScreenInfo.getInstance().getWidthParam(), pageNumber, QuranPageFragment.this); } }
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(); }
@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; }
GetAyahCoordsTask(Context context, int sura, int ayah, HighlightType type) { super(context, QuranScreenInfo.getInstance().getWidthParam(), sura, ayah, type); }
GetAyahCoordsTask(Context context, MotionEvent event, EventType eventType) { super(context, event, eventType, QuranScreenInfo.getInstance().getWidthParam(), pageNumber); }
GetAyahCoordsTask(Context context) { super(context, QuranScreenInfo.getInstance().getWidthParam()); }
QueryPageCoordinatesTask(Context context) { super(context, QuranScreenInfo.getInstance().getWidthParam()); }