[fea]
[slide 抽离]
This commit is contained in:
yangyakun
2024-10-11 14:34:47 +08:00
parent 6dd6f25dd1
commit e9906b913b
17 changed files with 204 additions and 168 deletions

View File

@@ -74,6 +74,7 @@ dependencies {
api rootProject.ext.dependencies.flexbox
api project(":OCH:common:data")
api rootProject.ext.dependencies.lottie
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
api rootProject.ext.dependencies.mogocommons

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,159 @@
package com.mogo.och.common.module.wigets
import android.animation.ObjectAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatTextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.common.module.R
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.utils.RxUtils
import kotlinx.android.synthetic.main.common_slide_view.view.lottie_bg
class CommonSlideView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
companion object {
const val TAG = "LoadingMapStatusView"
}
private var initialX = 0f
private var initialY = 0f
private val tempSet = ConstraintSet()
private var draggableButton: AppCompatTextView
private var slideListener:SlideListener?=null
private var slideTitle:String?=null
private var assetsfolder:String?=null
fun setSlideListener(slideListener:SlideListener){
this.slideListener = slideListener
}
init {
LayoutInflater.from(context).inflate(R.layout.common_slide_view, this, true)
try {
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommonSlideView)
slideTitle = typedArray.getString(R.styleable.CommonSlideView_slide_title)?:""
assetsfolder = typedArray.getString(R.styleable.CommonSlideView_assetsfolder)?:"images"
typedArray.recycle()
} catch (e: Exception) {
e.printStackTrace()
}
draggableButton = findViewById(R.id.actv_draggable_block)
draggableButton.text = slideTitle
lottie_bg.imageAssetsFolder = assetsfolder
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerLogger.d(TAG,"onAttachedToWindow")
}
/**
* 为该组件的触碰事件重写事件处理方法
*/
override fun onTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
initialX = event.rawX;
initialY = event.rawY;
}
MotionEvent.ACTION_MOVE -> {
val dx = event.rawX - initialX;
val dy = event.rawY - initialY;
initialX = event.rawX;
initialY = event.rawY;
if(draggableButton.translationX<0){
tempSet.clone(this)
tempSet.setTranslationX(draggableButton.id, 0f)
tempSet.applyTo(this)
}else if(draggableButton.translationX>=0&&draggableButton.translationX<=width-draggableButton.width){
tempSet.clone(this)
val dex = (draggableButton.translationX + dx).takeIf { it>=0 }?:0f
val newDex = dex.takeIf { it<=width-draggableButton.width }?:(width-draggableButton.width).toFloat()
tempSet.setTranslationX(draggableButton.id, newDex)
tempSet.applyTo(this)
}else{
tempSet.clone(this)
val dex = (draggableButton.translationX + dx).takeIf { it<=width-draggableButton.width }?:(width-draggableButton.width).toFloat()
tempSet.setTranslationX(draggableButton.id, dex)
tempSet.applyTo(this)
}
}
MotionEvent.ACTION_UP -> {
if(draggableButton.translationX<(width-draggableButton.width)){
ObjectAnimator.ofFloat(
draggableButton, "translationX", draggableButton.translationX,
0f
).apply {
duration = 100
}.start()
}else if (draggableButton.translationX>=(width-draggableButton.width)){
lottie_bg.setAnimation("data.json")
lottie_bg.playAnimation()
draggableButton.setTextColor(ResourcesUtils.getColor(R.color.common_80FFFFFF))
RxUtils.createSubscribe(1_000) {
slideListener?.slideEnd()
}
}else{
ObjectAnimator.ofFloat(
draggableButton, "translationX", draggableButton.translationX,
0f
).apply {
duration = 100
}.start()
}
}
else -> {}
}
return true
}
override fun onVisibilityAggregated(isVisible: Boolean) {
super.onVisibilityAggregated(isVisible)
if(isVisible){
lottie_bg.setAnimation("slide.json")
lottie_bg.playAnimation()
draggableButton.setTextColor(ResourcesUtils.getColor(R.color.white))
ObjectAnimator.ofFloat(
draggableButton, "translationX", draggableButton.translationX,
0f
).apply {
duration = 100
}.start()
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerLogger.d(TAG,"onDetachedFromWindow")
}
fun setTextValue(value: String) {
draggableButton.text = value
}
interface SlideListener{
fun slideEnd()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_loaing_view"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_bg"
android:layout_width="774px"
android:layout_height="120px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_fileName="slide.json"
app:lottie_loop="true"
app:lottie_autoPlay="true"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_draggable_block"
tools:text="滑动出发"
android:textColor="@color/white"
android:gravity="center"
android:background="@drawable/common_slide_block"
app:layout_constraintTop_toTopOf="@+id/aciv_task_leave_station_slide_bg"
app:layout_constraintBottom_toBottomOf="@+id/aciv_task_leave_station_slide_bg"
app:layout_constraintStart_toStartOf="@+id/aciv_task_leave_station_slide_bg"
android:textSize="@dimen/dp_40"
android:layout_width="@dimen/dp_300"
android:layout_height="@dimen/dp_120"/>
</merge>

View File

@@ -9,6 +9,12 @@
<attr name="och_image_left_bottom_radius" format="dimension" />
</declare-styleable>
<declare-styleable name="CommonSlideView">
<attr name="slide_title" format="string" />
<attr name="assetsfolder" format="string" />
</declare-styleable>
<!--阴影布局 -->
<declare-styleable name="ShadowLayout">
<!-- 阴影颜色-->

View File

@@ -16,6 +16,7 @@
<color name="qr_bg_color">#3B4577</color>
<color name="common_80000000">#80000000</color>
<color name="common_80FFFFFF">#80FFFFFF</color>
<color name="common_1466FB">#1466FB</color>
<color name="common_e0efff">#E0EFFF</color>
<color name="common_b8c2d7">#B8C2D7</color>

View File

@@ -61,7 +61,6 @@ dependencies {
implementation rootProject.ext.dependencies.roomRxjava
implementation rootProject.ext.dependencies.androidxrecyclerview
kapt rootProject.ext.dependencies.recyclerviewadapterhelper
implementation rootProject.ext.dependencies.lottie
implementation rootProject.ext.dependencies.androidxroomruntime
kapt rootProject.ext.dependencies.androidxroomcompiler

View File

@@ -10,15 +10,13 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.mogo.commons.AbsMogoApplication
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.view.SpacesItemDecoration
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.utils.ResourcesUtils
import com.mogo.och.common.module.wigets.CommonDialogStatus
import com.mogo.och.common.module.wigets.OCHCommitDialog
import com.mogo.och.common.module.wigets.CommonSlideView
import com.mogo.och.shuttle.weaknet.R
import com.mogo.och.weaknet.model.LineModel
import com.mogo.och.weaknet.ui.bizswitch.SwtichBizeModel
import com.mogo.och.weaknet.view.BizLeaveStationView.SlideListener
import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.aciv_task_leave_station_slide_bg
import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_arriver_station
import kotlinx.android.synthetic.main.shuttle_weak_task_running.view.actv_complete_task
@@ -63,7 +61,7 @@ class TaskRunningView: ConstraintLayout, TaskRunningModel.SwtichLineViewCallback
rl_running_task_station_list.setLayoutManager(linearLayoutManager)
mAdapter = TaskRunningAdapter(context, mutableListOf())
rl_running_task_station_list.setAdapter(mAdapter)
aciv_task_leave_station_slide_bg.setSlideListener(object : SlideListener{
aciv_task_leave_station_slide_bg.setSlideListener(object : CommonSlideView.SlideListener {
override fun slideEnd() {
viewModel?.leaveStation()
}

View File

@@ -1,63 +0,0 @@
package com.mogo.och.weaknet.view
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.view.MapBizView
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.map.uicontroller.IMogoMapUIController
import com.mogo.och.shuttle.weaknet.R
/**
* 魔戒蓝牙控件
* 放置于StatusBar右侧位置
*/
class BizMapView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
private lateinit var mapBizView: MapBizView
init {
if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode)) {
LayoutInflater.from(context).inflate(R.layout.shuttle_weak_m2_bizmap_map, this, true)
}else if(AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)){
LayoutInflater.from(context).inflate(R.layout.shuttle_weak_jl_bizmap_map, this, true)
}else{
LayoutInflater.from(context).inflate(R.layout.shuttle_weak_jl_bizmap_map, this, true)
}
mapBizView = findViewById(R.id.bizMapView)
}
fun getUI(): IMogoMapUIController? {
return mapBizView.getUI()
}
fun onCreate(bundle: Bundle?) {
mapBizView.onCreate(bundle)
}
fun onResume() {
mapBizView.onResume()
}
fun onSaveInstanceState(outState: Bundle){
mapBizView.onSaveInstanceState(outState)
}
fun onLowMemory() {
mapBizView.onLowMemory()
}
fun onPause() {
mapBizView.onPause()
}
fun onDestroy() {
mapBizView.onDestroy()
}
}

View File

@@ -7,15 +7,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- <androidx.appcompat.widget.AppCompatImageView-->
<!-- android:id="@+id/aciv_task_leave_station_slide_bg"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- android:src="@drawable/bus_task_leave_station_slide_bg"-->
<!-- android:layout_width="@dimen/dp_774"-->
<!-- android:layout_height="@dimen/dp_120"/>-->
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_bg"
android:layout_width="774px"

View File

@@ -57,11 +57,13 @@
android:layout_marginTop="@dimen/dp_22"
android:layout_marginBottom="@dimen/dp_46"/>
<com.mogo.och.weaknet.view.BizLeaveStationView
<com.mogo.och.common.module.wigets.CommonSlideView
android:id="@+id/aciv_task_leave_station_slide_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:assetsfolder="images"
app:slide_title="@string/bus_task_leave_station"
android:layout_marginBottom="@dimen/dp_46"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

View File

@@ -5,94 +5,4 @@
<attr name="taxi_server_title" format="string" />
</declare-styleable>
<!--阴影布局 -->
<declare-styleable name="ShadowLayout">
<!-- 阴影颜色-->
<attr name="shadowColor" format="color"/>
<!-- 圆角大小默认无圆角0-->
<attr name="shadowRadius" format="dimension"/>
<!-- 模糊半径 -->
<attr name="blurRadius" format="dimension" />
<!-- 是否有点击效果-->
<attr name="hasEffect" format="boolean"/>
<attr name="bgColor" format="color"/>
<!-- 水平位移-->
<attr name="xOffset" format="dimension"/>
<!--竖直位移 -->
<attr name="yOffset" format="dimension"/>
<!--横向修正 -->
<attr name="blurCorrectX" format="dimension"/>
<!--纵向向修正 -->
<attr name="blurCorrectY" format="dimension"/>
<!-- -->
<attr name="shadow_position" format="enum">
<enum name="normal" value="0" />
<enum name="solid" value="1" />
<enum name="outer" value="2" />
<enum name="inner" value="3" />
</attr>
</declare-styleable>
<!--CardView -->
<declare-styleable name="OCHCardViewCorner">
<attr name="och_card_left_top_radius" format="dimension" />
<attr name="och_card_right_top_radius" format="dimension" />
<attr name="och_card_right_bottom_radius" format="dimension" />
<attr name="och_card_left_bottom_radius" format="dimension" />
</declare-styleable>
<declare-styleable name="OCHRealtimeBlurView">
<attr name="och_realtime_blur_radius" format="dimension" />
<attr name="och_realtime_downsample_factor" format="float" />
<attr name="och_realtime_overlay_color" format="color" />
<attr name="och_realtime_onece" format="boolean" />
</declare-styleable>
<declare-styleable name="OCHShapeBlurView">
<attr name="och_realtime_start_color" format="color" />
<attr name="och_realtime_end_color" format="color" />
<attr name="och_realtime_radius" format="dimension" />
</declare-styleable>
<declare-styleable name="MarqueeTextView">
<attr name="customGap" format="float" />
<attr name="useCustomGap" format="boolean"/>
</declare-styleable>
<declare-styleable name="MapDirectionView">
<!-- 地图样式asset目录下的路径 -->
<attr name="mapStylePath" format="string" />
<attr name="mapStyleExtraPath" format="string" />
<!-- 自车模型图片 -->
<attr name="carDrawable" format="reference" />
<!-- 罗盘图片 -->
<attr name="compassDrawable" format="reference" />
<!-- 起点图片 -->
<attr name="startPointDrawable" format="reference" />
<!-- 终点图片 -->
<attr name="endPointDrawable" format="reference" />
<!-- 已走过路线的图片 -->
<attr name="arrivedDrawable" format="reference" />
<!-- 未走过路线的图片 -->
<attr name="unArrivedDrawable" format="reference" />
<!-- 重置位置图片右面margin -->
<attr name="resetDrawableMarginRight" format="dimension" />
<!-- 重置位置图片下面margin -->
<attr name="resetDrawableMarginBottom" format="dimension" />
<!-- 规定屏幕范围的padding -->
<attr name="leftPadding" format="integer" />
<attr name="topPadding" format="integer" />
<attr name="rightPadding" format="integer" />
<attr name="bottomPadding" format="integer" />
</declare-styleable>
<declare-styleable name="SlidePanelView">
<attr name="textSize" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="NORMAL_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_LEFT" format="dimension" />
<attr name="SHORT_TEXT_MARGIN_RIGHT" format="dimension" />
<attr name="BLOCK_START_X" format="dimension" />
<attr name="BLOCK_START_Y" format="dimension" />
</declare-styleable>
</resources>