My PDF Renderer has the following issues:
- When I enlarge the image, the page enlarges and the page moves to the next or previous page .. the page is NOT held.
- I implemented flip using xml and zoom using gestures. The listeners seem to redefine ... any suggestions, please.
public boolean onTouchEvent (MotionEvent touchhevent) {
int actionId = touchevent.getPointerCount(); if (actionId == 1 && touchevent.getPointerCount() == 2) { switch (touchevent.getAction()) { case MotionEvent.ACTION_DOWN: // when user first touches the screen to swap { flag = 0; System.out.println("ACTION_DOWN - " + touchevent.getPointerCount()); lastX = touchevent.getX(); break; } // Finger went up case MotionEvent.ACTION_UP: { flag = 0; float currentX = touchevent.getX(); System.out.println("ACTION_UP - " + touchevent.getPointerCount()); // if left to right swipe on screen - previous page if (lastX < currentX) { // If no more View/Child to flip // if (viewFlipper.getDisplayedChild() == 1) // break; Log.e("TAG - in prevoius move", "TAG - in prevoius move"); Log.i("TAG - BEFORE MOVE ", "currentPage - " + currentPage); if (currentPage > 0) { try { render(--currentPage); if (!next.isEnabled()) next.setEnabled(true); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { currentPage = 0; try { render(currentPage); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } previous.setEnabled(false); if (!next.isEnabled()) next.setEnabled(true); } Log.i("TAG - POST PREVIOUS MOVE ", "currentPage - " + currentPage); // set the required Animation type to ViewFlipper // The Next screen will come in form Left and current Screen // will go OUT from Right // Specifies the animation used to animate a View that // enters / exits the screen. viewFlipper.setInAnimation(this, R.anim.in_from_left); viewFlipper.setOutAnimation(this, R.anim.out_to_right); // Show the next Screen viewFlipper.showNext(); } // if right to left swipe on screen - next page if (lastX > currentX) { // if (viewFlipper.getDisplayedChild() == 1) // break; Log.e("TAG - in next move", " TAG - in next move"); Log.i("TAG - BEFORE MOVE ", "currentPage - " + currentPage); if (currentPage < renderer.getPageCount()) { try { if (currentPage == renderer.getPageCount() - 1) { next.setEnabled(false); // currentPage--; // render(currentPage); } else { render(++currentPage); if (!next.isEnabled()) next.setEnabled(true); if (!previous.isEnabled()) previous.setEnabled(true); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Log.i("TAG - POST NEXT MOVE ", "currentPage - " + currentPage); // set the required Animation type to ViewFlipper // The Next screen will come in form Right and current // Screen will go OUT from Left // Specifies the animation used to animate a View that // enters / exits the screen. viewFlipper.setInAnimation(this, R.anim.in_from_right); viewFlipper.setOutAnimation(this, R.anim.out_to_left); // Show The Previous Screen viewFlipper.showPrevious(); } } } } else { flag = 1; SGD.onTouchEvent(touchevent); System.out.println("SGD - " + touchevent.getPointerCount()); } return false;
}
private void render (int i) {// TODO Automatically generated stub method
}
private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override public boolean onScale(ScaleGestureDetector detector) { scale *= detector.getScaleFactor(); scale = Math.max(0.1 f, Math.min(scale, 5.0 f)); matrix.setScale(scale, scale); imageView.setImageMatrix(matrix); return true; } }
source share