Ejemplo n.º 1
0
  private void animateOut() {
    ValueAnimator animWidth = ValueAnimator.ofInt(zoomableImageView.getMeasuredWidth(), rect.right);
    animWidth.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.width = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animWidth.setDuration(500);
    animWidth.start();

    ValueAnimator animHeight =
        ValueAnimator.ofInt(zoomableImageView.getMeasuredHeight(), rect.bottom);
    animHeight.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.height = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animHeight.setDuration(500);
    animHeight.start();
    if (statusBarHeightCorrection > 0) {
      zoomableImageView.animate().y(-statusBarHeightCorrection).setDuration(300).start();
    }
    zoomableImageView.animate().alpha(0.0f).setDuration(500).start();
  }
  @Override
  public Object instantiateItem(ViewGroup container, int position) {

    View itemView = mLayoutInflater.inflate(R.layout.item_preview, container, false);

    PhotoView imageView = (PhotoView) itemView.findViewById(R.id.iv_pager);

    final String path = paths.get(position);
    final Uri uri;
    if (path.startsWith("http")) {
      uri = Uri.parse(path);
    } else {
      uri = Uri.fromFile(new File(path));
    }
    Glide.with(mContext)
        .load(uri)
        //            .placeholder(R.mipmap.default_error)
        .error(R.mipmap.default_error)
        .crossFade()
        .into(imageView);

    imageView.setOnPhotoTapListener(
        new PhotoViewAttacher.OnPhotoTapListener() {
          @Override
          public void onPhotoTap(View view, float v, float v1) {
            if (listener != null) {
              listener.OnPhotoTapListener(view, v, v1);
            }
          }
        });

    container.addView(itemView);

    return itemView;
  }
  public void animationExit(ObjectAnimator backgroundAnimator) {

    if (Math.abs(photoView.getScale() - 1.0f) > 0.1f) {
      photoView.setScale(1, true);
      return;
    }

    getActivity().overridePendingTransition(0, 0);
    animateClose(backgroundAnimator);
  }
Ejemplo n.º 4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mPhotoView = (PhotoView) findViewById(R.id.pv_photo);

    Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper);
    mPhotoView.setImageDrawable(bitmap);
    mPhotoView.setZoomable(true);
  }
Ejemplo n.º 5
0
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
    PhotoView photo = new PhotoView(container.getContext());
    photo.setScaleType(ImageView.ScaleType.FIT_CENTER);

    // Load Image from URL using Glide
    Glide.with(activity)
        .load(imagesList.get(position))
        .crossFade()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .into(photo);

    container.addView(
        photo, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT);
    return photo;
  }
Ejemplo n.º 6
0
  public void runExitAnimation(ObjectAnimator backgroundAnimator) {

    mGifView.setVisibility(View.GONE);
    mPhotoView.setVisibility(View.VISIBLE);
    //        setBitmapToPhotoView();
    //        AnimationRect rect = getArguments().getParcelable("rect");

    AnimationRect.runExitAnimation(mPhotoView, mRect, backgroundAnimator);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_photo_view, container, false);

    imageView = (PhotoView) view.findViewById(R.id.photoIm);
    progressBar = (CircularProgressBar) view.findViewById(R.id.progressBar);

    ImageLoader loader = ImageLoader.getInstance();
    ImageLoaderUtils.initImageLoader(getActivity());
    DisplayImageOptions options =
        new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build();

    imageView.setOnViewTapListener(
        new PhotoViewAttacher.OnViewTapListener() {
          @Override
          public void onViewTap(View view, float x, float y) {
            getActivity().finish();
          }
        });

    loader.displayImage(
        url,
        imageView,
        options,
        new ImageLoadingListener() {
          @Override
          public void onLoadingStarted(String imageUri, View view) {}

          @Override
          public void onLoadingFailed(String imageUri, View view, FailReason failReason) {}

          @Override
          public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            if (imageUri.equals(url)) {
              progressBar.setVisibility(View.GONE);
            }
          }

          @Override
          public void onLoadingCancelled(String imageUri, View view) {}
        },
        new ImageLoadingProgressListener() {
          @Override
          public void onProgressUpdate(String s, View view, int i, int i2) {
            progressBar.setProgressPecentage((float) i / i2);
          }
        });

    return view;
  }
Ejemplo n.º 8
0
 @Override
 public boolean onException(
     Exception e, String model, Target<Bitmap> target, boolean isFirstResource) {
   if (image != null) {
     image.setImageResource(R.drawable.cancel);
   }
   if (progress != null) {
     progress.setVisibility(View.GONE);
   }
   if (getActivity() != null)
     Toast.makeText(getActivity(), R.string.loading_exception_error, Toast.LENGTH_SHORT)
         .show();
   return false;
 }
