mirror of
https://github.com/accelforce/Yuito
synced 2024-12-27 08:13:00 +01:00
migrate ReportPagerAdapter to ViewPager2 (#1635)
This commit is contained in:
parent
cd52caf9e9
commit
f12f126df5
@ -78,7 +78,8 @@ class ReportActivity : BottomSheetActivity(), HasAndroidInjector {
|
||||
}
|
||||
|
||||
private fun initViewPager() {
|
||||
wizard.adapter = ReportPagerAdapter(supportFragmentManager)
|
||||
wizard.isUserInputEnabled = false
|
||||
wizard.adapter = ReportPagerAdapter(this)
|
||||
}
|
||||
|
||||
private fun subscribeObservables() {
|
||||
|
@ -16,14 +16,14 @@
|
||||
package com.keylesspalace.tusky.components.report.adapter
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentPagerAdapter
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.keylesspalace.tusky.components.report.fragments.ReportDoneFragment
|
||||
import com.keylesspalace.tusky.components.report.fragments.ReportNoteFragment
|
||||
import com.keylesspalace.tusky.components.report.fragments.ReportStatusesFragment
|
||||
|
||||
class ReportPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manager) {
|
||||
override fun getItem(position: Int): Fragment {
|
||||
class ReportPagerAdapter(activity: FragmentActivity) : FragmentStateAdapter(activity) {
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when (position) {
|
||||
0 -> ReportStatusesFragment.newInstance()
|
||||
1 -> ReportNoteFragment.newInstance()
|
||||
@ -32,5 +32,5 @@ class ReportPagerAdapter(manager: FragmentManager) : FragmentPagerAdapter(manage
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCount(): Int = 3
|
||||
override fun getItemCount() = 3
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/* Copyright 2019 Joel Pyska
|
||||
*
|
||||
* This file is a part of Tusky.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
* Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with Tusky; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
package com.keylesspalace.tusky.view
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
class NoSwipeViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs) {
|
||||
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
|
||||
<include layout="@layout/toolbar_basic" />
|
||||
|
||||
<com.keylesspalace.tusky.view.NoSwipeViewPager
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/wizard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user