bug修改 - 视频主界面的那个红包进度条,如果在进度条没有满的时候点击红包的话,可以加一个tips
This commit is contained in:
parent
b010c1e4d2
commit
5d217d025b
|
|
@ -10,6 +10,7 @@ import android.view.LayoutInflater
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.ama.core.architecture.util.AndroidUtil
|
import com.ama.core.architecture.util.AndroidUtil
|
||||||
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.vididin.real.money.game.R
|
import com.vididin.real.money.game.R
|
||||||
import com.vididin.real.money.game.databinding.LayoutDragIconViewBinding
|
import com.vididin.real.money.game.databinding.LayoutDragIconViewBinding
|
||||||
|
|
||||||
|
|
@ -24,9 +25,11 @@ class HomeDragIconView @JvmOverloads constructor(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true)
|
mBinding = LayoutDragIconViewBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
mBinding.progressContainer.setOnClickListener {
|
|
||||||
|
mBinding.dragLayout.setClickedCallback{
|
||||||
AndroidUtil.showTopToast(R.string.gold_not_ready_hint)
|
AndroidUtil.showTopToast(R.string.gold_not_ready_hint)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<com.ama.core.common.widget.DragLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<com.ama.core.common.widget.DragLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/drag_layout"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
|
@ -46,7 +47,8 @@
|
||||||
android:id="@+id/progress_container"
|
android:id="@+id/progress_container"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:focusable="true">
|
||||||
<com.ama.core.architecture.widget.CircleProgressBar
|
<com.ama.core.architecture.widget.CircleProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ class DragLayout @JvmOverloads constructor(
|
||||||
private var lastTouchX = 0f
|
private var lastTouchX = 0f
|
||||||
private var lastTouchY = 0f
|
private var lastTouchY = 0f
|
||||||
|
|
||||||
|
private var startTouchX = 0f
|
||||||
|
private var startTouchY = 0f
|
||||||
|
|
||||||
|
private var onClicked: (()->Unit)? = null
|
||||||
|
|
||||||
|
|
||||||
var onDragStart: ((View) -> Unit)? = null
|
var onDragStart: ((View) -> Unit)? = null
|
||||||
var onDragEnd: ((View) -> Unit)? = null
|
var onDragEnd: ((View) -> Unit)? = null
|
||||||
|
|
@ -65,22 +70,27 @@ class DragLayout @JvmOverloads constructor(
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setClickedCallback(onClicked: ()->Unit) {
|
||||||
|
this.onClicked = onClicked
|
||||||
|
}
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
if (draggedView == null) return false
|
if (draggedView == null) return false
|
||||||
|
|
||||||
when (event.action and MotionEvent.ACTION_MASK) {
|
when (event.action and MotionEvent.ACTION_MASK) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
startTouchX = event.x
|
||||||
|
startTouchY = event.y
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
if (!isDragging) {
|
if (!isDragging && (Math.abs((event.x - startTouchX)) > 5f || Math.abs((event.y - startTouchY)) > 5f)) {
|
||||||
startDrag()
|
startDrag()
|
||||||
}
|
}
|
||||||
|
|
||||||
val dx = event.x - lastTouchX
|
val dx = event.x - lastTouchX
|
||||||
val dy = event.y - lastTouchY
|
val dy = event.y - lastTouchY
|
||||||
|
|
||||||
updateViewPosition(dx, dy)
|
updateViewPosition(dx, dy)
|
||||||
lastTouchX = event.x
|
lastTouchX = event.x
|
||||||
lastTouchY = event.y
|
lastTouchY = event.y
|
||||||
|
|
@ -88,6 +98,10 @@ class DragLayout @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||||
|
if (!isDragging) {
|
||||||
|
onClicked?.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
endDrag()
|
endDrag()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue