From 8282386f623bb757ea019c65bb0f32028a9d03fc Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 13 Jun 2021 23:56:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/rss/article/RssSortActivity.kt | 47 ++++++++----------- .../main/res/layout/activity_rss_artivles.xml | 2 +- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt index eb3f34b9f..81947f41b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt @@ -1,3 +1,5 @@ +@file:Suppress("DEPRECATION") + package io.legado.app.ui.rss.article import android.content.Intent @@ -7,8 +9,7 @@ import android.view.MenuItem import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.viewModels import androidx.fragment.app.Fragment -import androidx.viewpager2.adapter.FragmentStateAdapter -import com.google.android.material.tabs.TabLayoutMediator +import androidx.fragment.app.FragmentStatePagerAdapter import io.legado.app.R import io.legado.app.base.VMBaseActivity import io.legado.app.databinding.ActivityRssArtivlesBinding @@ -20,9 +21,8 @@ class RssSortActivity : VMBaseActivity() private lateinit var adapter: TabFragmentPageAdapter - private val fragmentMap = hashMapOf() + private val fragments = linkedMapOf() private val upSourceResult = registerForActivityResult( ActivityResultContracts.StartActivityForResult() ) { @@ -40,9 +40,7 @@ class RssSortActivity : VMBaseActivity - tab.text = sorts.keys.elementAt(position) - }.attach() + binding.tabLayout.setupWithViewPager(binding.viewPager) viewModel.titleLiveData.observe(this, { binding.titleBar.title = it }) @@ -78,10 +76,11 @@ class RssSortActivity : VMBaseActivity -