|
|
|
@ -19,6 +19,7 @@ import android.os.Bundle; |
|
|
|
|
import android.support.annotation.Nullable; |
|
|
|
|
import android.support.v4.app.DialogFragment; |
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
|
import android.view.MotionEvent; |
|
|
|
|
import android.view.View; |
|
|
|
|
import android.view.ViewGroup; |
|
|
|
|
import android.view.WindowManager; |
|
|
|
@ -71,6 +72,7 @@ public class ViewMediaFragment extends DialogFragment { |
|
|
|
|
|
|
|
|
|
attacher = new PhotoViewAttacher(photoView); |
|
|
|
|
|
|
|
|
|
// Clicking outside the photo closes the viewer.
|
|
|
|
|
attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { |
|
|
|
|
@Override |
|
|
|
|
public void onPhotoTap(View view, float x, float y) { |
|
|
|
@ -83,6 +85,20 @@ public class ViewMediaFragment extends DialogFragment { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/* An upward swipe motion also closes the viewer. This is especially useful when the photo |
|
|
|
|
* mostly fills the screen so clicking outside is difficult. */ |
|
|
|
|
attacher.setOnSingleFlingListener(new PhotoViewAttacher.OnSingleFlingListener() { |
|
|
|
|
@Override |
|
|
|
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, |
|
|
|
|
float velocityY) { |
|
|
|
|
if (velocityY < 0.0 && Math.abs(velocityY) > Math.abs(velocityX)) { |
|
|
|
|
dismiss(); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Picasso.with(getContext()) |
|
|
|
|
.load(url) |
|
|
|
|
.into(photoView, new Callback() { |
|
|
|
|