pull/37/head
kunfei 5 years ago
parent c799f37dab
commit b9953c2e87
  1. 22
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt
  2. 29
      app/src/main/res/layout/view_load_more.xml

@ -2,15 +2,14 @@ package io.legado.app.ui.rss.article
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.view.View
import android.util.Log
import android.view.*
import androidx.core.content.ContextCompat
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.App
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -73,6 +72,7 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
return super.onCompatOptionsItemSelected(item)
}
@SuppressLint("InflateParams")
private fun initView() {
ATH.applyEdgeEffectColor(recycler_view)
recycler_view.layoutManager = LinearLayoutManager(this)
@ -84,6 +84,8 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
})
adapter = RssArticlesAdapter(this, this)
recycler_view.adapter = adapter
val loadMoreView = LayoutInflater.from(this).inflate(R.layout.view_load_more, null)
adapter?.addFooterView(loadMoreView)
refresh_progress_bar.isAutoLoading = true
recycler_view.setOnTouchListener(object : View.OnTouchListener {
@SuppressLint("ClickableViewAccessibility")
@ -135,6 +137,14 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
return false
}
})
recycler_view.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
if (!recyclerView.canScrollVertically(1)) {
scrollToBottom()
}
}
})
}
private fun initData(origin: String) {
@ -145,6 +155,10 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
})
}
private fun scrollToBottom() {
Log.d("xxxxxx", "scrollToBottom")
}
override fun readRss(rssArticle: RssArticle) {
viewModel.read(rssArticle)
startActivity<ReadRssActivity>(

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<io.legado.app.ui.widget.anima.RotateLoading
android:id="@+id/rotate_loading"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_margin="6dp"
android:visibility="gone"
app:loading_width="2dp" />
<TextView
android:id="@+id/tv_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
android:gravity="center"
android:background="?attr/selectableItemBackground"
android:visibility="invisible"
tools:text="加载状态"
tools:visibility="visible" />
</FrameLayout>
Loading…
Cancel
Save