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", "bgStr": "#FFFFFF",
"bgStrNight": "#000000", "bgStrNight": "#000000",

@ -16,6 +16,7 @@ import io.legado.app.data.entities.RssArticle
import io.legado.app.databinding.FragmentRssArticlesBinding import io.legado.app.databinding.FragmentRssArticlesBinding
import io.legado.app.databinding.ViewLoadMoreBinding import io.legado.app.databinding.ViewLoadMoreBinding
import io.legado.app.lib.theme.ATH 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.rss.read.ReadRssActivity
import io.legado.app.ui.widget.recycler.LoadMoreView import io.legado.app.ui.widget.recycler.LoadMoreView
import io.legado.app.ui.widget.recycler.VerticalDivider 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?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
viewModel.init(arguments) viewModel.init(arguments)
initView() initView()
binding.refreshRecyclerView.startLoading()
initView() initView()
initData() initData()
} }
private fun initView() = with(binding) { private fun initView() = with(binding) {
ATH.applyEdgeEffectColor(refreshRecyclerView.recyclerView) refreshLayout.setColorSchemeColors(accentColor)
refreshRecyclerView.recyclerView.layoutManager = if (activityViewModel.isGridLayout) { ATH.applyEdgeEffectColor(recyclerView)
refreshRecyclerView.recyclerView.setPadding(8, 0, 8, 0) recyclerView.layoutManager = if (activityViewModel.isGridLayout) {
recyclerView.setPadding(8, 0, 8, 0)
GridLayoutManager(requireContext(), 2) GridLayoutManager(requireContext(), 2)
} else { } else {
refreshRecyclerView.recyclerView.addItemDecoration(VerticalDivider(requireContext())) recyclerView.addItemDecoration(VerticalDivider(requireContext()))
LinearLayoutManager(requireContext()) LinearLayoutManager(requireContext())
} }
@ -70,18 +71,15 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
2 -> RssArticlesAdapter2(requireContext(), this@RssArticlesFragment) 2 -> RssArticlesAdapter2(requireContext(), this@RssArticlesFragment)
else -> RssArticlesAdapter(requireContext(), this@RssArticlesFragment) else -> RssArticlesAdapter(requireContext(), this@RssArticlesFragment)
} }
refreshRecyclerView.recyclerView.adapter = adapter recyclerView.adapter = adapter
loadMoreView = LoadMoreView(requireContext()) loadMoreView = LoadMoreView(requireContext())
adapter.addFooterView { adapter.addFooterView {
ViewLoadMoreBinding.bind(loadMoreView) ViewLoadMoreBinding.bind(loadMoreView)
} }
refreshRecyclerView.onRefreshStart = { refreshLayout.setOnRefreshListener {
activityViewModel.rssSource?.let { loadArticles()
viewModel.loadContent(it)
}
} }
refreshRecyclerView.recyclerView.addOnScrollListener(object : recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy) super.onScrolled(recyclerView, dx, dy)
if (!recyclerView.canScrollVertically(1)) { if (!recyclerView.canScrollVertically(1)) {
@ -89,6 +87,10 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
} }
} }
}) })
refreshLayout.post {
refreshLayout.isRefreshing = true
loadArticles()
}
} }
private fun initData() { 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() { private fun scrollToBottom() {
if (viewModel.isLoading) return if (viewModel.isLoading) return
if (loadMoreView.hasMore && adapter.getActualItemCount() > 0) { if (loadMoreView.hasMore && adapter.getActualItemCount() > 0) {
@ -113,7 +121,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
override fun observeLiveBus() { override fun observeLiveBus() {
viewModel.loadFinally.observe(viewLifecycleOwner) { viewModel.loadFinally.observe(viewLifecycleOwner) {
binding.refreshRecyclerView.stopLoading() binding.refreshLayout.isRefreshing = false
if (it) { if (it) {
loadMoreView.startLoad() loadMoreView.startLoad()
} else { } else {

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

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

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