Exemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    mQuranPageLayout = new QuranImagePageLayout(context);
    mQuranPageLayout.setPageController(this, pageNumber);
    mImageView = mQuranPageLayout.getImageView();

    if (mCoordinatesData != null) {
      mImageView.setCoordinateData(mCoordinatesData);
    }
    updateView();

    justCreated = true;
    return mQuranPageLayout;
  }
Exemplo n.º 2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.quran_page_layout, container, false);
    view.setBackgroundDrawable((mPageNumber % 2 == 0 ? mLeftGradient : mRightGradient));
    int lineImageId = R.drawable.dark_line;
    int leftBorderImageId = R.drawable.border_left;
    int rightBorderImageId = R.drawable.border_right;

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    Resources res = getResources();
    if (!prefs.getBoolean(Constants.PREF_USE_NEW_BACKGROUND, true)) {
      view.setBackgroundColor(res.getColor(R.color.page_background));
    }

    boolean nightMode = false;
    if (prefs.getBoolean(Constants.PREF_NIGHT_MODE, false)) {
      leftBorderImageId = R.drawable.night_left_border;
      rightBorderImageId = R.drawable.night_right_border;
      lineImageId = R.drawable.light_line;
      view.setBackgroundColor(Color.BLACK);
      nightMode = true;
    }

    ImageView leftBorder = (ImageView) view.findViewById(R.id.left_border);
    ImageView rightBorder = (ImageView) view.findViewById(R.id.right_border);
    if (mPageNumber % 2 == 0) {
      rightBorder.setVisibility(View.GONE);
      leftBorder.setBackgroundResource(leftBorderImageId);
    } else {
      rightBorder.setVisibility(View.VISIBLE);
      rightBorder.setBackgroundResource(rightBorderImageId);
      leftBorder.setBackgroundResource(lineImageId);
    }

    mImageView = (HighlightingImageView) view.findViewById(R.id.page_image);
    mImageView.setNightMode(nightMode);

    mScrollView = (ScrollView) view.findViewById(R.id.page_scroller);

    final GestureDetector gestureDetector = new GestureDetector(new PageGestureDetector());
    OnTouchListener gestureListener =
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
          }
        };
    mImageView.setOnTouchListener(gestureListener);
    mImageView.setClickable(true);
    mImageView.setLongClickable(true);

    mOverlayText = prefs.getBoolean(Constants.PREF_OVERLAY_PAGE_INFO, true);

    if (mCoordinateData != null) {
      mImageView.setCoordinateData(mCoordinateData);
    }

    if (mPageBoundsRect != null) {
      mImageView.setPageBounds(mPageBoundsRect);
      if (mOverlayText) {
        mImageView.setOverlayText(mPageNumber, true);
      }
    }

    return view;
  }