1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-23 07:07:30 +00:00

Remove swipe to dismiss Post view temporarily

This commit is contained in:
Ammar Githam 2021-01-04 01:47:15 +09:00
parent 788358eb35
commit 2b2f390f59
3 changed files with 70 additions and 54 deletions

View File

@ -2,6 +2,8 @@ package awais.instagrabber.adapters.viewholder;
import android.graphics.drawable.Animatable; import android.graphics.drawable.Animatable;
import android.net.Uri; import android.net.Uri;
import android.view.GestureDetector;
import android.view.MotionEvent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -59,9 +61,19 @@ public class SliderPhotoViewHolder extends SliderItemViewHolder {
}) })
.setLowResImageRequest(ImageRequest.fromUri(model.getThumbnailUrl())) .setLowResImageRequest(ImageRequest.fromUri(model.getThumbnailUrl()))
.build()); .build());
binding.getRoot().setOnClickListener(v -> { // binding.getRoot().setOnClickListener(v -> {
// if (sliderCallback != null) {
// sliderCallback.onItemClicked(position);
// }
// });
binding.getRoot().setTapListener(new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(final MotionEvent e) {
if (sliderCallback != null) { if (sliderCallback != null) {
sliderCallback.onItemClicked(position); sliderCallback.onItemClicked(position);
return true;
}
return false;
} }
}); });
final AnimatedZoomableController zoomableController = AnimatedZoomableController.newInstance(); final AnimatedZoomableController zoomableController = AnimatedZoomableController.newInstance();

View File

@ -7,11 +7,8 @@
package awais.instagrabber.customviews.drawee; package awais.instagrabber.customviews.drawee;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Matrix;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MotionEvent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -53,46 +50,47 @@ public class DraggableZoomableDraweeView extends ZoomableDraweeView {
private int lastNewPointerCount; private int lastNewPointerCount;
private boolean wasTransformCorrected; private boolean wasTransformCorrected;
@Override // @Override
protected void onTransformEnd(final Matrix transform) { // protected void onTransformEnd(final Matrix transform) {
super.onTransformEnd(transform); // super.onTransformEnd(transform);
final AnimatedZoomableController zoomableController = (AnimatedZoomableController) getZoomableController(); // final AnimatedZoomableController zoomableController = (AnimatedZoomableController) getZoomableController();
final TransformGestureDetector detector = zoomableController.getDetector(); // final TransformGestureDetector detector = zoomableController.getDetector();
lastNewPointerCount = detector.getNewPointerCount(); // lastNewPointerCount = detector.getNewPointerCount();
lastPointerCount = detector.getPointerCount(); // lastPointerCount = detector.getPointerCount();
} // }
//
// @Override
// protected void onTranslationLimited(final float offsetLeft, final float offsetTop) {
// super.onTranslationLimited(offsetLeft, offsetTop);
// wasTransformCorrected = offsetTop != 0;
// }
@Override // @SuppressLint("ClickableViewAccessibility")
protected void onTranslationLimited(final float offsetLeft, final float offsetTop) { // @Override
super.onTranslationLimited(offsetLeft, offsetTop); // public boolean onTouchEvent(final MotionEvent event) {
wasTransformCorrected = offsetTop != 0; // boolean superResult = false;
} // superResult = super.onTouchEvent(event);
// if (verticalDragHelper.isDragging()) {
@SuppressLint("ClickableViewAccessibility") // final boolean onDragTouch = verticalDragHelper.onDragTouch(event);
@Override // if (onDragTouch) {
public boolean onTouchEvent(final MotionEvent event) { // return true;
boolean superResult = false; // }
if (verticalDragHelper.isDragging()) { // }
final boolean onDragTouch = verticalDragHelper.onDragTouch(event); // if (!verticalDragHelper.isDragging()) {
if (onDragTouch) { // superResult = super.onTouchEvent(event);
return true; // if (wasTransformCorrected
} // && (lastPointerCount == 1 || lastPointerCount == 0)
} // && (lastNewPointerCount == 1 || lastNewPointerCount == 0)) {
if (!verticalDragHelper.isDragging()) { // final boolean onDragTouch = verticalDragHelper.onDragTouch(event);
superResult = super.onTouchEvent(event); // if (onDragTouch) {
if (wasTransformCorrected // return true;
&& (lastPointerCount == 1 || lastPointerCount == 0) // }
&& (lastNewPointerCount == 1 || lastNewPointerCount == 0)) { // }
final boolean onDragTouch = verticalDragHelper.onDragTouch(event); // }
if (onDragTouch) { // final boolean gestureListenerResult = verticalDragHelper.onGestureTouchEvent(event);
return true; // if (gestureListenerResult) {
} // return true;
} // }
} // return superResult;
final boolean gestureListenerResult = verticalDragHelper.onGestureTouchEvent(event); // }
if (gestureListenerResult) {
return true;
}
return superResult;
}
} }

