opt
This commit is contained in:
@@ -32,8 +32,8 @@ import com.mogo.utils.UiThreadHandler
|
||||
import com.mogo.utils.glide.GlideApp
|
||||
|
||||
class FloatView constructor(
|
||||
private val pushViewModel: PushViewModel,
|
||||
private val context: Context
|
||||
private val pushViewModel: PushViewModel,
|
||||
private val context: Context
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@@ -50,7 +50,7 @@ class FloatView constructor(
|
||||
}
|
||||
|
||||
open abstract inner class PushView(context: Context) : FrameLayout(context),
|
||||
PushViewController {
|
||||
PushViewController {
|
||||
lateinit var appIcon: ImageView
|
||||
lateinit var titleIconContainer: View
|
||||
lateinit var pushTitle: TextView
|
||||
@@ -103,7 +103,7 @@ class FloatView constructor(
|
||||
}
|
||||
|
||||
fun hasTextContent(bean: PushBean?): Boolean =
|
||||
bean?.content?.isNullOrEmpty()?.not() ?: false
|
||||
bean?.content?.isNullOrEmpty()?.not() ?: false
|
||||
|
||||
fun hasImgContent(bean: PushBean?): Boolean = bean?.QRCode?.isNullOrEmpty()?.not() ?: false
|
||||
|
||||
@@ -139,9 +139,9 @@ class FloatView constructor(
|
||||
pushImage.layoutParams = params
|
||||
ThreadPoolService.execute {
|
||||
val bmp = stringConverterBitmap(
|
||||
bean.QRCode,
|
||||
getQrImgWidth(),
|
||||
getQrImgHeight()
|
||||
bean.QRCode,
|
||||
getQrImgWidth(),
|
||||
getQrImgHeight()
|
||||
)
|
||||
UiThreadHandler.post {
|
||||
pushImage.setImageBitmap(bmp)
|
||||
@@ -220,6 +220,8 @@ class FloatView constructor(
|
||||
return
|
||||
}
|
||||
}
|
||||
pushViewModel.pushBean?.showTimeout = 0
|
||||
updateTimer()
|
||||
}
|
||||
|
||||
override fun onViewAdded(view: View?) {
|
||||
@@ -248,23 +250,23 @@ class FloatView constructor(
|
||||
}
|
||||
|
||||
override fun getImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width)
|
||||
|
||||
override fun getImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
|
||||
override fun getQrImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
|
||||
override fun getQrImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height)
|
||||
}
|
||||
|
||||
inner class PushViewInWindowView(context: Context) : PushView(context), View.OnTouchListener {
|
||||
|
||||
private val mContentContainer: View
|
||||
private val mWindowManager =
|
||||
context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
|
||||
|
||||
private val params = WindowManager.LayoutParams()
|
||||
|
||||
@@ -302,8 +304,8 @@ class FloatView constructor(
|
||||
mWindowManager.updateViewLayout(this, params)
|
||||
}
|
||||
translationXAnimation(
|
||||
-ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical),
|
||||
0f
|
||||
-ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical),
|
||||
0f
|
||||
) {
|
||||
if (pushViewModel.pushBean != null) {
|
||||
startClosePush()
|
||||
@@ -312,17 +314,17 @@ class FloatView constructor(
|
||||
}
|
||||
|
||||
private fun translationXAnimation(
|
||||
from: Float,
|
||||
to: Float,
|
||||
doOnEnd: (animator: Animator) -> Unit
|
||||
from: Float,
|
||||
to: Float,
|
||||
doOnEnd: (animator: Animator) -> Unit
|
||||
) {
|
||||
val transitionXAnimator: ObjectAnimator =
|
||||
ObjectAnimator.ofFloat(
|
||||
this,
|
||||
View.TRANSLATION_X,
|
||||
from,
|
||||
to
|
||||
)
|
||||
ObjectAnimator.ofFloat(
|
||||
this,
|
||||
View.TRANSLATION_X,
|
||||
from,
|
||||
to
|
||||
)
|
||||
transitionXAnimator.duration = 200
|
||||
transitionXAnimator.doOnEnd(doOnEnd)
|
||||
transitionXAnimator.start()
|
||||
@@ -333,7 +335,7 @@ class FloatView constructor(
|
||||
var paddingBottom: Int = 0
|
||||
if (pushButton.isVisible) {
|
||||
paddingBottom =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_content_paddingBottom_vertical)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_content_paddingBottom_vertical)
|
||||
}
|
||||
mContentContainer.setPadding(0, 0, 0, paddingBottom)
|
||||
}
|
||||
@@ -341,8 +343,8 @@ class FloatView constructor(
|
||||
override fun hide() {
|
||||
super.hide()
|
||||
translationXAnimation(
|
||||
this.x,
|
||||
-ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical)
|
||||
this.x,
|
||||
-ResourcesHelper.getDimension(context, R.dimen.module_push_ui_width_vertical)
|
||||
) {
|
||||
Logger.d(TAG, "here")
|
||||
this.x = 0f
|
||||
@@ -413,16 +415,16 @@ class FloatView constructor(
|
||||
}
|
||||
|
||||
override fun getImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width_vertical)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_width_vertical)
|
||||
|
||||
override fun getImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height_vertical)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_ui_image_height_vertical)
|
||||
|
||||
override fun getQrImgWidth(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
|
||||
override fun getQrImgHeight(): Int =
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
context.resources.getDimensionPixelSize(R.dimen.module_push_image_qr_size_vertical)
|
||||
}
|
||||
|
||||
private val delayClosePush: Runnable
|
||||
@@ -524,8 +526,8 @@ class FloatView constructor(
|
||||
private fun startClosePush() {
|
||||
uiHandler.removeCallbacks(delayClosePush)
|
||||
uiHandler.postDelayed(
|
||||
delayClosePush,
|
||||
1000L
|
||||
delayClosePush,
|
||||
1000L
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user