[6.4.5]
[fea] [线路缓存]
This commit is contained in:
@@ -100,10 +100,6 @@ object LoginStatusManager : CallerBase<ILoginCallback>() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun setLoginStatus(loginStatus: LoginStatusEnum) {
|
fun setLoginStatus(loginStatus: LoginStatusEnum) {
|
||||||
if(FunctionBuildConfig.isOffLine){
|
|
||||||
loginService?.setLoginStatus(LoginStatusEnum.Login)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loginService?.setLoginStatus(loginStatus)
|
loginService?.setLoginStatus(loginStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ class FRetryWithTime<T : BaseData> : Function<T, ObservableSource<T>> {
|
|||||||
MoGoAiCloudClient.getInstance().refreshToken()
|
MoGoAiCloudClient.getInstance().refreshToken()
|
||||||
return Observable.error(OchCommonRetryException())
|
return Observable.error(OchCommonRetryException())
|
||||||
}else if(it.code == 1003){
|
}else if(it.code == 1003){
|
||||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
if(!FunctionBuildConfig.isOffLine){
|
||||||
LoginStatusManager.setLoginStatus(LoginStatusEnum.Logout)
|
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||||
|
LoginStatusManager.setLoginStatus(LoginStatusEnum.Logout)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +1,105 @@
|
|||||||
package com.mogo.och.offline.model;
|
package com.mogo.och.offline.model
|
||||||
|
|
||||||
import android.content.Context;
|
import com.mogo.commons.storage.SharedPrefsMgr
|
||||||
|
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||||
import com.mogo.commons.AbsMogoApplication;
|
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||||
import com.mogo.commons.storage.SharedPrefsMgr;
|
import com.mogo.och.common.module.manager.loop.LoopInfo
|
||||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
import com.mogo.och.common.module.network.OchCommonServiceCallback
|
||||||
import com.mogo.eagle.core.utilcode.util.JsonUtils;
|
import com.mogo.och.offline.bean.BindLineListResponse
|
||||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
import com.mogo.och.offline.callback.IBusLinesCallback
|
||||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
import com.mogo.och.offline.net.OrderServiceManager
|
||||||
import com.mogo.och.offline.R;
|
import io.reactivex.schedulers.Schedulers
|
||||||
import com.mogo.och.offline.bean.BindLineListResponse;
|
|
||||||
import com.mogo.och.offline.callback.IBusLinesCallback;
|
|
||||||
import com.mogo.och.offline.net.OrderServiceManager;
|
|
||||||
import com.mogo.och.common.module.network.OchCommonServiceCallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: wangmingjun
|
* @author: wangmingjun
|
||||||
* @date: 2022/2/9
|
* @date: 2022/2/9
|
||||||
*/
|
*/
|
||||||
public class BusLineModel {
|
object BusLineModel {
|
||||||
private static volatile BusLineModel sInstance;
|
private var mBusLinesCallback: IBusLinesCallback? = null
|
||||||
private Context mContext;
|
|
||||||
private IBusLinesCallback mBusLinesCallback;
|
|
||||||
private static final String Catche4AllLines = "Catche4AllLines";
|
|
||||||
public static BusLineModel getInstance() {
|
|
||||||
if ( sInstance == null ) {
|
|
||||||
synchronized ( BusLineModel.class ) {
|
|
||||||
if ( sInstance == null ) {
|
|
||||||
sInstance = new BusLineModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sInstance;
|
|
||||||
}
|
|
||||||
private BusLineModel() {
|
|
||||||
|
|
||||||
|
private const val Catche4AllLines = "Catche4AllLines"
|
||||||
|
private const val TAG = "BusLineModel"
|
||||||
|
|
||||||
|
private var lastAllLinesJson = ""
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun setBusLinesCallback(callback: IBusLinesCallback?) {
|
||||||
|
mBusLinesCallback = callback
|
||||||
}
|
}
|
||||||
public void init() {
|
|
||||||
mContext = AbsMogoApplication.getApp();
|
@JvmStatic
|
||||||
}
|
fun queryBusLines() {
|
||||||
public void setBusLinesCallback(IBusLinesCallback callback){
|
val catche4AllLines = SharedPrefsMgr.getInstance().getString(Catche4AllLines)
|
||||||
mBusLinesCallback = callback;
|
val bindLineListResponse =
|
||||||
}
|
GsonUtils.fromJson(catche4AllLines, BindLineListResponse::class.java)
|
||||||
public void queryBusLines(){
|
if (bindLineListResponse != null && mBusLinesCallback != null) {
|
||||||
String catche4AllLines = SharedPrefsMgr.getInstance().getString(Catche4AllLines);
|
mBusLinesCallback!!.onBusLinesChange(bindLineListResponse)
|
||||||
BindLineListResponse bindLineListResponse = GsonUtils.fromJson(catche4AllLines, BindLineListResponse.class);
|
|
||||||
if(bindLineListResponse!=null){
|
|
||||||
mBusLinesCallback.onBusLinesChange(bindLineListResponse);
|
|
||||||
}
|
}
|
||||||
OrderServiceManager.queryBindLineListBySn(new OchCommonServiceCallback<BindLineListResponse>() {
|
lastAllLinesJson = catche4AllLines
|
||||||
@Override
|
OrderServiceManager.queryBindLineListBySn(object : OchCommonServiceCallback<BindLineListResponse> {
|
||||||
public void onSuccess(BindLineListResponse data) {
|
override fun onSuccess(data: BindLineListResponse) {
|
||||||
if (null == data && mBusLinesCallback != null) {
|
if (null == data && mBusLinesCallback != null) {
|
||||||
mBusLinesCallback.onBusLinesChange(null);
|
mBusLinesCallback?.onBusLinesChange(null)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
mBusLinesCallback?.onBusLinesChange(data)
|
||||||
if (mBusLinesCallback != null){
|
val toJson = GsonUtils.toJson(data)
|
||||||
mBusLinesCallback.onBusLinesChange(data);
|
if(lastAllLinesJson==toJson){
|
||||||
SharedPrefsMgr.getInstance().putString(Catche4AllLines, GsonUtils.toJson(data));
|
return
|
||||||
|
}else{
|
||||||
|
lastAllLinesJson = toJson
|
||||||
|
SharedPrefsMgr.getInstance().putString(Catche4AllLines, toJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun onError() {
|
||||||
public void onError() {
|
}
|
||||||
if (!NetworkUtils.isConnected(mContext)) {
|
|
||||||
ToastUtils.showShort(mContext.getString(R.string.network_error_tip));
|
override fun onFail(code: Int, failMsg: String) {
|
||||||
} else {
|
}
|
||||||
ToastUtils.showShort(mContext.getString(R.string.request_error_tip));
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
@JvmStatic
|
||||||
|
fun queryBusLinesByIo() {
|
||||||
|
OrderServiceManager.queryBindLineListBySn(object : OchCommonServiceCallback<BindLineListResponse> {
|
||||||
|
override fun onSuccess(data: BindLineListResponse) {
|
||||||
|
if (null == data) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val toJson = GsonUtils.toJson(data)
|
||||||
|
if(lastAllLinesJson==toJson){
|
||||||
|
return
|
||||||
|
}else{
|
||||||
|
lastAllLinesJson = toJson
|
||||||
|
SharedPrefsMgr.getInstance().putString(Catche4AllLines, toJson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
override fun onError() {
|
||||||
public void onFail(int code, String failMsg) {
|
|
||||||
if (!NetworkUtils.isConnected(mContext)) {
|
|
||||||
ToastUtils.showShort("网络异常,请稍后重试");
|
|
||||||
}else {
|
|
||||||
ToastUtils.showShort("查询所有绑定路线失败:"+failMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
override fun onFail(code: Int, failMsg: String) {
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void commitSwitchLineId(BindLineListResponse.Result checkLineInfo){
|
@JvmStatic
|
||||||
if (mBusLinesCallback != null){
|
fun commitSwitchLineId(checkLineInfo: BindLineListResponse.Result?) {
|
||||||
mBusLinesCallback.onChangeLineIdSuccess(checkLineInfo);
|
if (mBusLinesCallback != null) {
|
||||||
|
mBusLinesCallback!!.onChangeLineIdSuccess(checkLineInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@JvmStatic
|
||||||
|
fun startLoopAllLine() {
|
||||||
|
BizLoopManager.setLoopFunction(TAG, LoopInfo(60,::queryBusLinesByIo, scheduler = Schedulers.io()))
|
||||||
|
}
|
||||||
|
@JvmStatic
|
||||||
|
fun stopLoopAllLine() {
|
||||||
|
BizLoopManager.removeLoopFunction(TAG)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ object OrderServiceManager {
|
|||||||
SharedPrefsMgr.getInstance().sn
|
SharedPrefsMgr.getInstance().sn
|
||||||
)
|
)
|
||||||
.transformIoTry()
|
.transformIoTry()
|
||||||
.subscribe(OchCommonSubscribeImpl(AbsMogoApplication.getApp(), callback, "writeOffCount"))
|
.subscribe(OchCommonSubscribeImpl(AbsMogoApplication.getApp(), callback, "queryBindLineListBySn"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
|||||||
|
|
||||||
public BusLinePresenter(BusSwitchLineView view) {
|
public BusLinePresenter(BusSwitchLineView view) {
|
||||||
super(view);
|
super(view);
|
||||||
BusLineModel.getInstance().init();
|
|
||||||
OrderModel.getInstance().init();
|
OrderModel.getInstance().init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
BusLineModel.getInstance().setBusLinesCallback(this);
|
BusLineModel.setBusLinesCallback(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,15 +59,15 @@ public class BusLinePresenter extends Presenter<BusSwitchLineView> implements IB
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void queryBusLines(){
|
public void queryBusLines(){
|
||||||
BusLineModel.getInstance().queryBusLines();
|
BusLineModel.queryBusLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commitSwitchLineId(BindLineListResponse.Result checkLineInfo){
|
public void commitSwitchLineId(BindLineListResponse.Result checkLineInfo){
|
||||||
BusLineModel.getInstance().commitSwitchLineId(checkLineInfo);
|
BusLineModel.commitSwitchLineId(checkLineInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(){
|
public void removeListener(){
|
||||||
BusLineModel.getInstance().setBusLinesCallback(null);
|
BusLineModel.setBusLinesCallback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryBusRoutes(){
|
public void queryBusRoutes(){
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.mogo.och.offline.callback.IBusControllerStatusCallback;
|
|||||||
import com.mogo.och.offline.callback.IRefreshBusStationsCallback;
|
import com.mogo.och.offline.callback.IRefreshBusStationsCallback;
|
||||||
import com.mogo.och.offline.callback.ISlidePannelHideCallback;
|
import com.mogo.och.offline.callback.ISlidePannelHideCallback;
|
||||||
import com.mogo.och.offline.fragment.ShuttleFragment;
|
import com.mogo.och.offline.fragment.ShuttleFragment;
|
||||||
|
import com.mogo.och.offline.model.BusLineModel;
|
||||||
import com.mogo.och.offline.model.OrderModel;
|
import com.mogo.och.offline.model.OrderModel;
|
||||||
import com.mogo.och.offline.util.BusTrajectoryManager;
|
import com.mogo.och.offline.util.BusTrajectoryManager;
|
||||||
import com.mogo.och.common.module.biz.login.ILoginCallback;
|
import com.mogo.och.common.module.biz.login.ILoginCallback;
|
||||||
@@ -288,7 +289,9 @@ public class BusPresenter extends Presenter<ShuttleFragment>
|
|||||||
if(LoginStatusManager.isLogin()){
|
if(LoginStatusManager.isLogin()){
|
||||||
// OrderModel.getInstance().queryBusRoutes();
|
// OrderModel.getInstance().queryBusRoutes();
|
||||||
OrderModel.getInstance().queryBusCacheRoutes();
|
OrderModel.getInstance().queryBusCacheRoutes();
|
||||||
|
BusLineModel.startLoopAllLine();
|
||||||
}else {
|
}else {
|
||||||
|
BusLineModel.stopLoopAllLine();
|
||||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||||
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
BusTrajectoryManager.getInstance().stopTrajReqLoop();
|
||||||
clearBusStationsMarkers();
|
clearBusStationsMarkers();
|
||||||
|
|||||||
@@ -251,6 +251,18 @@
|
|||||||
android:layout_width="@dimen/dp_142"
|
android:layout_width="@dimen/dp_142"
|
||||||
android:layout_height="@dimen/dp_142"/>
|
android:layout_height="@dimen/dp_142"/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatTextView
|
||||||
|
android:background="@drawable/common_driverroma_normal"
|
||||||
|
android:text="@string/offline_mode"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:layout_marginStart="-10dp"
|
||||||
|
android:layout_marginBottom="@dimen/dp_17"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toRightOf="@id/reportworkorderview"
|
||||||
|
android:layout_width="@dimen/dp_142"
|
||||||
|
android:layout_height="@dimen/dp_142"/>
|
||||||
|
|
||||||
<com.mogo.och.offline.view.SlidePanelView
|
<com.mogo.och.offline.view.SlidePanelView
|
||||||
android:id="@+id/module_mogo_och_slide_panel"
|
android:id="@+id/module_mogo_och_slide_panel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|||||||
@@ -38,6 +38,8 @@
|
|||||||
<string name="bus_dialog_confirm">确认</string>
|
<string name="bus_dialog_confirm">确认</string>
|
||||||
<string name="bus_dialog_cancel">取消</string>
|
<string name="bus_dialog_cancel">取消</string>
|
||||||
|
|
||||||
|
<string name="offline_mode">离线\n模式</string>
|
||||||
|
|
||||||
<string name="bus_no_task_tip">暂无任务</string>
|
<string name="bus_no_task_tip">暂无任务</string>
|
||||||
<string name="shuttle_write_off_count">本站核销成功:%1$d人</string>
|
<string name="shuttle_write_off_count">本站核销成功:%1$d人</string>
|
||||||
<string name="shuttle_write_off_count_default">本站核销成功:0人</string>
|
<string name="shuttle_write_off_count_default">本站核销成功:0人</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user