Ejemplo n.º 9
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_image_gif, container, false);

    mGifView = (PhotoView) view.findViewById(R.id.iv_normal);
    mPhotoView = (ClipImageView) view.findViewById(R.id.cover);
    mScreenWidth = getResources().getDisplayMetrics().widthPixels;

    mGifView.setOnLongClickListener(this);

    File gifFile = new File(mPath);
    try {
      GifDrawable gifFromFile = new GifDrawable(gifFile);
      mGifView.setImageDrawable(gifFromFile);
    } catch (IOException e) {
      e.printStackTrace();
    }

    setBitmapToPhotoView();
    if (mAnimateIn) {
      mAnimateIn = false;
      runEnterAnimation();
    }

    if (SettingHelper.isClickToCloseGallery()) {
      mGifView.setOnViewTapListener(
          new PhotoViewAttacher.OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
              getActivity().onBackPressed();
            }
          });
    }
    return view;
  }
Ejemplo n.º 10
0
    /** 用来实例化页卡 */
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
      PhotoView photoView = new PhotoView(mContext);
      //            photoView.setScaleType(ImageView.ScaleType.CENTER);
      photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
      Glide.with(mContext).load(mPictures.get(position)).into(photoView);
      // Now just add PhotoView to ViewPager and return it
      container.addView(
          photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      // 单击图片
      photoView.setOnPhotoTapListener(
          new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float v, float v1) {
              mOnSingleClickListener.singleClickFinish();
            }

            @Override
            public void onOutsidePhotoTap() {
              mOnSingleClickListener.singleClickFinish();
            }
          });
      return photoView;
    }
Ejemplo n.º 11
0
 private void applyZoomLevel() {
   if (image != null && image.canZoom()) {
     switch (zoomLevel) {
       case 0:
         image.setScale(image.getMinimumScale(), true);
         break;
       case 1:
         image.setScale(image.getMediumScale(), true);
         break;
       case 2:
         image.setScale(image.getMaximumScale(), true);
         break;
     }
   }
 }
