From c7d4be1d9de26e4593b7d37d0e0517bf4c9c2dae Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Nov 2020 23:42:03 +0100 Subject: [PATCH] fix the new UI with horizontal view too --- .../gallery/pro/activities/MainActivity.kt | 7 ++++--- .../gallery/pro/adapters/DirectoryAdapter.kt | 6 ++++++ app/src/main/res/layout/directory_item_grid.xml | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 542c1f8fd..ec856d540 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -660,15 +660,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { private fun calculateContentWidth(directories: ArrayList) { val layoutManager = directories_grid.layoutManager as MyGridLayoutManager - val thumbnailWidth = layoutManager.getChildAt(0)?.width ?: 0 - val fullWidth = ((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailWidth + val thumbnailWidth = (layoutManager.getChildAt(0)?.width ?: 0) + resources.getDimension(R.dimen.medium_margin).toInt() * 2 + val columnCount = (directories.size - 1) / layoutManager.spanCount + 1 + val fullWidth = columnCount * thumbnailWidth directories_horizontal_fastscroller.setContentWidth(fullWidth) directories_horizontal_fastscroller.setScrollToX(directories_grid.computeHorizontalScrollOffset()) } private fun calculateContentHeight(directories: ArrayList) { val layoutManager = directories_grid.layoutManager as MyGridLayoutManager - val thumbnailHeight = (layoutManager.getChildAt(0)?.height ?: 0) + (resources.getDimension(R.dimen.medium_margin).toInt() * 2) + val thumbnailHeight = (layoutManager.getChildAt(0)?.height ?: 0) + resources.getDimension(R.dimen.medium_margin).toInt() * 2 val rowCount = (directories.size - 1) / layoutManager.spanCount + 1 val fullHeight = rowCount * thumbnailHeight directories_vertical_fastscroller.setContentHeight(fullHeight) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt index 460ba1921..567dd7850 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/DirectoryAdapter.kt @@ -9,6 +9,7 @@ import android.graphics.drawable.Icon import android.view.Menu import android.view.View import android.view.ViewGroup +import android.widget.RelativeLayout import com.bumptech.glide.Glide import com.google.gson.Gson import com.simplemobiletools.commons.activities.BaseSimpleActivity @@ -674,6 +675,11 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList