From f2074a4d16c57dcaf092def81f5c88a987e1149c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 11 Dec 2016 21:35:05 +0100 Subject: [PATCH] move zoom handling into an own function --- .../gallery/activities/MediaActivity.kt | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 36ef96b18..f94bd388b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -50,29 +50,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mIsGetAnyIntent = getBooleanExtra(GET_ANY_INTENT, false) } + handleZooming() media_holder.setOnRefreshListener({ getMedia() }) mPath = intent.getStringExtra(DIRECTORY) mMedia = ArrayList() mShowAll = mConfig.showAll if (mShowAll) supportActionBar?.setDisplayHomeAsUpEnabled(false) - - val layoutManager = media_grid.layoutManager as GridLayoutManager - MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener { - override fun zoomIn() { - if (layoutManager.spanCount > 1) { - layoutManager.spanCount-- - MediaAdapter.actMode?.finish() - } - } - - override fun zoomOut() { - if (layoutManager.spanCount < 10) { - layoutManager.spanCount++ - MediaAdapter.actMode?.finish() - } - } - } } override fun onResume() { @@ -217,6 +201,25 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { false } + private fun handleZooming() { + val layoutManager = media_grid.layoutManager as GridLayoutManager + MyScalableRecyclerView.mListener = object : MyScalableRecyclerView.ZoomListener { + override fun zoomIn() { + if (layoutManager.spanCount > 1) { + layoutManager.spanCount-- + MediaAdapter.actMode?.finish() + } + } + + override fun zoomOut() { + if (layoutManager.spanCount < 10) { + layoutManager.spanCount++ + MediaAdapter.actMode?.finish() + } + } + } + } + override fun deleteFiles(files: ArrayList) { files.filter { it.exists() && it.isImageVideoGif() } .forEach {