pull/981/head
gedoor 4 years ago
parent 3c37fd3190
commit 7ba47a113b
  1. 11
      app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt

@ -22,6 +22,7 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
by viewModels() by viewModels()
private var sorts = linkedMapOf<String, String>() private var sorts = linkedMapOf<String, String>()
private lateinit var adapter: TabFragmentPageAdapter private lateinit var adapter: TabFragmentPageAdapter
private val fragmentMap = hashMapOf<Long, Fragment>()
private val upSourceResult = registerForActivityResult( private val upSourceResult = registerForActivityResult(
ActivityResultContracts.StartActivityForResult() ActivityResultContracts.StartActivityForResult()
) { ) {
@ -99,12 +100,20 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
return style * 100 + super.getItemId(position) return style * 100 + super.getItemId(position)
} }
override fun containsItem(itemId: Long): Boolean {
return fragmentMap.containsKey(itemId)
}
override fun createFragment(position: Int): Fragment { override fun createFragment(position: Int): Fragment {
return RssArticlesFragment.create( val itemId = getItemId(position)
val fragment = RssArticlesFragment.create(
sorts.keys.elementAt(position), sorts.keys.elementAt(position),
sorts.values.elementAt(position) sorts.values.elementAt(position)
) )
fragmentMap[itemId] = fragment
return fragment
} }
} }
} }
Loading…
Cancel
Save