|
|
@ -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 { |
|
|
|