Ejemplo n.º 1
0
 @Override
 public boolean onScroll(MotionEvent e1, MotionEvent e2,
         float distanceX, float distanceY) {
     ImageViewTouch2 imageView = mImageView;
     if (imageView.getScale() > 1F) {
         imageView.postTranslateCenter(-distanceX, -distanceY);
     }
     return true;
 }
Ejemplo n.º 2
0
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            ImageViewTouch2 imageView = mImageView;

            // Switch between the original scale and 3x scale.
            if (imageView.getScale() > 2F) {
                mImageView.zoomTo(1f);
            } else {
                mImageView.zoomToPoint(3f, e.getX(), e.getY());
            }
            return true;
        }
Ejemplo n.º 3
0
    @Override
    public void onStop() {
        super.onStop();
        mPaused = true;

        // mGetter could be null if we call finish() and leave early in
        // onStart().
        if (mGetter != null) {
            mGetter.cancelCurrent();
            mGetter.stop();
            mGetter = null;
        }

        // removing all callback in the message queue
        mHandler.removeAllGetterCallbacks();

        if (mAllImages != null) {
            mSavedUri = getCurrentUri();
            mAllImages.close();
            mAllImages = null;
        }

        hideOnScreenControls();
        mImageView.clear();
        mCache.clear();

        for (ImageViewTouchBase iv : mSlideShowImageViews) {
            iv.clear();
        }
    }
Ejemplo n.º 4
0
 public void run() {
     mAllImages.removeImageAt(mCurrentPosition);
     if (mAllImages.getCount() == 0) {
         finish();
         return;
     } else {
         if (mCurrentPosition == mAllImages.getCount()) {
             mCurrentPosition -= 1;
         }
     }
     mImageView.clear();
     mCache.clear();  // Because the position number is changed.
     setImage(mCurrentPosition, true);
 }
Ejemplo n.º 5
0
    @Override
    public void onCreate(Bundle instanceState) {
        super.onCreate(instanceState);

        Intent intent = getIntent();
        mFullScreenInNormalMode = intent.getBooleanExtra(
                MediaStore.EXTRA_FULL_SCREEN, true);

        setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.review_image);

        mRootView = findViewById(R.id.root);
        mControlBar = findViewById(R.id.control_bar);
        mImageView = (ImageViewTouch2) findViewById(R.id.image);
        mImageView.setEnableTrackballScroll(true);
        mCache = new BitmapCache(3);
        mImageView.setRecycler(mCache);

        ((PreviewFrameLayout) findViewById(
                R.id.frame_layout)).setAspectRatio(ASPECT_RATIO);


        makeGetter();

        mSlideShowImageViews[0] =
                (ImageViewTouchBase) findViewById(R.id.image1_slideShow);
        mSlideShowImageViews[1] =
                (ImageViewTouchBase) findViewById(R.id.image2_slideShow);
        for (ImageViewTouchBase v : mSlideShowImageViews) {
            v.setVisibility(View.INVISIBLE);
            v.setRecycler(mCache);
        }

        mParam = getIntent().getParcelableExtra(KEY_IMAGE_LIST);

        if (instanceState != null) {
            mSavedUri = instanceState.getParcelable(STATE_URI);
            mShowControls = instanceState.getBoolean(STATE_SHOW_CONTROLS, true);
        } else {
            mSavedUri = getIntent().getData();
        }

        int[] pickIds = {R.id.attach, R.id.cancel};
        int[] reviewIds = {R.id.btn_delete, R.id.btn_share, R.id.btn_set_as,
                R.id.btn_play, R.id.btn_done};
        int[] connectIds = isPickIntent() ? pickIds : reviewIds;
        for (int id : connectIds) {
            View view = mControlBar.findViewById(id);
            view.setOnClickListener(this);
            // Set the LinearLayout of the given button to visible
            ((View) view.getParent()).setVisibility(View.VISIBLE);
        }

        if (mFullScreenInNormalMode) {
            getWindow().addFlags(
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

        setupOnScreenControls(findViewById(R.id.mainPanel), mImageView);
    }
Ejemplo n.º 6
0
    void setImage(int pos, boolean showControls) {
        mCurrentPosition = pos;

        Bitmap b = mCache.getBitmap(pos);
        if (b != null) {
            IImage image = mAllImages.getImageAt(pos);
            mImageView.setImageRotateBitmapResetBase(
                    new RotateBitmap(b, image.getDegreesRotated()), true);
            updateZoomButtonsEnabled();
        }

        ImageGetterCallback cb = new ImageGetterCallback() {
            public void completed() {
            }

            public boolean wantsThumbnail(int pos, int offset) {
                return !mCache.hasBitmap(pos + offset);
            }

            public boolean wantsFullImage(int pos, int offset) {
                return offset == 0;
            }

            public int fullImageSizeToUse(int pos, int offset) {
                // this number should be bigger so that we can zoom.  we may
                // need to get fancier and read in the fuller size image as the
                // user starts to zoom.
                // Originally the value is set to 480 in order to avoid OOM.
                // Now we set it to 2048 because of using
                // native memory allocation for Bitmaps.
                final int imageViewSize = 2048;
                return imageViewSize;
            }

            public int [] loadOrder() {
                return sOrderAdjacents;
            }

            public void imageLoaded(int pos, int offset, RotateBitmap bitmap,
                                    boolean isThumb) {
                // shouldn't get here after onPause()

                // We may get a result from a previous request. Ignore it.
                if (pos != mCurrentPosition) {
                    bitmap.recycle();
                    return;
                }

                if (isThumb) {
                    mCache.put(pos + offset, bitmap.getBitmap());
                }
                if (offset == 0) {
                    // isThumb: We always load thumb bitmap first, so we will
                    // reset the supp matrix for then thumb bitmap, and keep
                    // the supp matrix when the full bitmap is loaded.
                    mImageView.setImageRotateBitmapResetBase(bitmap, isThumb);
                    updateZoomButtonsEnabled();
                }
            }
        };

        // Could be null if we're stopping a slide show in the course of pausing
        if (mGetter != null) {
            mGetter.setPosition(pos, cb, mAllImages, mHandler);
        }
        updateActionIcons();
        if (showControls) showOnScreenControls();
        scheduleDismissOnScreenControls();
    }
Ejemplo n.º 7
0
 private void updateZoomButtonsEnabled() {
     ImageViewTouch2 imageView = mImageView;
     float scale = imageView.getScale();
     mZoomButtonsController.setZoomInEnabled(scale < imageView.mMaxZoom);
     mZoomButtonsController.setZoomOutEnabled(scale > 1);
 }