pull/967/head
gedoor 4 years ago
parent d6564f30ed
commit cbc30f1584
  1. 4
      app/src/main/assets/updateLog.md
  2. 92
      app/src/main/java/io/legado/app/ui/widget/recycler/RefreshRecyclerView.kt
  3. 109
      app/src/main/java/io/legado/app/ui/widget/recycler/SwipeRefreshLayout.kt

@ -3,9 +3,11 @@
* 关注合作公众号 **[小说拾遗]** 获取好看的小说。
* 旧版数据导入教程:先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】。
**2021/04/18**
**2021/04/29**
* epub插图,epublib优化,图片解码优化,epub读取导出优化。by ag2s20150909
* 添加高刷设置
* 其它一些优化
* pro版本被play商店下架了,先把pro设置图片背景的功能开放到所有版本,使用pro版本的可以使用备份恢复功能切换最新版本
**2021/04/16**
* 去掉google统计,解决华为手机使用崩溃的bug

@ -1,92 +0,0 @@
package io.legado.app.ui.widget.recycler
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.databinding.ViewRefreshRecyclerBinding
import io.legado.app.lib.theme.ATH
@SuppressLint("ClickableViewAccessibility")
class RefreshRecyclerView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {
private var binding: ViewRefreshRecyclerBinding
private var durTouchX = -1000000f
private var durTouchY = -1000000f
var onRefreshStart: (() -> Unit)? = null
init {
orientation = VERTICAL
val view = LayoutInflater.from(context).inflate(R.layout.view_refresh_recycler, this, true)
binding = ViewRefreshRecyclerBinding.bind(view)
ATH.applyEdgeEffectColor(binding.recyclerView)
binding.recyclerView.setOnTouchListener(object : OnTouchListener {
@SuppressLint("ClickableViewAccessibility")
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
durTouchX = event.x
durTouchY = event.y
}
MotionEvent.ACTION_MOVE -> {
if (durTouchX == -1000000f) {
durTouchX = event.x
}
if (durTouchY == -1000000f)
durTouchY = event.y
val dY = event.y - durTouchY //>0下拉
durTouchY = event.y
if (!binding.refreshProgressBar.isAutoLoading &&
binding.refreshProgressBar.getSecondDurProgress() == binding.refreshProgressBar.secondFinalProgress
) {
binding.recyclerView.adapter?.let {
if (it.itemCount > 0) {
if (0 == (binding.recyclerView.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()) {
binding.refreshProgressBar.setSecondDurProgress((binding.refreshProgressBar.getSecondDurProgress() + dY / 2).toInt())
}
} else {
binding.refreshProgressBar.setSecondDurProgress((binding.refreshProgressBar.getSecondDurProgress() + dY / 2).toInt())
}
}
return binding.refreshProgressBar.getSecondDurProgress() > 0
}
}
MotionEvent.ACTION_UP -> {
if (!binding.refreshProgressBar.isAutoLoading &&
binding.refreshProgressBar.secondMaxProgress > 0 &&
binding.refreshProgressBar.getSecondDurProgress() > 0
) {
if (binding.refreshProgressBar.getSecondDurProgress() >= binding.refreshProgressBar.secondMaxProgress) {
binding.refreshProgressBar.isAutoLoading = true
onRefreshStart?.invoke()
} else {
binding.refreshProgressBar.setSecondDurProgressWithAnim(0)
}
}
durTouchX = -1000000f
durTouchY = -1000000f
}
}
return false
}
})
}
val recyclerView get() = binding.recyclerView
fun startLoading() {
binding.refreshProgressBar.isAutoLoading = true
onRefreshStart?.invoke()
}
fun stopLoading() {
binding.refreshProgressBar.isAutoLoading = false
}
}

@ -1,109 +0,0 @@
package io.legado.app.ui.widget.recycler
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import androidx.core.view.*
class SwipeRefreshLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : ViewGroup(context, attrs), NestedScrollingParent3,
NestedScrollingParent2, NestedScrollingChild3, NestedScrollingChild2, NestedScrollingParent,
NestedScrollingChild {
init {
}
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
TODO("Not yet implemented")
}
override fun startNestedScroll(axes: Int, type: Int): Boolean {
TODO("Not yet implemented")
}
override fun stopNestedScroll(type: Int) {
TODO("Not yet implemented")
}
override fun hasNestedScrollingParent(type: Int): Boolean {
TODO("Not yet implemented")
}
override fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?,
type: Int
): Boolean {
TODO("Not yet implemented")
}
override fun dispatchNestedPreScroll(
dx: Int,
dy: Int,
consumed: IntArray?,
offsetInWindow: IntArray?,
type: Int
): Boolean {
TODO("Not yet implemented")
}
override fun dispatchNestedScroll(
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
offsetInWindow: IntArray?,
type: Int,
consumed: IntArray
) {
TODO("Not yet implemented")
}
override fun onStartNestedScroll(child: View, target: View, axes: Int, type: Int): Boolean {
TODO("Not yet implemented")
}
override fun onNestedScrollAccepted(child: View, target: View, axes: Int, type: Int) {
TODO("Not yet implemented")
}
override fun onStopNestedScroll(target: View, type: Int) {
TODO("Not yet implemented")
}
override fun onNestedScroll(
target: View,
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
type: Int
) {
TODO("Not yet implemented")
}
override fun onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray, type: Int) {
TODO("Not yet implemented")
}
override fun onNestedScroll(
target: View,
dxConsumed: Int,
dyConsumed: Int,
dxUnconsumed: Int,
dyUnconsumed: Int,
type: Int,
consumed: IntArray
) {
TODO("Not yet implemented")
}
}
Loading…
Cancel
Save