Skip to content

Commit

Permalink
Recycler Grid Zooming enabled only for MediaView.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Aug 5, 2024
1 parent cf222d4 commit bf12ea2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit bf12ea2

Please sign in to comment.