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) {
binding.appView.slideOutToBottom()
binding.homeView.fadeIn()
binding.menutitle.visibility = View.GONE
}
fun showApps(binding: ActivityMainBinding) {
@ -32,7 +31,7 @@ class Animations () {
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 newColor = ContextCompat.getColor(activity, R.color.new_color)
@ -48,7 +47,7 @@ class Animations () {
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 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 overscroll: Int = dy - scrollRange
if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted) {
if (overscroll < 0 && firstVisibleItemPosition == 0 && scrollStarted && activity.appUpdate) {
activity.backToHome()
}

View file

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

View file

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