@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    activity = (ActionBarActivity) ImageFragment.this.getActivity();
    final FrameLayout root =
        (FrameLayout) inflater.inflate(R.layout.fragment_image_layout, container, false);

    final Bundle arguments = getArguments();
    if (arguments != null) {
      final String image_url = arguments.getString("image_url");

      mImageView = (ImageView) root.findViewById(R.id.iv_photo);
      mCurrMatrixTv = new TextView(getActivity());

      // The MAGIC happens here!
      isAttacherDisposed = false;
      mAttacher = new PhotoViewAttacher(mImageView);
      mAttacher.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

      Picasso.with(getActivity())
          .load(image_url)
          .noFade()
          .into(
              mImageView,
              new Callback() {
                @Override
                public void onSuccess() {
                  if (!isAttacherDisposed) {
                    mAttacher.setScaleType(ImageView.ScaleType.FIT_CENTER);
                    root.findViewById(R.id.progress).setVisibility(View.GONE);
                  }
                }

                @Override
                public void onError() {}
              });
      // Lets attach some listeners, not required though!
      mAttacher.setOnMatrixChangeListener(new MatrixChangeListener());
      mAttacher.setOnPhotoTapListener(new PhotoTapListener());
    }
    return root;
  }
Exemple #2
0
 @Override
 public void setOnMatrixChangeListener(OnMatrixChangedListener listener) {
   mAttacher.setOnMatrixChangeListener(listener);
 }