properly calculate scrollbar height

This commit is contained in:
tibbi
2022-08-12 16:30:43 +02:00
parent 6aba53c387
commit 8462d76aa7
5 changed files with 46 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.Color
import android.graphics.drawable.Drawable
import android.os.Bundle
@ -17,6 +18,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
import com.simplemobiletools.launcher.BuildConfig
import com.simplemobiletools.launcher.R
import com.simplemobiletools.launcher.adapters.LaunchersAdapter
import com.simplemobiletools.launcher.extensions.getColumnCount
import com.simplemobiletools.launcher.models.AppLauncher
import kotlinx.android.synthetic.main.activity_main.*
@ -40,6 +42,18 @@ class MainActivity : SimpleActivity() {
setupNavigationBar()
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
launchers_grid.scrollToPosition(0)
launchers_fastscroller.resetManualScrolling()
setupNavigationBar()
val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager
layoutManager.spanCount = getColumnCount()
val launchers = (launchers_grid.adapter as LaunchersAdapter).launchers
setupAdapter(launchers)
}
@SuppressLint("WrongConstant")
private fun getLaunchers() {
val allApps = ArrayList<AppLauncher>()
@ -79,17 +93,12 @@ class MainActivity : SimpleActivity() {
launchers.sortBy { it.title.toLowerCase() }
val layoutManager = launchers_grid.layoutManager as MyGridLayoutManager
layoutManager.spanCount = if (portrait) {
resources.getInteger(R.integer.portrait_column_count)
} else {
resources.getInteger(R.integer.landscape_column_count)
}
layoutManager.spanCount = getColumnCount()
setupAdapter(launchers)
}
private fun setupAdapter(launchers: ArrayList<AppLauncher>) {
LaunchersAdapter(this, launchers) {
LaunchersAdapter(this, launchers, launchers_fastscroller) {
}.apply {
launchers_grid.adapter = this