aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java38
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java72
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/customviews/TableHorinzontalScrollView.java112
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragmentBase.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/markdown/CustomMarkwonAdapter.java34
-rw-r--r--app/src/main/res/layout/adapter_table_block.xml4
9 files changed, 218 insertions, 88 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index d89f0bd1..117f96e2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -868,6 +868,20 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
}
+ @Override
+ public void lockSwipeRightToGoBack() {
+ if (mSliderPanel != null) {
+ mSliderPanel.lock();
+ }
+ }
+
+ @Override
+ public void unlockSwipeRightToGoBack() {
+ if (mSliderPanel != null) {
+ mSliderPanel.unlock();
+ }
+ }
+
private class SectionsPagerAdapter extends FragmentStateAdapter {
public SectionsPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index 42dd48ee..0021c8e3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -1379,12 +1379,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
- ((ViewPostDetailActivity) mActivity).lockSwipeRightToGoBack();
+ mActivity.lockSwipeRightToGoBack();
}
@Override
public void unlockSwipe() {
- ((ViewPostDetailActivity) mActivity).unlockSwipeRightToGoBack();
+ mActivity.unlockSwipeRightToGoBack();
}
});
commentMarkdownView.setLayoutManager(linearLayoutManager);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
index 1112cf51..75d7fcbf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java
@@ -67,14 +67,9 @@ import io.noties.markwon.core.MarkwonTheme;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.FetchVideoLinkListener;
-import ml.docilealligator.infinityforreddit.thing.FetchRedgifsVideoLinks;
-import ml.docilealligator.infinityforreddit.post.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveMemoryCenterInisdeDownsampleStrategy;
-import ml.docilealligator.infinityforreddit.thing.SaveThing;
-import ml.docilealligator.infinityforreddit.thing.StreamableVideo;
-import ml.docilealligator.infinityforreddit.thing.VoteThing;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
@@ -114,8 +109,13 @@ import ml.docilealligator.infinityforreddit.markdown.EvenBetterLinkMovementMetho
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifEntry;
import ml.docilealligator.infinityforreddit.markdown.ImageAndGifPlugin;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
+import ml.docilealligator.infinityforreddit.post.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostPagingSource;
+import ml.docilealligator.infinityforreddit.thing.FetchRedgifsVideoLinks;
+import ml.docilealligator.infinityforreddit.thing.SaveThing;
+import ml.docilealligator.infinityforreddit.thing.StreamableVideo;
+import ml.docilealligator.infinityforreddit.thing.VoteThing;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -2268,12 +2268,11 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface, mPostDetailMarkwon,
mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor,
- mCardViewColor, mCommentColor, mScale,
- galleryImage -> {});
+ mCardViewColor, mCommentColor, mScale);
binding.galleryRecyclerViewItemPostDetailGallery.setAdapter(adapter);
new PagerSnapHelper().attachToRecyclerView(binding.galleryRecyclerViewItemPostDetailGallery);
binding.galleryRecyclerViewItemPostDetailGallery.setOnTouchListener((v, motionEvent) -> {
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
@@ -2311,7 +2310,10 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
private float downX;
private float downY;
private boolean dragged;
+ private long downTime;
private final int minTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
+ private final int longClickThreshold = ViewConfiguration.getLongPressTimeout();
+ private boolean longPressed;
@Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
@@ -2320,18 +2322,27 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
case MotionEvent.ACTION_DOWN:
downX = e.getRawX();
downY = e.getRawY();
+ downTime = System.currentTimeMillis();
break;
case MotionEvent.ACTION_MOVE:
- if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
+ if (Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
dragged = true;
}
+ if (!dragged && !longPressed) {
+ if (System.currentTimeMillis() - downTime >= longClickThreshold) {
+ itemView.performLongClick();
+ longPressed = true;
+ }
+ }
break;
case MotionEvent.ACTION_UP:
if (!dragged) {
- int position = getBindingAdapterPosition();
- if (position >= 0) {
- if (mPost != null) {
- openMedia(mPost, layoutManager.findFirstVisibleItemPosition());
+ if (System.currentTimeMillis() - downTime < longClickThreshold) {
+ int position = getBindingAdapterPosition();
+ if (position >= 0) {
+ if (mPost != null) {
+ openMedia(mPost, layoutManager.findFirstVisibleItemPosition());
+ }
}
}
}
@@ -2339,6 +2350,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
downX = 0;
downY = 0;
dragged = false;
+ longPressed = false;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java
index 7d888a93..386e29f9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostGalleryTypeImageRecyclerViewAdapter.java
@@ -44,27 +44,23 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
private boolean blurImage;
private float ratio;
private final boolean showCaption;
- private final ItemClickListener itemClickListener;
public PostGalleryTypeImageRecyclerViewAdapter(RequestManager glide, Typeface typeface,
SaveMemoryCenterInisdeDownsampleStrategy saveMemoryCenterInisdeDownsampleStrategy,
- int mColorAccent, int mPrimaryTextColor, float scale,
- ItemClickListener itemClickListener) {
+ int mColorAccent, int mPrimaryTextColor, float scale) {
this.glide = glide;
this.typeface = typeface;
this.saveMemoryCenterInisdeDownsampleStrategy = saveMemoryCenterInisdeDownsampleStrategy;
this.mColorAccent = mColorAccent;
this.mPrimaryTextColor = mPrimaryTextColor;
this.mScale = scale;
- this.itemClickListener = itemClickListener;
showCaption = false;
}
public PostGalleryTypeImageRecyclerViewAdapter(RequestManager glide, Typeface typeface, Markwon postDetailMarkwon,
SaveMemoryCenterInisdeDownsampleStrategy saveMemoryCenterInisdeDownsampleStrategy,
int mColorAccent, int mPrimaryTextColor, int mCardViewColor,
- int mCommentColor, float scale,
- ItemClickListener itemClickListener) {
+ int mCommentColor, float scale) {
this.glide = glide;
this.typeface = typeface;
this.mPostDetailMarkwon = postDetailMarkwon;
@@ -74,7 +70,6 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
this.mCardViewColor = mCardViewColor;
this.mCommentColor = mCommentColor;
this.mScale = scale;
- this.itemClickListener = itemClickListener;
showCaption = true;
}
@@ -208,11 +203,6 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
this.binding = binding;
- itemView.setOnLongClickListener(v -> {
- itemClickListener.OnItemLongClick(galleryImages.get(getBindingAdapterPosition()));
- return true;
- });
-
if (typeface != null) {
binding.errorTextViewItemGalleryImageInPostFeed.setTypeface(typeface);
}
@@ -226,8 +216,4 @@ public class PostGalleryTypeImageRecyclerViewAdapter extends RecyclerView.Adapte
});
}
}
-
- public interface ItemClickListener {
- void OnItemLongClick(Post.Gallery galleryImage);
- }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index 72022ea9..c230751a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -108,8 +108,6 @@ import ml.docilealligator.infinityforreddit.databinding.ItemPostVideoTypeAutopla
import ml.docilealligator.infinityforreddit.databinding.ItemPostVideoTypeAutoplayLegacyControllerBinding;
import ml.docilealligator.infinityforreddit.databinding.ItemPostWithPreviewBinding;
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToPostDetailFragment;
-import ml.docilealligator.infinityforreddit.fragments.FragmentCommunicator;
-import ml.docilealligator.infinityforreddit.fragments.PostFragment;
import ml.docilealligator.infinityforreddit.fragments.PostFragmentBase;
import ml.docilealligator.infinityforreddit.post.FetchStreamableVideo;
import ml.docilealligator.infinityforreddit.post.MarkPostAsReadInterface;
@@ -3366,11 +3364,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
noPreviewImageView.setColorFilter(mNoPreviewPostTypeIconTint, android.graphics.PorterDuff.Mode.SRC_IN);
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
- mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
- galleryImage -> itemView.performLongClick());
+ mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
galleryRecyclerView.setAdapter(adapter);
galleryRecyclerView.setOnTouchListener((v, motionEvent) -> {
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
@@ -3413,7 +3410,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private float downX;
private float downY;
private boolean dragged;
+ private long downTime;
private final int minTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
+ private final int longClickThreshold = ViewConfiguration.getLongPressTimeout();
+ private boolean longPressed;
@Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
@@ -3422,19 +3422,47 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
case MotionEvent.ACTION_DOWN:
downX = e.getRawX();
downY = e.getRawY();
+ downTime = System.currentTimeMillis();
+
+ if (mActivity.mSliderPanel != null) {
+ mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
+ }
+ if (mActivity.mViewPager2 != null) {
+ mActivity.mViewPager2.setUserInputEnabled(false);
+ }
+ mActivity.lockSwipeRightToGoBack();
+ swipeLocked = true;
break;
case MotionEvent.ACTION_MOVE:
if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
dragged = true;
}
+
+ if (!dragged && !longPressed) {
+ if (System.currentTimeMillis() - downTime >= longClickThreshold) {
+ itemView.performLongClick();
+ longPressed = true;
+ }
+ }
+
+ if (mActivity.mSliderPanel != null) {
+ mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
+ }
+ if (mActivity.mViewPager2 != null) {
+ mActivity.mViewPager2.setUserInputEnabled(false);
+ }
+ mActivity.lockSwipeRightToGoBack();
+ swipeLocked = true;
break;
case MotionEvent.ACTION_UP:
if (!dragged) {
- int position = getBindingAdapterPosition();
- if (position >= 0) {
- if (post != null) {
- markPostRead(post, true);
- openMedia(post, layoutManager.findFirstVisibleItemPosition());
+ if (System.currentTimeMillis() - downTime < longClickThreshold) {
+ int position = getBindingAdapterPosition();
+ if (position >= 0) {
+ if (post != null) {
+ markPostRead(post, true);
+ openMedia(post, layoutManager.findFirstVisibleItemPosition());
+ }
}
}
}
@@ -3442,6 +3470,17 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
downX = 0;
downY = 0;
dragged = false;
+ longPressed = false;
+
+ if (mActivity.mSliderPanel != null) {
+ mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
+ }
+
+ if (mActivity.mViewPager2 != null) {
+ mActivity.mViewPager2.setUserInputEnabled(true);
+ }
+ mActivity.unlockSwipeRightToGoBack();
+ swipeLocked = false;
}
return false;
}
@@ -4049,10 +4088,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
imageIndexTextView.setBorderColor(mMediaIndicatorBackgroundColor);
adapter = new PostGalleryTypeImageRecyclerViewAdapter(mGlide, mActivity.typeface,
- mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale,
- galleryImage -> {});
+ mSaveMemoryCenterInsideDownsampleStrategy, mColorAccent, mPrimaryTextColor, mScale);
recyclerView.setOnTouchListener((v, motionEvent) -> {
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP || motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
if (mActivity.mSliderPanel != null) {
mActivity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
}
@@ -4096,6 +4134,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
private long downTime;
private final int minTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
private final int longClickThreshold = ViewConfiguration.getLongPressTimeout();
+ private boolean longPressed;
@Override
public boolean onInterceptTouchEvent(@NonNull RecyclerView rv, @NonNull MotionEvent e) {
@@ -4107,12 +4146,13 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
downTime = System.currentTimeMillis();
break;
case MotionEvent.ACTION_MOVE:
- if(Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
+ if (Math.abs(e.getRawX() - downX) > minTouchSlop || Math.abs(e.getRawY() - downY) > minTouchSlop) {
dragged = true;
}
- if (!dragged) {
+ if (!dragged && !longPressed) {
if (System.currentTimeMillis() - downTime >= longClickThreshold) {
onLongClick();
+ longPressed = true;
}
}
break;
@@ -4126,7 +4166,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
downX = 0;
downY = 0;
dragged = false;
-
+ longPressed = false;
}
return false;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/TableHorinzontalScrollView.java b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/TableHorinzontalScrollView.java
new file mode 100644
index 00000000..6d8615cf
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/customviews/TableHorinzontalScrollView.java
@@ -0,0 +1,112 @@
+package ml.docilealligator.infinityforreddit.customviews;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.ViewParent;
+import android.widget.HorizontalScrollView;
+
+import androidx.viewpager2.widget.ViewPager2;
+
+import ml.docilealligator.infinityforreddit.customviews.slidr.widget.SliderPanel;
+
+public class TableHorinzontalScrollView extends HorizontalScrollView {
+ private CustomToroContainer toroContainer;
+ private ViewPager2 viewPager2;
+ private SliderPanel sliderPanel;
+
+ private float lastX = 0.0f;
+ private float lastY = 0.0f;
+
+ public TableHorinzontalScrollView(Context context) {
+ super(context);
+ init();
+ }
+
+ public TableHorinzontalScrollView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public TableHorinzontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ public TableHorinzontalScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ init();
+ }
+
+ private void init() {
+ new Handler(Looper.getMainLooper()).post(() -> {
+ ViewParent parent = getParent();
+ while (parent != null) {
+ if (parent instanceof CustomToroContainer) {
+ toroContainer = (CustomToroContainer) parent;
+ } else if (parent instanceof ViewPager2) {
+ viewPager2 = (ViewPager2) parent;
+ } else if (parent instanceof SliderPanel) {
+ sliderPanel = (SliderPanel) parent;
+ }
+
+ parent = parent.getParent();
+ }
+ });
+ }
+
+ @Override
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ boolean allowScroll = true;
+
+ switch (ev.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ lastX = ev.getX();
+ lastY = ev.getY();
+
+ if (toroContainer != null) {
+ toroContainer.requestDisallowInterceptTouchEvent(true);
+ }
+ if (viewPager2 != null) {
+ viewPager2.setUserInputEnabled(false);
+ }
+ if (sliderPanel != null) {
+ sliderPanel.requestDisallowInterceptTouchEvent(true);
+ }
+ break;
+ case MotionEvent.ACTION_UP:
+ if (toroContainer != null) {
+ toroContainer.requestDisallowInterceptTouchEvent(false);
+ }
+ if (viewPager2 != null) {
+ viewPager2.setUserInputEnabled(true);
+ }
+ if (sliderPanel != null) {
+ sliderPanel.requestDisallowInterceptTouchEvent(false);
+ }
+ break;
+ case MotionEvent.ACTION_MOVE:
+ float currentX = ev.getX();
+ float currentY = ev.getY();
+ float dx = Math.abs(currentX - lastX);
+ float dy = Math.abs(currentY - lastY);
+
+ allowScroll = dy < dx;
+
+ if (toroContainer != null) {
+ toroContainer.requestDisallowInterceptTouchEvent(allowScroll);
+ }
+ if (viewPager2 != null) {
+ viewPager2.setUserInputEnabled(false);
+ }
+ if (sliderPanel != null) {
+ sliderPanel.requestDisallowInterceptTouchEvent(true);
+ }
+ break;
+ }
+
+ return allowScroll && super.onInterceptTouchEvent(ev);
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragmentBase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragmentBase.java
index c2e0a470..10d10558 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragmentBase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragmentBase.java
@@ -256,8 +256,8 @@ public abstract class PostFragmentBase extends Fragment {
if (!exceedThreshold && isCurrentlyActive) {
exceedThreshold = true;
if (vibrateWhenActionTriggered) {
- viewHolder.itemView.setHapticFeedbackEnabled(true);
- viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ itemView.setHapticFeedbackEnabled(true);
+ itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}
backgroundSwipeRight.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
@@ -274,12 +274,12 @@ public abstract class PostFragmentBase extends Fragment {
drawableSwipeRight.draw(c);
} else if (dX < 0) {
if (-dX > (itemView.getRight() - itemView.getLeft()) * swipeActionThreshold) {
- dX = -(viewHolder.itemView.getRight() - viewHolder.itemView.getLeft()) * swipeActionThreshold;
+ dX = -(itemView.getRight() - itemView.getLeft()) * swipeActionThreshold;
if (!exceedThreshold && isCurrentlyActive) {
exceedThreshold = true;
if (vibrateWhenActionTriggered) {
- viewHolder.itemView.setHapticFeedbackEnabled(true);
- viewHolder.itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ itemView.setHapticFeedbackEnabled(true);
+ itemView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}
backgroundSwipeLeft.setBounds(0, itemView.getTop(), itemView.getRight(), itemView.getBottom());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/CustomMarkwonAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/CustomMarkwonAdapter.java
index dbe4b23f..a64b00ed 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/CustomMarkwonAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/markdown/CustomMarkwonAdapter.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.markdown;
import android.util.SparseArray;
import android.view.LayoutInflater;
-import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
@@ -142,39 +141,6 @@ public class CustomMarkwonAdapter extends MarkwonAdapter {
return false;
});
} else if (holder.itemView instanceof HorizontalScrollView) {
- holder.itemView.setOnTouchListener(new View.OnTouchListener() {
- boolean isSliderPanelLockedAlready;
- boolean isViewPager2UserInputEnabledAlready;
- @Override
- public boolean onTouch(View v, MotionEvent motionEvent) {
- if (motionEvent.getActionMasked() == MotionEvent.ACTION_UP) {
- if (activity.mSliderPanel != null) {
- activity.mSliderPanel.requestDisallowInterceptTouchEvent(false);
- }
-
- if (activity.mViewPager2 != null && isViewPager2UserInputEnabledAlready) {
- activity.mViewPager2.setUserInputEnabled(true);
- }
-
- if (!isSliderPanelLockedAlready) {
- activity.unlockSwipeRightToGoBack();
- }
- } else {
- if (activity.mSliderPanel != null) {
- isSliderPanelLockedAlready = activity.mSliderPanel.isLocked();
- activity.mSliderPanel.requestDisallowInterceptTouchEvent(true);
- }
- if (activity.mViewPager2 != null) {
- isViewPager2UserInputEnabledAlready = activity.mViewPager2.isUserInputEnabled();
- activity.mViewPager2.setUserInputEnabled(false);
- }
- activity.lockSwipeRightToGoBack();
- }
-
- return false;
- }
- });
-
TableLayout tableLayout = holder.itemView.findViewById(R.id.table_layout);
if (tableLayout != null) {
for (int i = 0; i < tableLayout.getChildCount(); i++) {
diff --git a/app/src/main/res/layout/adapter_table_block.xml b/app/src/main/res/layout/adapter_table_block.xml
index e924f89e..29ce9279 100644
--- a/app/src/main/res/layout/adapter_table_block.xml
+++ b/app/src/main/res/layout/adapter_table_block.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<HorizontalScrollView
+<ml.docilealligator.infinityforreddit.customviews.TableHorinzontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -13,4 +13,4 @@
android:layout_height="wrap_content"
android:stretchColumns="*" />
-</HorizontalScrollView>
+</ml.docilealligator.infinityforreddit.customviews.TableHorinzontalScrollView>