Ejemplo n.º 12
0
  private void runEnterAnimation() {

    mPhotoView.setVisibility(View.VISIBLE);
    mGifView.setVisibility(View.GONE);
    AnimationRect.runEnterAnimation(mPhotoView, mRect, mGifView);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.gallery_general_layout, container, false);

    photoView = (PhotoView) view.findViewById(R.id.animation);

    if (SettingUtility.allowClickToCloseGallery()) {

      photoView.setOnViewTapListener(
          new PhotoViewAttacher.OnViewTapListener() {
            @Override
            public void onViewTap(View view, float x, float y) {
              getActivity().onBackPressed();
            }
          });
    }

    LongClickListener longClickListener =
        ((ContainerFragment) getParentFragment()).getLongClickListener();
    photoView.setOnLongClickListener(longClickListener);

    final String path = getArguments().getString("path");
    boolean animateIn = getArguments().getBoolean("animationIn");
    final AnimationRect rect = getArguments().getParcelable("rect");

    if (!animateIn) {

      new MyAsyncTask<Void, Bitmap, Bitmap>() {

        @Override
        protected Bitmap doInBackground(Void... params) {
          Bitmap bitmap =
              ImageUtility.decodeBitmapFromSDCard(
                  path, IMAGEVIEW_SOFT_LAYER_MAX_WIDTH, IMAGEVIEW_SOFT_LAYER_MAX_HEIGHT);
          return bitmap;
        }

        @Override
        protected void onPostExecute(Bitmap bitmap) {
          super.onPostExecute(bitmap);
          photoView.setImageBitmap(bitmap);
        }
      }.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);

      return view;
    }

    final Bitmap bitmap =
        ImageUtility.decodeBitmapFromSDCard(
            path, IMAGEVIEW_SOFT_LAYER_MAX_WIDTH, IMAGEVIEW_SOFT_LAYER_MAX_HEIGHT);

    photoView.setImageBitmap(bitmap);

    final Runnable endAction =
        new Runnable() {
          @Override
          public void run() {
            Bundle bundle = getArguments();
            bundle.putBoolean("animationIn", false);
          }
        };

    photoView
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new ViewTreeObserver.OnPreDrawListener() {
              @Override
              public boolean onPreDraw() {

                if (rect == null) {
                  photoView.getViewTreeObserver().removeOnPreDrawListener(this);
                  return true;
                }

                final Rect startBounds = new Rect(rect.scaledBitmapRect);
                final Rect finalBounds = AnimationUtility.getBitmapRectFromImageView(photoView);

                if (finalBounds == null) {
                  photoView.getViewTreeObserver().removeOnPreDrawListener(this);
                  return true;
                }

                float startScale = (float) finalBounds.width() / startBounds.width();

                if (startScale * startBounds.height() > finalBounds.height()) {
                  startScale = (float) finalBounds.height() / startBounds.height();
                }

                int deltaTop = startBounds.top - finalBounds.top;
                int deltaLeft = startBounds.left - finalBounds.left;

                photoView.setPivotY((photoView.getHeight() - finalBounds.height()) / 2);
                photoView.setPivotX((photoView.getWidth() - finalBounds.width()) / 2);

                photoView.setScaleX(1 / startScale);
                photoView.setScaleY(1 / startScale);

                photoView.setTranslationX(deltaLeft);
                photoView.setTranslationY(deltaTop);

                photoView
                    .animate()
                    .translationY(0)
                    .translationX(0)
                    .scaleY(1)
                    .scaleX(1)
                    .setDuration(ANIMATION_DURATION)
                    .setInterpolator(new AccelerateDecelerateInterpolator())
                    .withEndAction(endAction);

                AnimatorSet animationSet = new AnimatorSet();
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setInterpolator(new AccelerateDecelerateInterpolator());

                animationSet.playTogether(
                    ObjectAnimator.ofFloat(
                        photoView,
                        "clipBottom",
                        AnimationRect.getClipBottom(rect, finalBounds),
                        0));
                animationSet.playTogether(
                    ObjectAnimator.ofFloat(
                        photoView, "clipRight", AnimationRect.getClipRight(rect, finalBounds), 0));
                animationSet.playTogether(
                    ObjectAnimator.ofFloat(
                        photoView, "clipTop", AnimationRect.getClipTop(rect, finalBounds), 0));
                animationSet.playTogether(
                    ObjectAnimator.ofFloat(
                        photoView, "clipLeft", AnimationRect.getClipLeft(rect, finalBounds), 0));

                animationSet.start();

                photoView.getViewTreeObserver().removeOnPreDrawListener(this);
                return true;
              }
            });

    return view;
  }
  private void animateClose(ObjectAnimator backgroundAnimator) {

    AnimationRect rect = getArguments().getParcelable("rect");

    if (rect == null) {
      photoView.animate().alpha(0);
      backgroundAnimator.start();
      return;
    }

    final Rect startBounds = rect.scaledBitmapRect;
    final Rect finalBounds = AnimationUtility.getBitmapRectFromImageView(photoView);

    if (finalBounds == null) {
      photoView.animate().alpha(0);
      backgroundAnimator.start();
      return;
    }

    if (Utility.isDevicePort() != rect.isScreenPortrait) {
      photoView.animate().alpha(0);
      backgroundAnimator.start();
      return;
    }

    float startScale;
    if ((float) finalBounds.width() / finalBounds.height()
        > (float) startBounds.width() / startBounds.height()) {
      startScale = (float) startBounds.height() / finalBounds.height();

    } else {
      startScale = (float) startBounds.width() / finalBounds.width();
    }

    final float startScaleFinal = startScale;

    int deltaTop = startBounds.top - finalBounds.top;
    int deltaLeft = startBounds.left - finalBounds.left;

    photoView.setPivotY((photoView.getHeight() - finalBounds.height()) / 2);
    photoView.setPivotX((photoView.getWidth() - finalBounds.width()) / 2);

    photoView
        .animate()
        .translationX(deltaLeft)
        .translationY(deltaTop)
        .scaleY(startScaleFinal)
        .scaleX(startScaleFinal)
        .setDuration(ANIMATION_DURATION)
        .setInterpolator(new AccelerateDecelerateInterpolator())
        .withEndAction(
            new Runnable() {
              @Override
              public void run() {

                photoView
                    .animate()
                    .alpha(0.0f)
                    .setDuration(200)
                    .withEndAction(
                        new Runnable() {
                          @Override
                          public void run() {}
                        });
              }
            });

    AnimatorSet animationSet = new AnimatorSet();
    animationSet.setDuration(ANIMATION_DURATION);
    animationSet.setInterpolator(new AccelerateDecelerateInterpolator());

    animationSet.playTogether(backgroundAnimator);

    animationSet.playTogether(
        ObjectAnimator.ofFloat(
            photoView, "clipBottom", 0, AnimationRect.getClipBottom(rect, finalBounds)));
    animationSet.playTogether(
        ObjectAnimator.ofFloat(
            photoView, "clipRight", 0, AnimationRect.getClipRight(rect, finalBounds)));
    animationSet.playTogether(
        ObjectAnimator.ofFloat(
            photoView, "clipTop", 0, AnimationRect.getClipTop(rect, finalBounds)));
    animationSet.playTogether(
        ObjectAnimator.ofFloat(
            photoView, "clipLeft", 0, AnimationRect.getClipLeft(rect, finalBounds)));

    animationSet.start();
  }
