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