[6.6.0]
[手动刷新]
This commit is contained in:
@@ -13,4 +13,6 @@ public interface IBusLinesCallback {
|
||||
void onBusLinesChange(List<BusQueryLinesResponse.Result> data);
|
||||
void onChangeLineIdSuccess();
|
||||
void onBusLineTasks(List<BusQueryLineTaskResponse.Result> o, int position,boolean autoRefresh);
|
||||
|
||||
void onRefreshSuccess(long currentTimeStamp);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
@@ -17,7 +18,9 @@ import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils
|
||||
import com.mogo.och.data.bean.BusStationBean
|
||||
import com.mogo.och.shuttle.weaknet.R
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.bean.BusRoutesResponse
|
||||
@@ -55,7 +58,7 @@ object BusLineModel {
|
||||
private const val executableChangeMd5 = "EXECUTABLECHANGEMD5"
|
||||
|
||||
// 展示上一次刷新时间
|
||||
private const val executableChangeTime = "executablechangetime"
|
||||
const val executableChangeTime = "executablechangetime"
|
||||
|
||||
var currentTask: TaskDataBean?=null
|
||||
|
||||
@@ -71,7 +74,7 @@ object BusLineModel {
|
||||
EventModel.load()
|
||||
BizLoopManager.setLoopFunction(
|
||||
"${TAG}_${LoopCarInfo}",
|
||||
LoopInfo(60, ::queryCarExecutableTaskList, immediately = true)
|
||||
LoopInfo(60, ::backRefreshTask, immediately = true)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -88,10 +91,18 @@ object BusLineModel {
|
||||
mBusLinesCallback = callback
|
||||
}
|
||||
|
||||
fun refreshTask() {
|
||||
queryCarExecutableTaskList(true)
|
||||
}
|
||||
|
||||
fun backRefreshTask(){
|
||||
queryCarExecutableTaskList(false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步基础信息
|
||||
*/
|
||||
private fun queryCarExecutableTaskList() {
|
||||
private fun queryCarExecutableTaskList(showError:Boolean) {
|
||||
mContext?.let {
|
||||
OrderServiceManager.queryCarExecutableTaskList(
|
||||
it,
|
||||
@@ -106,8 +117,11 @@ object BusLineModel {
|
||||
|
||||
SharedPrefsMgr.getInstance().putLong(executableChangeTime, currentTimeStamp)
|
||||
val sameDay = DateTimeUtil.isSameDay(currentTimeStamp, lastUpdateTime)
|
||||
if (currentRequest == lastChangeMd5 && sameDay) {
|
||||
return
|
||||
mBusLinesCallback?.onRefreshSuccess(currentTimeStamp)
|
||||
if(!showError){
|
||||
if (currentRequest == lastChangeMd5 && sameDay) {
|
||||
return
|
||||
}
|
||||
}
|
||||
SharedPrefsMgr.getInstance().putString(executableChangeMd5, currentRequest)
|
||||
OchChainLogManager.writeChainLog(
|
||||
@@ -118,11 +132,24 @@ object BusLineModel {
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
if(showError){
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort(ResourcesUtils.getString(R.string.network_error_tip));
|
||||
} else {
|
||||
ToastUtils.showShort(ResourcesUtils.getString(R.string.request_error_tip));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, failMsg: String) {
|
||||
|
||||
if(showError){
|
||||
if (!NetworkUtils.isConnected(mContext)) {
|
||||
ToastUtils.showShort("网络异常,请稍后重试");
|
||||
}else {
|
||||
ToastUtils.showShort(failMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -368,5 +395,4 @@ object BusLineModel {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package com.mogo.och.weaknet.presenter
|
||||
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.callback.IBusLinesCallback
|
||||
import com.mogo.och.weaknet.model.BusLineModel
|
||||
import com.mogo.och.weaknet.model.BusLineModel.executableChangeTime
|
||||
import com.mogo.och.weaknet.model.BusLineModel.queryBusLineTasksById
|
||||
import com.mogo.och.weaknet.model.BusLineModel.setBusLinesCallback
|
||||
import com.mogo.och.weaknet.model.OrderModel
|
||||
@@ -32,6 +35,11 @@ class BusLinePresenter(view: BusSwitchLineView?) : Presenter<BusSwitchLineView?>
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
initListener()
|
||||
initData()
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
BusLineModel.refreshTask()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
@@ -93,8 +101,21 @@ class BusLinePresenter(view: BusSwitchLineView?) : Presenter<BusSwitchLineView?>
|
||||
position: Int,
|
||||
autoRefresh: Boolean
|
||||
) {
|
||||
if (mView != null) {
|
||||
mView!!.onBusLineTasks(o, position, autoRefresh)
|
||||
mView?.onBusLineTasks(o, position, autoRefresh)
|
||||
}
|
||||
|
||||
override fun onRefreshSuccess(currentTimeStamp: Long) {
|
||||
mView?.refreshDate(DateTimeUtil.formatLongToString(currentTimeStamp,DateTimeUtil.yyyy_MM_dd_HH_mm_ss))
|
||||
}
|
||||
|
||||
fun refreshTask() {
|
||||
BusLineModel.refreshTask()
|
||||
}
|
||||
|
||||
fun setRefreshTime() {
|
||||
val lastUpdateTime = SharedPrefsMgr.getInstance().getLong(executableChangeTime, -1)
|
||||
if(lastUpdateTime>0){
|
||||
onRefreshSuccess(lastUpdateTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.och.weaknet.ui
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.graphics.Point
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
@@ -13,15 +16,20 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.commons.mvp.MvpActivity
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.och.weaknet.presenter.BusLinePresenter
|
||||
import com.mogo.och.weaknet.ui.adapter.SwitchLineAdapter
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.ui.adapter.OpenItemAnimator
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.view.SpacesItemDecoration
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.utils.ResourcesUtils
|
||||
import com.mogo.och.shuttle.weaknet.R
|
||||
import java.util.ArrayList
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse
|
||||
import com.mogo.och.weaknet.presenter.BusLinePresenter
|
||||
import com.mogo.och.weaknet.ui.adapter.OpenItemAnimator
|
||||
import com.mogo.och.weaknet.ui.adapter.SwitchLineAdapter
|
||||
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.aciv_refresh_task
|
||||
import kotlinx.android.synthetic.main.shuttle_weak_switch_line.actv_last_refresh_date
|
||||
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -41,6 +49,8 @@ class BusSwitchLineActivity : MvpActivity<BusSwitchLineView?, BusLinePresenter?>
|
||||
private lateinit var mAdapter: SwitchLineAdapter
|
||||
private lateinit var linearLayoutManager:LinearLayoutManager
|
||||
private val mData: MutableList<BusQueryLinesResponse.Result> = ArrayList()
|
||||
private var animator:ObjectAnimator?=null
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.shuttle_weak_switch_line
|
||||
}
|
||||
@@ -85,6 +95,17 @@ class BusSwitchLineActivity : MvpActivity<BusSwitchLineView?, BusLinePresenter?>
|
||||
mPresenter?.queryBusLineTasks(mData[position].lineId, position, close)
|
||||
}
|
||||
})
|
||||
aciv_refresh_task.onClick {
|
||||
mPresenter?.refreshTask()
|
||||
if(animator==null) {
|
||||
animator = ObjectAnimator.ofFloat(aciv_refresh_task, "rotation", 0f, 360f)
|
||||
animator?.setDuration(1000) // 设置动画持续时间
|
||||
animator?.repeatCount = ValueAnimator.INFINITE // 设置动画无限重复
|
||||
animator?.repeatMode = ValueAnimator.RESTART // 设置重复模式
|
||||
}
|
||||
animator?.start()
|
||||
}
|
||||
mPresenter?.setRefreshTime()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,6 +203,16 @@ class BusSwitchLineActivity : MvpActivity<BusSwitchLineView?, BusLinePresenter?>
|
||||
}
|
||||
}
|
||||
|
||||
override fun refreshDate(formatLongToString: String?) {
|
||||
UiThreadHandler.post({
|
||||
formatLongToString?.let {
|
||||
actv_last_refresh_date.text = ResourcesUtils.getString(R.string.bus_refresh_time,it)
|
||||
animator?.cancel()
|
||||
}
|
||||
},UiThreadHandler.MODE.QUEUE)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 有无数据UI显示
|
||||
* @param b
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.mogo.commons.mvp.IView;
|
||||
import com.mogo.och.weaknet.bean.BusQueryLineTaskResponse;
|
||||
import com.mogo.och.weaknet.bean.BusQueryLinesResponse;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -16,5 +18,7 @@ public interface BusSwitchLineView extends IView {
|
||||
void onChangeLineIdSuccess();
|
||||
|
||||
void onBusLineTasks(List<BusQueryLineTaskResponse.Result> o, int position,boolean autoRefresh);
|
||||
|
||||
void refreshDate(@Nullable String formatLongToString);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
@@ -20,7 +20,7 @@
|
||||
android:id="@+id/bus_lint_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/bus_switch_line_title"
|
||||
android:textSize="@dimen/dp_42"
|
||||
android:layout_marginLeft="@dimen/dp_113"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@@ -28,6 +28,16 @@
|
||||
android:textColor="@android:color/white"
|
||||
android:text="@string/bus_switch_line_title"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/aciv_refresh_task"
|
||||
app:layout_constraintTop_toTopOf="@+id/bus_lint_title"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/bus_lint_title"
|
||||
app:layout_constraintStart_toEndOf="@+id/bus_lint_title"
|
||||
android:layout_marginStart="@dimen/dp_30"
|
||||
android:src="@drawable/shuttle_refresh_task"
|
||||
android:layout_width="@dimen/dp_59"
|
||||
android:layout_height="@dimen/dp_60"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/switch_line_close"
|
||||
android:layout_width="@dimen/dp_107"
|
||||
@@ -38,12 +48,23 @@
|
||||
android:layout_marginRight="@dimen/dp_40"
|
||||
android:src="@drawable/bus_switch_line_close"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/actv_last_refresh_date"
|
||||
android:textColor="@color/shuttle_driver_D4D4D4"
|
||||
android:textSize="@dimen/dp_34"
|
||||
app:layout_constraintStart_toStartOf="@+id/bus_lint_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/bus_lint_title"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
tools:text="更新时间:2024-07-10 15:00:00"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/switch_line_rv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_0"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/switch_line_1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/switch_line_1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/actv_last_refresh_date"
|
||||
app:layout_constraintBottom_toTopOf="@+id/switch_line_btn_commit"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:layout_marginBottom="@dimen/dp_30"/>
|
||||
|
||||
@@ -60,4 +60,5 @@
|
||||
<color name="shuttle_driver_cad6ff">#CAD6FF</color>
|
||||
<color name="shuttle_driver_bf0e3dbc">#BF0E3DBC</color>
|
||||
<color name="shuttle_driver_bf1e2e89">#BF1E2E89</color>
|
||||
<color name="shuttle_driver_D4D4D4">#D4D4D4</color>
|
||||
</resources>
|
||||
@@ -33,6 +33,8 @@
|
||||
<string name="bus_station_txt_tag_end">终</string>
|
||||
<string name="bus_line_time_tag">班次:</string>
|
||||
|
||||
<string name="bus_refresh_time">更新时间:%1$s</string>
|
||||
|
||||
<string name="bus_dialog_title">提示</string>
|
||||
<string name="bus_dialog_tips">您确认要结束任务吗?</string>
|
||||
<string name="bus_dialog_confirm">确认</string>
|
||||
|
||||
Reference in New Issue
Block a user