From 5fbf734f8959f9faf904eb92ba80058f17c312b1 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 27 Apr 2021 22:41:55 +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 --- .../main/assets/defaultData/readConfig.json | 50 +++++++++++++++++++ .../app/ui/rss/article/RssArticlesFragment.kt | 34 ++++++++----- .../ui/rss/favorites/RssFavoritesActivity.kt | 2 +- .../res/layout/activity_rss_favorites.xml | 15 ++++-- .../main/res/layout/fragment_rss_articles.xml | 15 +++--- 5 files changed, 88 insertions(+), 28 deletions(-) diff --git a/app/src/main/assets/defaultData/readConfig.json b/app/src/main/assets/defaultData/readConfig.json index 968141a0c..4b8c27ef4 100644 --- a/app/src/main/assets/defaultData/readConfig.json +++ b/app/src/main/assets/defaultData/readConfig.json @@ -1,4 +1,54 @@ [ + { + "bgStr": "#ffc0edc6", + "bgStrEInk": "#FFFFFF", + "bgStrNight": "#000000", + "bgType": 0, + "bgTypeEInk": 0, + "bgTypeNight": 0, + "darkStatusIcon": true, + "darkStatusIconEInk": true, + "darkStatusIconNight": false, + "footerMode": 0, + "footerPaddingBottom": 10, + "footerPaddingLeft": 13, + "footerPaddingRight": 17, + "footerPaddingTop": 0, + "headerMode": 0, + "headerPaddingBottom": 0, + "headerPaddingLeft": 19, + "headerPaddingRight": 16, + "headerPaddingTop": 10, + "letterSpacing": -0.14, + "lineSpacingExtra": 7, + "name": "微信读书", + "paddingBottom": 4, + "paddingLeft": 22, + "paddingRight": 22, + "paddingTop": 5, + "pageAnim": 3, + "pageAnimEInk": 3, + "paragraphIndent": "  ", + "paragraphSpacing": 6, + "showFooterLine": true, + "showHeaderLine": true, + "textBold": 0, + "textColor": "#ff0b0b0b", + "textColorEInk": "#000000", + "textColorNight": "#ADADAD", + "textSize": 24, + "tipColor": -10461088, + "tipFooterLeft": 7, + "tipFooterMiddle": 0, + "tipFooterRight": 6, + "tipHeaderLeft": 1, + "tipHeaderMiddle": 0, + "tipHeaderRight": 2, + "titleBottomSpacing": 0, + "titleMode": 0, + "titleSize": 4, + "titleTopSpacing": 0 + }, { "bgStr": "#FFFFFF", "bgStrNight": "#000000", 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 221b296ae..8bdd5faa9 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 @@ -16,6 +16,7 @@ import io.legado.app.data.entities.RssArticle import io.legado.app.databinding.FragmentRssArticlesBinding import io.legado.app.databinding.ViewLoadMoreBinding import io.legado.app.lib.theme.ATH +import io.legado.app.lib.theme.accentColor import io.legado.app.ui.rss.read.ReadRssActivity import io.legado.app.ui.widget.recycler.LoadMoreView import io.legado.app.ui.widget.recycler.VerticalDivider @@ -50,18 +51,18 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { viewModel.init(arguments) initView() - binding.refreshRecyclerView.startLoading() initView() initData() } private fun initView() = with(binding) { - ATH.applyEdgeEffectColor(refreshRecyclerView.recyclerView) - refreshRecyclerView.recyclerView.layoutManager = if (activityViewModel.isGridLayout) { - refreshRecyclerView.recyclerView.setPadding(8, 0, 8, 0) + refreshLayout.setColorSchemeColors(accentColor) + ATH.applyEdgeEffectColor(recyclerView) + recyclerView.layoutManager = if (activityViewModel.isGridLayout) { + recyclerView.setPadding(8, 0, 8, 0) GridLayoutManager(requireContext(), 2) } else { - refreshRecyclerView.recyclerView.addItemDecoration(VerticalDivider(requireContext())) + recyclerView.addItemDecoration(VerticalDivider(requireContext())) LinearLayoutManager(requireContext()) } @@ -70,18 +71,15 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme 2 -> RssArticlesAdapter2(requireContext(), this@RssArticlesFragment) else -> RssArticlesAdapter(requireContext(), this@RssArticlesFragment) } - refreshRecyclerView.recyclerView.adapter = adapter + recyclerView.adapter = adapter loadMoreView = LoadMoreView(requireContext()) adapter.addFooterView { ViewLoadMoreBinding.bind(loadMoreView) } - refreshRecyclerView.onRefreshStart = { - activityViewModel.rssSource?.let { - viewModel.loadContent(it) - } + refreshLayout.setOnRefreshListener { + loadArticles() } - refreshRecyclerView.recyclerView.addOnScrollListener(object : - RecyclerView.OnScrollListener() { + recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { super.onScrolled(recyclerView, dx, dy) if (!recyclerView.canScrollVertically(1)) { @@ -89,6 +87,10 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme } } }) + refreshLayout.post { + refreshLayout.isRefreshing = true + loadArticles() + } } private fun initData() { @@ -101,6 +103,12 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme } } + private fun loadArticles() { + activityViewModel.rssSource?.let { + viewModel.loadContent(it) + } + } + private fun scrollToBottom() { if (viewModel.isLoading) return if (loadMoreView.hasMore && adapter.getActualItemCount() > 0) { @@ -113,7 +121,7 @@ class RssArticlesFragment : VMBaseFragment(R.layout.fragme override fun observeLiveBus() { viewModel.loadFinally.observe(viewLifecycleOwner) { - binding.refreshRecyclerView.stopLoading() + binding.refreshLayout.isRefreshing = false if (it) { loadMoreView.startLoad() } else { diff --git a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt index 403a06d2e..e317ae734 100644 --- a/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt @@ -28,7 +28,7 @@ class RssFavoritesActivity : BaseActivity(), } private fun initView() { - binding.refreshRecyclerView.recyclerView.let { + binding.recyclerView.let { it.layoutManager = LinearLayoutManager(this) it.addItemDecoration(VerticalDivider(this)) adapter = RssFavoritesAdapter(this, this) diff --git a/app/src/main/res/layout/activity_rss_favorites.xml b/app/src/main/res/layout/activity_rss_favorites.xml index 7740c1981..098af211a 100644 --- a/app/src/main/res/layout/activity_rss_favorites.xml +++ b/app/src/main/res/layout/activity_rss_favorites.xml @@ -1,7 +1,6 @@ @@ -13,13 +12,19 @@ app:title="@string/favorites" app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintVertical_bias="0.0"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_rss_articles.xml b/app/src/main/res/layout/fragment_rss_articles.xml index 5ca0c9574..cc0266316 100644 --- a/app/src/main/res/layout/fragment_rss_articles.xml +++ b/app/src/main/res/layout/fragment_rss_articles.xml @@ -1,15 +1,12 @@ - + android:layout_height="match_parent"> - - \ No newline at end of file + \ No newline at end of file