From bf12ea2dd4d0c22160092843f2cbe57c2b7ec61e Mon Sep 17 00:00:00 2001 From: A117870935 Date: Thu, 25 May 2023 12:34:13 +0530 Subject: [PATCH] Recycler Grid Zooming enabled only for MediaView. --- .../ui/fragment/ExtendedListFragment.java | 34 ++++++++++++------- .../android/ui/fragment/GalleryFragment.java | 2 ++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java index 52d0d78672de..7ed14890ccbe 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -16,6 +16,7 @@ package com.owncloud.android.ui.fragment; import android.animation.LayoutTransition; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; @@ -325,21 +326,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); - mScale = preferences.getGridColumns(); setGridViewColumns(1f); - mScaleGestureDetector = new ScaleGestureDetector(MainApp.getAppContext(), new ScaleListener()); - - getRecyclerView().setOnTouchListener((view, motionEvent) -> { - mScaleGestureDetector.onTouchEvent(motionEvent); - - if (motionEvent.getAction() == MotionEvent.ACTION_UP) { - view.performClick(); - } - - return false; - }); - // Pull-down to refresh layout mRefreshListLayout = binding.swipeContainingList; viewThemeUtils.androidx.themeSwipeRefreshLayout(mRefreshListLayout); @@ -363,6 +351,26 @@ public void onDestroyView() { binding = null; } + /** + * method to enable recyclerview zooming for grid view + */ + @SuppressLint("ClickableViewAccessibility") + public void enableRecyclerViewGridZooming() { + mScale = preferences.getGridColumns(); + + mScaleGestureDetector = new ScaleGestureDetector(MainApp.getAppContext(), new ScaleListener()); + + getRecyclerView().setOnTouchListener((view, motionEvent) -> { + mScaleGestureDetector.onTouchEvent(motionEvent); + + if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + view.performClick(); + } + + return false; + }); + } + private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override public boolean onScale(ScaleGestureDetector detector) { diff --git a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java index b264078da243..067e6362dc08 100644 --- a/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java +++ b/app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java @@ -148,6 +148,8 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { } }); + enableRecyclerViewGridZooming(); + Log_OC.i(this, "onCreateView() in GalleryFragment end"); return v; }