Ejemplo n.º 15
0
  private void animateIn(final Dialog dialog) {
    RelativeLayout.LayoutParams params =
        (RelativeLayout.LayoutParams) zoomableImageView.getLayoutParams();
    params.width = rect.right;
    params.height = rect.bottom;
    zoomableImageView.setLayoutParams(params);

    zoomableImageView.setX(rect.left);
    zoomableImageView.setY(rect.top - statusBarHeightCorrection);
    zoomableImageView.setAlpha(0.0f);
    zoomableImageView.setImageBitmap(bitmap);

    WindowManager win = getActivity().getWindowManager();
    Display d = win.getDefaultDisplay();
    int displayWidth = d.getWidth(); // Width of the actual device
    int displayHeight = d.getHeight() + statusBarHeightCorrection;

    ValueAnimator animWidth = ValueAnimator.ofInt(rect.right, displayWidth);
    animWidth.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.width = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animWidth.setDuration(500);
    animWidth.setInterpolator(new LinearOutSlowInInterpolator());
    animWidth.start();

    ValueAnimator animHeight = ValueAnimator.ofInt(rect.bottom, displayHeight);
    animHeight.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.height = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animHeight.setDuration(500);
    animHeight.setInterpolator(new LinearOutSlowInInterpolator());

    animHeight.start();

    if (statusBarHeightCorrection > 0) {
      zoomableImageView.animate().y(0.0f).setDuration(300).start();
    }

    ValueAnimator animDim = ValueAnimator.ofFloat(0.0f, 0.5f);
    animDim.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
            layoutParams.copyFrom(dialog.getWindow().getAttributes());
            layoutParams.dimAmount = (Float) valueAnimator.getAnimatedValue();
            dialog.getWindow().setAttributes(layoutParams);
          }
        });
    animDim.setDuration(300);
    animDim.setStartDelay(300);
    animDim.start();
    zoomableImageView.animate().alpha(1.0f).setDuration(300).start();
  }
Ejemplo n.º 16
0
    @Override
    public Object instantiateItem(ViewGroup container, final int position) {

      View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);
      final PhotoView pvComic = (PhotoView) itemView.findViewById(R.id.ivComic);
      itemView.setTag(position);

      final TextView tvAlt = (TextView) itemView.findViewById(R.id.tvAlt);

      if (PrefHelper.altByDefault()) {
        tvAlt.setVisibility(View.VISIBLE);
      }
      tvAlt.setText(PrefHelper.getAlt(sFavorites[position]));

      // fix for issue #2
      pvComic.setOnDoubleTapListener(
          new GestureDetector.OnDoubleTapListener() {
            @Override
            public boolean onDoubleTap(MotionEvent e) {
              if (pvComic.getScale() < 0.5f * pvComic.getMaximumScale()) {
                pvComic.setScale(0.5f * pvComic.getMaximumScale(), true);
              } else if (pvComic.getScale() < pvComic.getMaximumScale()) {
                pvComic.setScale(pvComic.getMaximumScale(), true);
              } else {
                pvComic.setScale(1.0f, true);
              }
              return true;
            }

            @Override
            public boolean onSingleTapConfirmed(MotionEvent e) {
              if (!PrefHelper.altLongTap()) {
                if (PrefHelper.classicAltStyle()) {
                  toggleVisibility(tvAlt);
                } else {
                  android.support.v7.app.AlertDialog.Builder mDialog =
                      new android.support.v7.app.AlertDialog.Builder(getActivity());
                  mDialog.setMessage(tvAlt.getText());
                  mDialog.show();
                }
              }
              return false;
            }

            @Override
            public boolean onDoubleTapEvent(MotionEvent e) {
              if (e.getAction() == MotionEvent.ACTION_UP) {
                fingerLifted = true;
              }
              if (e.getAction() == MotionEvent.ACTION_DOWN) {
                fingerLifted = false;
              }
              return false;
            }
          });

      // Setup alt text and LongClickListener
      pvComic.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              if (fingerLifted && PrefHelper.altLongTap()) {
                if (PrefHelper.altVibration()) {
                  Vibrator vi =
                      (Vibrator) getActivity().getSystemService(MainActivity.VIBRATOR_SERVICE);
                  vi.vibrate(10);
                }
                // tvAlt.setText(PrefHelper.getAlt(sFavorites[sFavoriteIndex]));
                if (PrefHelper.classicAltStyle()) {
                  toggleVisibility(tvAlt);
                } else {
                  android.support.v7.app.AlertDialog.Builder mDialog =
                      new android.support.v7.app.AlertDialog.Builder(getActivity());
                  mDialog.setMessage(tvAlt.getText());
                  mDialog.show();
                }
              }
              return true;
            }
          });
      // setup the title text view
      TextView tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
      tvTitle.setText(PrefHelper.getTitle(sFavorites[position]));

      if (PrefHelper.invertColors()) {
        float[] colorMatrix_Negative = {
          -1.0f,
          0,
          0,
          0,
          255, // red
          0,
          -1.0f,
          0,
          0,
          255, // green
          0,
          0,
          -1.0f,
          0,
          255, // blue
          0,
          0,
          0,
          1.0f,
          0 // alpha
        };
        ColorFilter cf = new ColorMatrixColorFilter(colorMatrix_Negative);
        pvComic.setColorFilter(cf);
      }

      // load the image
      pvComic.setImageBitmap(mComicMap.get(position).getBitmap());
      if (Arrays.binarySearch(
              mContext.getResources().getIntArray(R.array.large_comics), sFavorites[sFavoriteIndex])
          >= 0) {
        pvComic.setMaximumScale(7.0f);
      }
      // Disable ViewPager scrolling when the user zooms into an image
      pvComic.setOnMatrixChangeListener(
          new PhotoViewAttacher.OnMatrixChangedListener() {
            @Override
            public void onMatrixChanged(RectF rectF) {
              if (pvComic.getScale() > 1.4) {
                mPager.setLocked(true);
              } else {
                mPager.setLocked(false);
              }
            }
          });

      container.addView(itemView);
      return itemView;
    }
