diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt index 201675028..22a62bb63 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.View import androidx.lifecycle.LiveData import androidx.lifecycle.Observer +import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import io.legado.app.App @@ -53,7 +54,11 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme private fun initView() { ATH.applyEdgeEffectColor(recycler_view) - recycler_view.layoutManager = LinearLayoutManager(requireContext()) + recycler_view.layoutManager = if (activityViewModel.isGridLayout) { + GridLayoutManager(requireContext(), 2) + } else { + LinearLayoutManager(requireContext()) + } recycler_view.addItemDecoration(VerticalDivider(requireContext())) adapter = RssArticlesAdapter(requireContext(), activityViewModel.layoutId, this) recycler_view.adapter = adapter diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt index e65dd37f4..135064bce 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssSortViewModel.kt @@ -16,9 +16,11 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { var rssSource: RssSource? = null val titleLiveData = MutableLiveData() var order = System.currentTimeMillis() + val isGridLayout get() = rssSource?.articleStyle == 2 val layoutId get() = when (rssSource?.articleStyle) { 1 -> R.layout.item_rss_article_1 + 2 -> R.layout.item_rss_article_2 else -> R.layout.item_rss_article } @@ -40,7 +42,7 @@ class RssSortViewModel(application: Application) : BaseViewModel(application) { fun switchLayout() { rssSource?.let { - if (it.articleStyle < 1) { + if (it.articleStyle < 2) { it.articleStyle = it.articleStyle + 1 } else { it.articleStyle = 0 diff --git a/app/src/main/res/drawable/bg_img_border.xml b/app/src/main/res/drawable/bg_img_border.xml new file mode 100644 index 000000000..07783726c --- /dev/null +++ b/app/src/main/res/drawable/bg_img_border.xml @@ -0,0 +1,13 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_rss_article_2.xml b/app/src/main/res/layout/item_rss_article_2.xml new file mode 100644 index 000000000..55eaa7aac --- /dev/null +++ b/app/src/main/res/layout/item_rss_article_2.xml @@ -0,0 +1,54 @@ + + + + + + + + + + \ No newline at end of file