pull/43/head
kunfei 5 years ago
parent 43888434d5
commit 18929ae2d0
  1. 2
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  2. 17
      app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt
  3. 1
      app/src/main/res/layout/item_find_book.xml
  4. 1
      app/src/main/res/layout/view_load_more.xml
  5. 6
      app/src/main/res/values/attrs.xml

@ -92,7 +92,7 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
} }
} else { } else {
iv_status.setImageResource(R.drawable.ic_add) iv_status.setImageResource(R.drawable.ic_add)
rotate_loading.hide() rotate_loading.hide(View.GONE)
gl_child.gone() gl_child.gone()
} }
} }

@ -34,6 +34,8 @@ class RotateLoading : View {
private var shadowPosition: Int = 0 private var shadowPosition: Int = 0
var hideMode = GONE
var isStarted = false var isStarted = false
private set private set
@ -49,7 +51,7 @@ class RotateLoading : View {
private val shown = Runnable { this.startInternal() } private val shown = Runnable { this.startInternal() }
private val hidden = Runnable { this.stopInternal(GONE) } private val hidden = Runnable { this.stopInternal() }
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
initView(context, null) initView(context, null)
@ -78,6 +80,7 @@ class RotateLoading : View {
) )
shadowPosition = typedArray.getInt(R.styleable.RotateLoading_shadow_position, DEFAULT_SHADOW_POSITION) shadowPosition = typedArray.getInt(R.styleable.RotateLoading_shadow_position, DEFAULT_SHADOW_POSITION)
speedOfDegree = typedArray.getInt(R.styleable.RotateLoading_loading_speed, DEFAULT_SPEED_OF_DEGREE) speedOfDegree = typedArray.getInt(R.styleable.RotateLoading_loading_speed, DEFAULT_SPEED_OF_DEGREE)
hideMode = typedArray.getInt(R.styleable.RotateLoading_hide_mode, GONE)
typedArray.recycle() typedArray.recycle()
} }
speedOfArc = (speedOfDegree / 4).toFloat() speedOfArc = (speedOfDegree / 4).toFloat()
@ -176,10 +179,10 @@ class RotateLoading : View {
post(shown) post(shown)
} }
fun hide(visibility: Int = INVISIBLE) { fun hide() {
removeCallbacks(shown) removeCallbacks(shown)
removeCallbacks(hidden) removeCallbacks(hidden)
stopInternal(visibility) stopInternal()
} }
private fun startInternal() { private fun startInternal() {
@ -188,8 +191,8 @@ class RotateLoading : View {
invalidate() invalidate()
} }
private fun stopInternal(visibility: Int = INVISIBLE) { private fun stopInternal() {
stopAnimator(visibility) stopAnimator()
invalidate() invalidate()
} }
@ -205,10 +208,10 @@ class RotateLoading : View {
.start() .start()
} }
private fun stopAnimator(visibility: Int = INVISIBLE) { private fun stopAnimator() {
animate().cancel() animate().cancel()
isStarted = false isStarted = false
this.visibility = visibility this.visibility = hideMode
} }
companion object { companion object {

@ -64,6 +64,7 @@
android:layout_height="36dp" android:layout_height="36dp"
android:visibility="gone" android:visibility="gone"
android:layout_gravity="center" android:layout_gravity="center"
app:hide_mode="gone"
app:loading_width="2dp" /> app:loading_width="2dp" />
</FrameLayout> </FrameLayout>

@ -12,6 +12,7 @@
android:layout_margin="6dp" android:layout_margin="6dp"
android:layout_gravity="center" android:layout_gravity="center"
android:visibility="invisible" android:visibility="invisible"
app:hide_mode="invisible"
app:loading_width="2dp" /> app:loading_width="2dp" />
<TextView <TextView

@ -113,6 +113,12 @@
<attr name="loading_color" format="color"/> <attr name="loading_color" format="color"/>
<attr name="shadow_position" format="integer"/> <attr name="shadow_position" format="integer"/>
<attr name="loading_speed" format="integer"/> <attr name="loading_speed" format="integer"/>
<attr name="hide_mode">
<!-- Not displayed, but taken into account during layout (space is left for it). -->
<enum name="invisible" value="1" />
<!-- Completely hidden, as if the view had not been added. -->
<enum name="gone" value="2" />
</attr>
</declare-styleable> </declare-styleable>
<declare-styleable name="CircleImageView"> <declare-styleable name="CircleImageView">

Loading…
Cancel
Save