Ejemplo n.º 17
0
    @Override
    public View instantiateItem(ViewGroup container, final int position) {
      final PhotoView photoView = new PhotoView(container.getContext());
      photoView.setImageResource(sDrawables[position]);

      // Now just add PhotoView to ViewPager and return it
      container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
      photoView.setOnPhotoTapListener(
          new PhotoViewAttacher.OnPhotoTapListener() {
            public void onPhotoTap(
                View paramAnonymousView, float paramAnonymousFloat1, float paramAnonymousFloat2) {
              if (mCurrentAnimator != null) {
                mCurrentAnimator.cancel();
              }

              photoView.clearZoom();

              boolean scaleResult = getScaleFinalBounds(position);
              // Animate the four positioning/sizing properties in parallel,
              // back to their
              // original values.
              AnimatorSet as = new AnimatorSet();
              ObjectAnimator containAlphaAnimator =
                  ObjectAnimator.ofFloat(((MainActivity) mContext).gridView, "alpha", 0.f, 1.0f);
              if (scaleResult) {
                ObjectAnimator animatorX = ObjectAnimator.ofFloat(viewPager, "x", startBounds.left);
                ObjectAnimator animatorY = ObjectAnimator.ofFloat(viewPager, "y", startBounds.top);
                ObjectAnimator animatorScaleX =
                    ObjectAnimator.ofFloat(viewPager, "scaleX", startScaleFinal);
                ObjectAnimator animatorScaleY =
                    ObjectAnimator.ofFloat(viewPager, "scaleY", startScaleFinal);

                as.play(containAlphaAnimator)
                    .with(animatorX)
                    .with(animatorY)
                    .with(animatorScaleX)
                    .with(animatorScaleY);
              } else {
                // the selected photoview is beyond the mobile screen display
                // so it just fade out
                ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(viewPager, "alpha", 0.1f);
                as.play(alphaAnimator).with(containAlphaAnimator);
              }
              as.setDuration(mShortAnimationDuration);
              as.setInterpolator(new DecelerateInterpolator());
              as.addListener(
                  new AnimatorListenerAdapter() {

                    @Override
                    public void onAnimationEnd(Animator animation) {
                      viewPager.clearAnimation();
                      viewPager.setVisibility(View.GONE);
                      mCurrentAnimator = null;
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                      viewPager.clearAnimation();
                      viewPager.setVisibility(View.GONE);
                      mCurrentAnimator = null;
                    }
                  });
              as.start();
              mCurrentAnimator = as;
            }
          });

      return photoView;
    }