pull/967/head
gedoor 4 years ago
parent 243027f4d5
commit 5fbf734f89
  1. 50
      app/src/main/assets/defaultData/readConfig.json
  2. 34
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  3. 2
      app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt
  4. 15
      app/src/main/res/layout/activity_rss_favorites.xml
  5. 15
      app/src/main/res/layout/fragment_rss_articles.xml

@ -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",

@ -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<RssArticlesViewModel>(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<RssArticlesViewModel>(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<RssArticlesViewModel>(R.layout.fragme
}
}
})
refreshLayout.post {
refreshLayout.isRefreshing = true
loadArticles()
}
}
private fun initData() {
@ -101,6 +103,12 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(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<RssArticlesViewModel>(R.layout.fragme
override fun observeLiveBus() {
viewModel.loadFinally.observe(viewLifecycleOwner) {
binding.refreshRecyclerView.stopLoading()
binding.refreshLayout.isRefreshing = false
if (it) {
loadMoreView.startLoad()
} else {

@ -28,7 +28,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
}
private fun initView() {
binding.refreshRecyclerView.recyclerView.let {
binding.recyclerView.let {
it.layoutManager = LinearLayoutManager(this)
it.addItemDecoration(VerticalDivider(this))
adapter = RssFavoritesAdapter(this, this)

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@ -13,13 +12,19 @@
app:title="@string/favorites"
app:layout_constraintTop_toTopOf="parent" />
<io.legado.app.ui.widget.recycler.RefreshRecyclerView
android:id="@+id/refresh_recycler_view"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_bar"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="0dp" />
app:layout_constraintVertical_bias="0.0">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -1,15 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/content_view"
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/title_bar">
android:layout_height="match_parent">
<io.legado.app.ui.widget.recycler.RefreshRecyclerView
android:id="@+id/refresh_recycler_view"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
Loading…
Cancel
Save