fix the new UI with horizontal view too

This commit is contained in:
tibbi 2020-11-01 23:42:03 +01:00
parent 9181d7c4f9
commit c7d4be1d9d
3 changed files with 11 additions and 3 deletions

View File

@ -660,15 +660,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private fun calculateContentWidth(directories: ArrayList<Directory>) { private fun calculateContentWidth(directories: ArrayList<Directory>) {
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager val layoutManager = directories_grid.layoutManager as MyGridLayoutManager
val thumbnailWidth = layoutManager.getChildAt(0)?.width ?: 0 val thumbnailWidth = (layoutManager.getChildAt(0)?.width ?: 0) + resources.getDimension(R.dimen.medium_margin).toInt() * 2
val fullWidth = ((directories.size - 1) / layoutManager.spanCount + 1) * thumbnailWidth val columnCount = (directories.size - 1) / layoutManager.spanCount + 1
val fullWidth = columnCount * thumbnailWidth
directories_horizontal_fastscroller.setContentWidth(fullWidth) directories_horizontal_fastscroller.setContentWidth(fullWidth)
directories_horizontal_fastscroller.setScrollToX(directories_grid.computeHorizontalScrollOffset()) directories_horizontal_fastscroller.setScrollToX(directories_grid.computeHorizontalScrollOffset())
} }
private fun calculateContentHeight(directories: ArrayList<Directory>) { private fun calculateContentHeight(directories: ArrayList<Directory>) {
val layoutManager = directories_grid.layoutManager as MyGridLayoutManager 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 rowCount = (directories.size - 1) / layoutManager.spanCount + 1
val fullHeight = rowCount * thumbnailHeight val fullHeight = rowCount * thumbnailHeight
directories_vertical_fastscroller.setContentHeight(fullHeight) directories_vertical_fastscroller.setContentHeight(fullHeight)

View File

@ -9,6 +9,7 @@ import android.graphics.drawable.Icon
import android.view.Menu import android.view.Menu
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.RelativeLayout
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.gson.Gson import com.google.gson.Gson
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
@ -674,6 +675,11 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
dir_check.background?.applyColorFilter(primaryColor) dir_check.background?.applyColorFilter(primaryColor)
} }
if (scrollHorizontally) {
(dir_name.layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.BELOW)
(dir_thumbnail.layoutParams as RelativeLayout.LayoutParams).addRule(RelativeLayout.ABOVE, dir_name.id)
}
if (lockedFolderPaths.contains(directory.path)) { if (lockedFolderPaths.contains(directory.path)) {
dir_lock.beVisible() dir_lock.beVisible()
dir_lock.background = ColorDrawable(config.backgroundColor) dir_lock.background = ColorDrawable(config.backgroundColor)

View File

@ -60,6 +60,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/dir_thumbnail" android:layout_below="@+id/dir_thumbnail"
android:layout_alignStart="@+id/dir_thumbnail" android:layout_alignStart="@+id/dir_thumbnail"
android:layout_alignParentBottom="true"
android:layout_toStartOf="@+id/dir_location" android:layout_toStartOf="@+id/dir_location"
android:ellipsize="middle" android:ellipsize="middle"
android:paddingTop="@dimen/medium_margin" android:paddingTop="@dimen/medium_margin"