From 72381ba53d98f4a9b97eeb57e355ea205f493378 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 11 Dec 2016 21:38:15 +0100 Subject: [PATCH] allow changing directory column cnt too --- .../gallery/activities/MainActivity.kt | 22 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index c314944c4..852be6f43 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -10,6 +10,7 @@ import android.os.Bundle import android.provider.MediaStore import android.support.design.widget.Snackbar import android.support.v4.app.ActivityCompat +import android.support.v7.widget.GridLayoutManager import android.view.Menu import android.view.MenuItem import android.view.View @@ -20,6 +21,7 @@ import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask import com.simplemobiletools.gallery.dialogs.ChangeSortingDialog import com.simplemobiletools.gallery.helpers.* import com.simplemobiletools.gallery.models.Directory +import com.simplemobiletools.gallery.views.MyScalableRecyclerView import kotlinx.android.synthetic.main.activity_main.* import java.io.File import java.util.* @@ -60,6 +62,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mToBeDeleted = ArrayList() directories_holder.setOnRefreshListener({ getDirectories() }) mDirs = ArrayList() + handleZooming() } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -229,6 +232,25 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { getDirectories() } + private fun handleZooming() { + val layoutManager = directories_grid.layoutManager as GridLayoutManager + MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + layoutManager.spanCount-- + DirectoryAdapter.actMode?.finish() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < 10) { + layoutManager.spanCount++ + DirectoryAdapter.actMode?.finish() + } + } + } + } + private fun isPickImageIntent(intent: Intent) = isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent)) private fun isPickVideoIntent(intent: Intent) = isPickIntent(intent) && (hasVideoContentData(intent) || isVideoType(intent)) diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index e0bb48782..cf32a3fb7 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -11,7 +11,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> -