Fixed incorrect default position in shortcut view's recyclerview.

This commit is contained in:
ottoptj 2024-06-04 02:33:27 +03:00
commit eb91eb8a9d
4 changed files with 10 additions and 11 deletions

View file

@ -24,7 +24,6 @@ class Animations () {
fun showHome(binding: ActivityMainBinding) { fun showHome(binding: ActivityMainBinding) {
binding.appView.slideOutToBottom() binding.appView.slideOutToBottom()
binding.homeView.fadeIn() binding.homeView.fadeIn()
binding.menutitle.visibility = View.GONE
} }
fun showApps(binding: ActivityMainBinding) { fun showApps(binding: ActivityMainBinding) {
@ -32,7 +31,7 @@ class Animations () {
binding.appView.slideInFromBottom() binding.appView.slideInFromBottom()
} }
fun backgroundIn(activity: Activity, binding: ActivityMainBinding, duration: Long = 100) { fun backgroundIn(activity: Activity, duration: Long = 100) {
val originalColor = ContextCompat.getColor(activity, R.color.original_color) val originalColor = ContextCompat.getColor(activity, R.color.original_color)
val newColor = ContextCompat.getColor(activity, R.color.new_color) val newColor = ContextCompat.getColor(activity, R.color.new_color)
@ -48,7 +47,7 @@ class Animations () {
backgroundColorAnimator.start() backgroundColorAnimator.start()
} }
fun backgroundOut(activity: Activity, binding: ActivityMainBinding, duration: Long = 100) { fun backgroundOut(activity: Activity, duration: Long = 100) {
val originalColor = ContextCompat.getColor(activity, R.color.new_color) val originalColor = ContextCompat.getColor(activity, R.color.new_color)
val newColor = ContextCompat.getColor(activity, R.color.original_color) val newColor = ContextCompat.getColor(activity, R.color.original_color)

View file

@ -17,7 +17,7 @@ class AppMenuLinearLayoutManager(private val activity: MainActivity) : LinearLay
val scrollRange = super.scrollVerticallyBy(dy, recycler, state) val scrollRange = super.scrollVerticallyBy(dy, recycler, state)
val overscroll: Int = dy - scrollRange val overscroll: Int = dy - scrollRange
if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted) { if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted && activity.appUpdate) {
activity.backToHome() activity.backToHome()
} }

View file

@ -240,7 +240,6 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
textView.setOnLongClickListener { textView.setOnLongClickListener {
adapter.menuMode = "shortcut" adapter.menuMode = "shortcut"
adapter.shortcutTextView = textView adapter.shortcutTextView = textView
binding.menutitle.visibility = View.VISIBLE
toAppMenu() toAppMenu()
return@setOnLongClickListener true return@setOnLongClickListener true
@ -366,9 +365,8 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
} }
fun openAppMenuActivity() { fun openAppMenuActivity() {
//AppMenuActivity.start(this, installedApps) {
//}
adapter.menuMode = "app" adapter.menuMode = "app"
binding.menutitle.visibility = View.GONE
toAppMenu() toAppMenu()
} }
@ -376,8 +374,11 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
closeKeyboard() closeKeyboard()
searchView.setText("") searchView.setText("")
animations.showHome(binding) animations.showHome(binding)
animations.backgroundOut(this@MainActivity, binding) animations.backgroundOut(this@MainActivity)
val handler = Handler(Looper.getMainLooper()) val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
binding.menutitle.visibility = View.VISIBLE
}, 100)
handler.postDelayed({ handler.postDelayed({
recyclerView.scrollToPosition(0) recyclerView.scrollToPosition(0)
}, 150) }, 150)
@ -385,7 +386,7 @@ class MainActivity : AppCompatActivity(), AppMenuAdapter.OnItemClickListener, Ap
private fun toAppMenu() { private fun toAppMenu() {
animations.showApps(binding) animations.showApps(binding)
animations.backgroundIn(this@MainActivity, binding) animations.backgroundIn(this@MainActivity)
} }
override fun onItemClick(appInfo: LauncherActivityInfo, userHandle: UserHandle) { override fun onItemClick(appInfo: LauncherActivityInfo, userHandle: UserHandle) {

View file

@ -33,8 +33,7 @@
android:text="@string/select_an_app" android:text="@string/select_an_app"
android:textAppearance="@android:style/TextAppearance.DeviceDefault" android:textAppearance="@android:style/TextAppearance.DeviceDefault"
android:textColor="#C1F3F3F3" android:textColor="#C1F3F3F3"
android:textSize="36sp" android:textSize="36sp" />
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view" android:id="@+id/recycler_view"