fix FragmentAdapter returning null fragments when activity was recreated (#1647)
* fix FragmentAdapter returning null fragments when activity was recreated * remove unused import * make activity in CustomFragmentStateAdapter private
This commit is contained in:
parent
27d464351b
commit
45828fbb5a
3 changed files with 34 additions and 21 deletions
|
@ -0,0 +1,28 @@
|
|||
/* Copyright 2019 Tusky Contributors
|
||||
*
|
||||
* 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.util
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
|
||||
abstract class CustomFragmentStateAdapter(
|
||||
private val activity: FragmentActivity
|
||||
): FragmentStateAdapter(activity) {
|
||||
|
||||
fun getFragment(position: Int): Fragment?
|
||||
= activity.supportFragmentManager.findFragmentByTag("f" + getItemId(position))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue