Ejemplo n.º 1
0
 @Override
 public void onSaveInstanceState(Bundle b) {
     super.onSaveInstanceState(b);
     b.putParcelable(STATE_URI,
             mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri());
     b.putBoolean(STATE_SHOW_CONTROLS, mShowControls);
 }
Ejemplo n.º 2
0
    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        if (mPaused) return false;

        IImage image = mAllImages.getImageAt(mCurrentPosition);
        if (mImageMenuRunnable != null) {
            mImageMenuRunnable.gettingReadyToOpen(menu, image);
        }

        Uri uri = mAllImages.getImageAt(mCurrentPosition).fullSizeImageUri();
        MenuHelper.enableShareMenuItem(menu, MenuHelper.isWhiteListUri(uri));

        MenuHelper.enableShowOnMapMenuItem(menu, MenuHelper.hasLatLngData(image));

        return true;
    }
Ejemplo n.º 3
0
 @Override
 public boolean onMenuItemSelected(int featureId, MenuItem item) {
     boolean b = super.onMenuItemSelected(featureId, item);
     if (mImageMenuRunnable != null) {
         mImageMenuRunnable.aboutToCall(item,
                 mAllImages.getImageAt(mCurrentPosition));
     }
     return b;
 }
Ejemplo n.º 4
0
 private void startPlayVideoActivity() {
     IImage image = mAllImages.getImageAt(mCurrentPosition);
     Intent intent = new Intent(
             Intent.ACTION_VIEW, image.fullSizeImageUri());
     try {
         startActivity(intent);
     } catch (android.content.ActivityNotFoundException ex) {
         Log.e(TAG, "Couldn't view video " + image.fullSizeImageUri(), ex);
     }
 }
Ejemplo n.º 5
0
    private void updateActionIcons() {
        if (isPickIntent()) return;

        IImage image = mAllImages.getImageAt(mCurrentPosition);
        if (image instanceof VideoObject) {
            setButtonPanelVisibility(R.id.btn_set_as, View.GONE);
            setButtonPanelVisibility(R.id.btn_play, View.VISIBLE);
        } else {
            setButtonPanelVisibility(R.id.btn_set_as, View.VISIBLE);
            setButtonPanelVisibility(R.id.btn_play, View.GONE);
        }
    }
Ejemplo n.º 6
0
 public void onClick(View v) {
     switch (v.getId()) {
         case R.id.btn_delete:
             MenuHelper.deleteImage(this, mDeletePhotoRunnable,
                     mAllImages.getImageAt(mCurrentPosition));
             break;
         case R.id.btn_play:
             startPlayVideoActivity();
             break;
         case R.id.btn_share: {
             IImage image = mAllImages.getImageAt(mCurrentPosition);
             if (!MenuHelper.isWhiteListUri(image.fullSizeImageUri())) {
                 return;
             }
             startShareMediaActivity(image);
             break;
         }
         case R.id.btn_set_as: {
             IImage image = mAllImages.getImageAt(mCurrentPosition);
             Intent intent = Util.createSetAsIntent(image);
             try {
                 startActivity(Intent.createChooser(
                         intent, getText(R.string.setImage)));
             } catch (android.content.ActivityNotFoundException ex) {
                 Toast.makeText(this, R.string.no_way_to_share_video,
                         Toast.LENGTH_SHORT).show();
             }
             break;
         }
         case R.id.btn_done:
             finish();
             break;
         case R.id.next_image:
             moveNextOrPrevious(1);
             break;
         case R.id.prev_image:
             moveNextOrPrevious(-1);
             break;
     }
 }
Ejemplo n.º 7
0
    private void showOnScreenControls() {

        // If the view has not been attached to the window yet, the
        // zoomButtonControls will not able to show up. So delay it until the
        // view has attached to window.
        if (mRootView.getWindowToken() == null) {
            mHandler.postGetterCallback(new Runnable() {
                public void run() {
                    showOnScreenControls();
                }
            });
            return;
        }

        // we may need to update the next/prev button due to index changing
        updateNextPrevControls();

        if (ImageManager.isImage(mAllImages.getImageAt(mCurrentPosition))) {
            updateZoomButtonsEnabled();
            mZoomButtonsController.setVisible(true);
        } else {
            mZoomButtonsController.setVisible(false);
        }
    }
Ejemplo n.º 8
0
 private Uri getCurrentUri() {
     if (mAllImages.getCount() == 0) return null;
     IImage image = mAllImages.getImageAt(mCurrentPosition);
     return image.fullSizeImageUri();
 }
Ejemplo n.º 9
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();
    }