pull/32/head
Invinciblelee 6 years ago
parent 09e94d8b5c
commit 6302b28f26
  1. 1
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.java
  2. 40
      app/src/main/java/io/legado/app/ui/widget/RotateLoading.kt
  3. 8
      app/src/main/res/layout/activity_search.xml
  4. 6
      app/src/main/res/layout/fragment_bookshelf.xml

@ -7,5 +7,6 @@ import org.jetbrains.annotations.NotNull;
public class ReplaceRuleViewModel extends BaseViewModel {
public ReplaceRuleViewModel(@NotNull Application application) {
super(application);
}
}

@ -9,10 +9,11 @@ import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.util.AttributeSet
import android.util.TypedValue
import android.view.View
import android.view.animation.LinearInterpolator
import androidx.core.view.isVisible
import io.legado.app.R
import io.legado.app.utils.dp
/**
* RotateLoading
@ -59,8 +60,8 @@ class RotateLoading : View {
private fun initView(context: Context, attrs: AttributeSet?) {
loadingColor = Color.WHITE
thisWidth = dpToPx(context, DEFAULT_WIDTH.toFloat())
shadowPosition = dpToPx(getContext(), DEFAULT_SHADOW_POSITION.toFloat())
thisWidth = DEFAULT_WIDTH.dp
shadowPosition = DEFAULT_SHADOW_POSITION.dp
speedOfDegree = DEFAULT_SPEED_OF_DEGREE
if (null != attrs) {
@ -68,7 +69,7 @@ class RotateLoading : View {
loadingColor = typedArray.getColor(R.styleable.RotateLoading_loading_color, Color.WHITE)
thisWidth = typedArray.getDimensionPixelSize(
R.styleable.RotateLoading_loading_width,
dpToPx(context, DEFAULT_WIDTH.toFloat())
DEFAULT_WIDTH.dp
)
shadowPosition = typedArray.getInt(R.styleable.RotateLoading_shadow_position, DEFAULT_SHADOW_POSITION)
speedOfDegree = typedArray.getInt(R.styleable.RotateLoading_loading_speed, DEFAULT_SPEED_OF_DEGREE)
@ -145,13 +146,29 @@ class RotateLoading : View {
}
}
fun start() {
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (isVisible) {
start()
}
}
override fun onVisibilityChanged(changedView: View, visibility: Int) {
super.onVisibilityChanged(changedView, visibility)
if (visibility == VISIBLE) {
start()
} else {
stop()
}
}
private fun start() {
startAnimator()
isStart = true
invalidate()
}
fun stop() {
private fun stop() {
stopAnimator()
invalidate()
}
@ -197,16 +214,11 @@ class RotateLoading : View {
animatorSet.start()
}
fun dpToPx(context: Context, dpVal: Float): Int {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpVal, context.resources.displayMetrics).toInt()
}
companion object {
private val DEFAULT_WIDTH = 6
private val DEFAULT_SHADOW_POSITION = 2
private val DEFAULT_SPEED_OF_DEGREE = 10
private const val DEFAULT_WIDTH = 6
private const val DEFAULT_SHADOW_POSITION = 2
private const val DEFAULT_SPEED_OF_DEGREE = 10
}
}

@ -1,5 +1,6 @@
<?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:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
@ -11,9 +12,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:title="搜索" />
app:title="搜索"/>
<io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
@ -23,7 +25,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"/>
</io.legado.app.ui.widget.dynamiclayout.DynamicFrameLayout>

@ -10,15 +10,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:attachToActivity="false"
app:title="@string/bookshelf" />
app:title="@string/bookshelf"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_book_group"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_bookshelf"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"/>
</LinearLayout>
Loading…
Cancel
Save