diff options
| author | 2023-04-24 04:01:54 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:53 -0700 | |
| commit | d8c102444c5e9d8b2c1f78aac009ee8df4a0d415 (patch) | |
| tree | 656463b4ae2d6a447b8086cee5c292806c2c683d /src/android | |
| parent | android: Fix A button preference key (diff) | |
| download | yuzu-d8c102444c5e9d8b2c1f78aac009ee8df4a0d415.tar.gz yuzu-d8c102444c5e9d8b2c1f78aac009ee8df4a0d415.tar.xz yuzu-d8c102444c5e9d8b2c1f78aac009ee8df4a0d415.zip | |
android: Fix first time setup scrolling bug
If you quickly scrolled from the second page to the first and then back, the next/back buttons would disappear.
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt | 33 | ||||
| -rw-r--r-- | src/android/app/src/main/res/layout/fragment_setup.xml | 2 |
2 files changed, 17 insertions, 18 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt index e7d102aad..35c84699b 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/SetupFragment.kt | |||
| @@ -110,23 +110,24 @@ class SetupFragment : Fragment() { | |||
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | binding.viewPager2.registerOnPageChangeCallback(object : OnPageChangeCallback() { | 112 | binding.viewPager2.registerOnPageChangeCallback(object : OnPageChangeCallback() { |
| 113 | override fun onPageScrolled( | 113 | var previousPosition: Int = 0 |
| 114 | position: Int, | ||
| 115 | positionOffset: Float, | ||
| 116 | positionOffsetPixels: Int | ||
| 117 | ) { | ||
| 118 | super.onPageScrolled(position, positionOffset, positionOffsetPixels) | ||
| 119 | if (position == 0) { | ||
| 120 | hideView(binding.buttonBack) | ||
| 121 | } else { | ||
| 122 | showView(binding.buttonBack) | ||
| 123 | } | ||
| 124 | 114 | ||
| 125 | if (position == pages.size - 1 || position == 0) { | 115 | override fun onPageSelected(position: Int) { |
| 116 | super.onPageSelected(position) | ||
| 117 | |||
| 118 | if (position == 1 && previousPosition == 0) { | ||
| 119 | showView(binding.buttonNext) | ||
| 120 | showView(binding.buttonBack) | ||
| 121 | } else if (position == 0 && previousPosition == 1) { | ||
| 122 | hideView(binding.buttonBack) | ||
| 123 | hideView(binding.buttonNext) | ||
| 124 | } else if (position == pages.size - 1 && previousPosition == pages.size - 2) { | ||
| 126 | hideView(binding.buttonNext) | 125 | hideView(binding.buttonNext) |
| 127 | } else { | 126 | } else if (position == pages.size - 2 && previousPosition == pages.size - 1) { |
| 128 | showView(binding.buttonNext) | 127 | showView(binding.buttonNext) |
| 129 | } | 128 | } |
| 129 | |||
| 130 | previousPosition = position | ||
| 130 | } | 131 | } |
| 131 | }) | 132 | }) |
| 132 | 133 | ||
| @@ -154,10 +155,6 @@ class SetupFragment : Fragment() { | |||
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | private fun showView(view: View) { | 157 | private fun showView(view: View) { |
| 157 | if (view.visibility == View.VISIBLE) { | ||
| 158 | return | ||
| 159 | } | ||
| 160 | |||
| 161 | view.apply { | 158 | view.apply { |
| 162 | alpha = 0f | 159 | alpha = 0f |
| 163 | visibility = View.VISIBLE | 160 | visibility = View.VISIBLE |
| @@ -169,7 +166,7 @@ class SetupFragment : Fragment() { | |||
| 169 | } | 166 | } |
| 170 | 167 | ||
| 171 | private fun hideView(view: View) { | 168 | private fun hideView(view: View) { |
| 172 | if (view.visibility == View.GONE) { | 169 | if (view.visibility == View.INVISIBLE) { |
| 173 | return | 170 | return |
| 174 | } | 171 | } |
| 175 | 172 | ||
diff --git a/src/android/app/src/main/res/layout/fragment_setup.xml b/src/android/app/src/main/res/layout/fragment_setup.xml index 6f8993152..adaaa4959 100644 --- a/src/android/app/src/main/res/layout/fragment_setup.xml +++ b/src/android/app/src/main/res/layout/fragment_setup.xml | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | android:layout_height="wrap_content" | 22 | android:layout_height="wrap_content" |
| 23 | android:layout_margin="16dp" | 23 | android:layout_margin="16dp" |
| 24 | android:text="@string/next" | 24 | android:text="@string/next" |
| 25 | android:visibility="invisible" | ||
| 25 | app:layout_constraintBottom_toBottomOf="parent" | 26 | app:layout_constraintBottom_toBottomOf="parent" |
| 26 | app:layout_constraintEnd_toEndOf="parent" /> | 27 | app:layout_constraintEnd_toEndOf="parent" /> |
| 27 | 28 | ||
| @@ -32,6 +33,7 @@ | |||
| 32 | android:layout_height="wrap_content" | 33 | android:layout_height="wrap_content" |
| 33 | android:layout_margin="16dp" | 34 | android:layout_margin="16dp" |
| 34 | android:text="@string/back" | 35 | android:text="@string/back" |
| 36 | android:visibility="invisible" | ||
| 35 | app:layout_constraintBottom_toBottomOf="parent" | 37 | app:layout_constraintBottom_toBottomOf="parent" |
| 36 | app:layout_constraintStart_toStartOf="parent" /> | 38 | app:layout_constraintStart_toStartOf="parent" /> |
| 37 | 39 | ||