View File

@ -18,8 +18,10 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils; import android.view.ViewAnimationUtils;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -72,7 +74,6 @@ import awais.instagrabber.customviews.VideoPlayerCallbackAdapter;
import awais.instagrabber.customviews.VideoPlayerViewHelper; import awais.instagrabber.customviews.VideoPlayerViewHelper;
import awais.instagrabber.customviews.drawee.AnimatedZoomableController; import awais.instagrabber.customviews.drawee.AnimatedZoomableController;
import awais.instagrabber.databinding.DialogPostViewBinding; import awais.instagrabber.databinding.DialogPostViewBinding;
import awais.instagrabber.fragments.main.ProfileFragment;
import awais.instagrabber.models.FeedModel; import awais.instagrabber.models.FeedModel;
import awais.instagrabber.models.PostChild; import awais.instagrabber.models.PostChild;
import awais.instagrabber.models.ProfileModel; import awais.instagrabber.models.ProfileModel;
@ -544,8 +545,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
bundle.putString("postId", feedModel.getPostId()); bundle.putString("postId", feedModel.getPostId());
bundle.putBoolean("isComment", false); bundle.putBoolean("isComment", false);
navController.navigate(R.id.action_global_likesViewerFragment, bundle); navController.navigate(R.id.action_global_likesViewerFragment, bundle);
} } else {
else {
Utils.displayToastAboveView(context, v, getString(R.string.like_without_count)); Utils.displayToastAboveView(context, v, getString(R.string.like_without_count));
} }
return true; return true;
@ -744,8 +744,7 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
if (result) { if (result) {
feedModel.setPostCaption(input.getText().toString()); feedModel.setPostCaption(input.getText().toString());
binding.caption.setText(input.getText().toString()); binding.caption.setText(input.getText().toString());
} } else Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
else Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
} }
@Override @Override
@ -927,12 +926,19 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment {
}) })
.build(); .build();
binding.postImage.setController(controller); binding.postImage.setController(controller);
binding.postImage.setOnClickListener(v -> toggleDetails()); // binding.postImage.setOnClickListener(v -> toggleDetails());
final AnimatedZoomableController zoomableController = AnimatedZoomableController.newInstance(); final AnimatedZoomableController zoomableController = AnimatedZoomableController.newInstance();
zoomableController.setMaxScaleFactor(3f); zoomableController.setMaxScaleFactor(3f);
binding.postImage.setZoomableController(zoomableController); binding.postImage.setZoomableController(zoomableController);
binding.postImage.setTapListener(new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(final MotionEvent e) {
toggleDetails();
return true;
}
});
binding.postImage.setAllowTouchInterceptionWhileZoomed(true); binding.postImage.setAllowTouchInterceptionWhileZoomed(true);
binding.postImage.setOnVerticalDragListener(onVerticalDragListener); // binding.postImage.setOnVerticalDragListener(onVerticalDragListener);
} }
private void setupSlider() { private void setupSlider() {