diff options
author | Alex Ning <chineseperson5@gmail.com> | 2018-08-11 15:13:26 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2018-08-11 15:13:26 +0000 |
commit | 3c1423a127fb3a16160e05814386cfd176d5560b (patch) | |
tree | 0fa1030996205ea94ef075b931ef5828508f19e1 /app/src/main/java | |
parent | eb973138f72b181f79d84bbf16c06f92760118e0 (diff) | |
download | infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar.gz infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar.bz2 infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar.lz infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar.xz infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.tar.zst infinity-for-reddit-3c1423a127fb3a16160e05814386cfd176d5560b.zip |
Disable image rotation in ViewImageActivity. Disable dispatching touch event in ViewImageActivity when the image is zooming in or out in order to view the image.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java index f2cc0330..d0161399 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java @@ -32,6 +32,8 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.Toast; +import com.alexvasilkov.gestures.GestureController; +import com.alexvasilkov.gestures.State; import com.alexvasilkov.gestures.views.GestureImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.DataSource; @@ -69,6 +71,7 @@ public class ViewImageActivity extends AppCompatActivity { private float totalLengthY = 0.0f; private float touchY = -1.0f; + private float zoom = 1.0f; @Override protected void onCreate(Bundle savedInstanceState) { @@ -256,10 +259,19 @@ public class ViewImageActivity extends AppCompatActivity { } }); - imageView.getController().getSettings() - .setPanEnabled(true) - .setRotationEnabled(true) - .setRestrictRotation(true); + imageView.getController().addOnStateChangeListener(new GestureController.OnStateChangeListener() { + @Override + public void onStateChanged(State state) { + zoom = state.getZoom(); + } + + @Override + public void onStateReset(State oldState, State newState) { + + } + }); + + imageView.getController().getSettings().setPanEnabled(true); Glide.with(this).load(mImageUrl).listener(new RequestListener<Drawable>() { @Override @@ -343,7 +355,9 @@ public class ViewImageActivity extends AppCompatActivity { @Override public boolean dispatchTouchEvent(MotionEvent ev) { - swipe.dispatchTouchEvent(ev); + if(zoom == 1.0) { + swipe.dispatchTouchEvent(ev); + } return super.dispatchTouchEvent(ev); } |