PDFRenderer缩放和翻转

时间:2014-12-22 07:41:28

标签: android imageview gesture pdfrenderer

我的PDF渲染器有以下问题 -

  1. 当我缩放图片视图时,页面会随着页面移动到下一页或上一页而缩放..页面未被保留..
  2. 我已经使用xml实现了翻转,并且使用手势监听器进行缩放似乎都在覆盖......有什么建议吗?
  3. public boolean onTouchEvent(MotionEvent touchevent){

    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自动生成的方法存根

    }

    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;
             }
        }
    

0 个答案:

没有答案