Commit c674b533 by Wyh

6.16 心跳優化,訂單詳情加載優化,打印機加機型。

parent c07bddb7
...@@ -94,10 +94,10 @@ public class HttpsConstans { ...@@ -94,10 +94,10 @@ public class HttpsConstans {
//修改這個值,修改微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據 //修改這個值,修改微信公眾號報表地址:首頁曲線圖數據,支付分析報表數據
public static String WECHAR_REPORT_SERVER_ADDRESS;// = (isFormal ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS public static String WECHAR_REPORT_SERVER_ADDRESS;// = (isFormal ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
public static void init(Context context,boolean isSwitchServer) { public static void init(Context context, boolean isSwitchServer) {
isFormal = (int) SPUtils.get(context, "isFormal", 1); isFormal = (int) SPUtils.get(context, "isFormal", 1);
if (!BuildConfig.DEBUG && !isSwitchServer) { if (!isSwitchServer) {
isFormal = 1; isFormal = BuildConfig.DEBUG ? 2 : 1;
} }
// _SERVER_ADDRESS = (isFormal == 1 ? HTTP_ADDRESS_URL_FORMAL : "http://a.ricepon.com:61177") + "/member-web/api/"; // _SERVER_ADDRESS = (isFormal == 1 ? HTTP_ADDRESS_URL_FORMAL : "http://a.ricepon.com:61177") + "/member-web/api/";
// ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = isFormal ==1 ? HTTP_ADDRESS_URL_FORMAL : REPORT_TEST_ADDRESS; // ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = isFormal ==1 ? HTTP_ADDRESS_URL_FORMAL : REPORT_TEST_ADDRESS;
...@@ -106,45 +106,45 @@ public class HttpsConstans { ...@@ -106,45 +106,45 @@ public class HttpsConstans {
// REPORT_SERVER_ADDRESS = (isFormal ==1 ? REPORT_FORMAL_ADDRESS : REPORT_TEST_ADDRESS) + REPORT_PATH;//測試:REPORT_FORMAL_ADDRESS 正式:REPORT_TEST_ADDRESS // REPORT_SERVER_ADDRESS = (isFormal ==1 ? REPORT_FORMAL_ADDRESS : REPORT_TEST_ADDRESS) + REPORT_PATH;//測試:REPORT_FORMAL_ADDRESS 正式:REPORT_TEST_ADDRESS
// WECHAR_REPORT_SERVER_ADDRESS = (isFormal == 1 ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS // WECHAR_REPORT_SERVER_ADDRESS = (isFormal == 1 ? WECHAR_REPORT_FORMAL_ADDRESS : WECHAR_REPORT_TEST_ADDRESS) + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
switch (isFormal){ switch (isFormal) {
case 1: case 1:
_SERVER_ADDRESS = HTTP_ADDRESS_URL_FORMAL + "/member-web/api/"; _SERVER_ADDRESS = HTTP_ADDRESS_URL_FORMAL + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL ; ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL + PATH; ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_FORMAL + PATH;
ROOT_URL = ROOT_FORMAL_URL ; ROOT_URL = ROOT_FORMAL_URL;
REPORT_SERVER_ADDRESS = REPORT_FORMAL_ADDRESS +REPORT_PATH; REPORT_SERVER_ADDRESS = REPORT_FORMAL_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_FORMAL_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_FORMAL_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break; break;
case 2: case 2:
_SERVER_ADDRESS = "http://a.ricepon.com:61177" + "/member-web/api/"; _SERVER_ADDRESS = "http://a.ricepon.com:61177" + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ; ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_HK + PATH; ROOT_SERVER_ADDRESS_FORMAL = HTTP_ADDRESS_URL_HK + PATH;
ROOT_URL = ROOT_HK_TEST_URL ; ROOT_URL = ROOT_HK_TEST_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH; REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break; break;
case 3: case 3:
_SERVER_ADDRESS = ROOT_SERVER_YOU_CHANG_HK + "/member-web/api/"; _SERVER_ADDRESS = ROOT_SERVER_YOU_CHANG_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ; ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_YOU_CHANG_HK; ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_YOU_CHANG_HK;
ROOT_URL = ROOT_SZ_URL ; ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH; REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break; break;
case 4: case 4:
_SERVER_ADDRESS = ROOT_SERVER_SHI_WEI_HK + "/member-web/api/"; _SERVER_ADDRESS = ROOT_SERVER_SHI_WEI_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ; ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_WEI_HK; ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_WEI_HK;
ROOT_URL = ROOT_SZ_URL ; ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH; REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break; break;
case 5: case 5:
_SERVER_ADDRESS = ROOT_SERVER_SHI_SHU_HK + "/member-web/api/"; _SERVER_ADDRESS = ROOT_SERVER_SHI_SHU_HK + "/member-web/api/";
ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS ; ROOT_SETTLEMENT_REPORT_SERVER_ADDRESS_FORMAL = REPORT_TEST_ADDRESS;
ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_SHU_HK; ROOT_SERVER_ADDRESS_FORMAL = ROOT_SERVER_SHI_SHU_HK;
ROOT_URL = ROOT_SZ_URL ; ROOT_URL = ROOT_SZ_URL;
REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS +REPORT_PATH; REPORT_SERVER_ADDRESS = REPORT_TEST_ADDRESS + REPORT_PATH;
WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS WECHAR_REPORT_SERVER_ADDRESS = WECHAR_REPORT_TEST_ADDRESS + WECHAR_REPORT_PATH;//正式:WECHAR_REPORT_FORMAL_ADDRESS 測試:WECHAR_REPORT_TEST_ADDRESS
break; break;
} }
......
package com.gingersoft.gsa.cloud.ui.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.base.R;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
public class OrderPayView extends LinearLayout {
// public OrderPayView(Context context) {
// this(context, null);
// }
public OrderPayView(Context context) {
this(context, null);
}
public OrderPayView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public OrderPayView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
public void init(Context context) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_order_pay, null);
MaxHeightRecyclerView rv_bill_money = view.findViewById(R.id.rv_bill_money);
TextView tvDifferenceName = view.findViewById(R.id.tv_difference_name);
TextView tvDifferenceMoney = view.findViewById(R.id.tv_difference_money);
MaxHeightRecyclerView rv_bill_method = view.findViewById(R.id.rv_bill_method);
QMUIAlphaButton keypadBtn = view.findViewById(R.id.btn_keypad);
QMUIAlphaButton exactBtn = view.findViewById(R.id.btn_exact);
QMUIAlphaButton sureBtn = view.findViewById(R.id.btn_sure_pay);
this.addView(view);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<com.gingersoft.gsa.cloud.ui.view.MaxHeightRecyclerView
android:id="@+id/rv_bill_money"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:fadeScrollbars="false"
android:orientation="vertical"
android:background="@color/theme_background_color"
app:maxHeight="@dimen/dp_80"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/yellow"
android:padding="@dimen/dp_5">
<TextView
android:id="@+id/tv_difference_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="尚欠:"
android:textSize="@dimen/sp_20"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_difference_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/red"
android:textSize="@dimen/sp_20"
android:textStyle="bold" />
</RelativeLayout>
<com.gingersoft.gsa.cloud.ui.view.MaxHeightRecyclerView
android:id="@+id/rv_bill_method"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@null"
android:fadeScrollbars="false"
android:orientation="vertical"
app:maxHeight="@dimen/dp_100"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="4"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_1"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_keypad"
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:background="#2F6666"
android:text="Keypad"
android:textColor="@color/theme_white_color"/>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_exact"
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:background="#315FC5"
android:layout_marginLeft="@dimen/dp_1"
android:text="Exact"
android:textColor="@color/theme_white_color"/>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_sure_pay"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginLeft="@dimen/dp_1"
android:layout_height="match_parent"
android:background="@color/Grass_green"
android:text="確認"
android:textColor="@color/theme_white_color"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
...@@ -495,4 +495,6 @@ ...@@ -495,4 +495,6 @@
<!-- 取消物流按鈕背景色--> <!-- 取消物流按鈕背景色-->
<color name="other_order_details_cancel_logistics_btn_color">#E74E40</color> <color name="other_order_details_cancel_logistics_btn_color">#E74E40</color>
<!-- 骨架屏加載時的顏色-->
<color name="skeleton_color">@color/color_f4</color>
</resources> </resources>
...@@ -5,8 +5,8 @@ ext { ...@@ -5,8 +5,8 @@ ext {
buildToolsVersion: '28.0.3', buildToolsVersion: '28.0.3',
minSdkVersion : 19, //N5收銀機應用安卓開發環境要求Android OS Version: 5.1Android SDK Min Version: 19 minSdkVersion : 19, //N5收銀機應用安卓開發環境要求Android OS Version: 5.1Android SDK Min Version: 19
targetSdkVersion : 28, targetSdkVersion : 28,
versionCode : 2, versionCode : 3,
versionName : "1.0.2" versionName : "1.0.3"
] ]
version = [ version = [
......
...@@ -5,6 +5,7 @@ import android.content.Intent; ...@@ -5,6 +5,7 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.text.TextUtils; import android.text.TextUtils;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication; import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.gingersoft.gsa.cloud.base.utils.LanguageUtils; import com.gingersoft.gsa.cloud.base.utils.LanguageUtils;
import com.gingersoft.gsa.cloud.main.R; import com.gingersoft.gsa.cloud.main.R;
...@@ -120,8 +121,14 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa ...@@ -120,8 +121,14 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
public void loginOut() { public void loginOut() {
RequestBody requestBody = new FormBody.Builder() RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) +"") .add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) + "")
.build(); .build();
CC.obtainBuilder("Component.OtherOrder")
.setActionName("closeHeart")
.build()
.call();
mModel.clearHeartbeat(requestBody) mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null)) .doOnSubscribe(disposable -> mRootView.showLoading(null))
......
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
android:layout_marginRight="@dimen/dp_10" android:layout_marginRight="@dimen/dp_10"
app:hl_cornerRadius="@dimen/dp_4" app:hl_cornerRadius="@dimen/dp_4"
app:hl_dy="@dimen/main_shadow_dy" app:hl_dy="@dimen/main_shadow_dy"
android:visibility="visible" android:visibility="gone"
app:hl_shadowBackColor="@color/white" app:hl_shadowBackColor="@color/white"
app:hl_shadowColor="@color/shadow_color" app:hl_shadowColor="@color/shadow_color"
app:hl_shadowLimit="@dimen/main_shadow_limit"> app:hl_shadowLimit="@dimen/main_shadow_limit">
......
...@@ -75,7 +75,8 @@ dependencies { ...@@ -75,7 +75,8 @@ dependencies {
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.ethanhua:skeleton:1.1.2'
implementation 'io.supercharge:shimmerlayout:2.1.0'
if (project.ext.runAsApp) { if (project.ext.runAsApp) {
addComponent 'print-module' addComponent 'print-module'
} }
......
package com.gingersoft.gsa.other_order_mode; package com.gingersoft.gsa.other_order_mode;
import android.content.Intent;
import android.util.Log;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.billy.cc.core.component.CCResult; import com.billy.cc.core.component.CCResult;
import com.billy.cc.core.component.CCUtil; import com.billy.cc.core.component.CCUtil;
import com.billy.cc.core.component.IComponent; import com.billy.cc.core.component.IComponent;
import com.gingersoft.gsa.other_order_mode.service.GetInfoUpdateService;
import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity; import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity;
...@@ -44,6 +48,11 @@ public class OtherOrderComponent implements IComponent { ...@@ -44,6 +48,11 @@ public class OtherOrderComponent implements IComponent {
CCUtil.navigateTo(cc, OtherOrderActivity.class); CCUtil.navigateTo(cc, OtherOrderActivity.class);
CC.sendCCResult(cc.getCallId(), CCResult.success()); CC.sendCCResult(cc.getCallId(), CCResult.success());
break; break;
case "closeHeart":
Intent intent = new Intent(cc.getContext(), GetInfoUpdateService.class);
cc.getContext().stopService(intent);
Log.e("eee", "closeHeart");
break;
default: default:
// cc.callAsync(new IComponentCallback() { // cc.callAsync(new IComponentCallback() {
// @Override // @Override
......
...@@ -13,6 +13,7 @@ import android.util.Log ...@@ -13,6 +13,7 @@ import android.util.Log
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator import com.gingersoft.gsa.other_order_mode.data.network.ServiceCreator
import com.gingersoft.gsa.other_order_mode.util.RxTimerUtil
import com.google.gson.Gson import com.google.gson.Gson
import io.reactivex.Observable import io.reactivex.Observable
import okhttp3.* import okhttp3.*
...@@ -28,10 +29,12 @@ class GetInfoUpdateService : Service() { ...@@ -28,10 +29,12 @@ class GetInfoUpdateService : Service() {
/** /**
* 心跳检测时间 * 心跳检测时间
*/ */
private val HEART_BEAT_RATE = (60 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测 private val HEART_BEAT_RATE = (58 * 1000).toLong()//每隔15秒进行一次对长连接的心跳检测
private val WEBSOCKET_HOST_AND_PORT = "${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号 private val WEBSOCKET_HOST_AND_PORT = "${ServiceCreator.ROOT_URL}/ricepon-websocket/js/webSocketServer"//可替换为自己的主机名和端口号
private var mWebSocket: WebSocket? = null private var mWebSocket: WebSocket? = null
var client: OkHttpClient? = null
var postCallBack: PostCallBack? = null var postCallBack: PostCallBack? = null
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {
...@@ -70,29 +73,28 @@ class GetInfoUpdateService : Service() { ...@@ -70,29 +73,28 @@ class GetInfoUpdateService : Service() {
// 初始化socket // 初始化socket
private fun initSocket() { private fun initSocket() {
// Observable.interval(5, 10, TimeUnit.SECONDS) RxTimerUtil.cancel()
// .subscribe(Observer()) RxTimerUtil.timer({
val client = OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).build() client = OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).build()
client?.let {
val request = Request.Builder() val request = Request.Builder()
.url(WEBSOCKET_HOST_AND_PORT) .url(WEBSOCKET_HOST_AND_PORT)
.build() .build()
it.newWebSocket(request, object : WebSocketListener() {
client.newWebSocket(request, object : WebSocketListener() { override fun onOpen(webSocket: WebSocket, response: Response) {//开启长连接成功的回调
override fun onOpen(webSocket: WebSocket?, response: Response?) {//开启长连接成功的回调
super.onOpen(webSocket, response) super.onOpen(webSocket, response)
if (!this@GetInfoUpdateService.isDestroy) { if (!this@GetInfoUpdateService.isDestroy) {
mWebSocket = webSocket mWebSocket = webSocket
val token = "weixin_" + GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService) + "_" + getRandomString(24) val token = "weixin_" + GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService) + "_" + getRandomString(24)
Log.e(TAG, "token:$token") Log.e(TAG, "token:$token")
webSocket!!.send(Gson().toJson(MsgBean(1, token))) webSocket.send(Gson().toJson(MsgBean(1, token)))
} }
} }
override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调 override fun onMessage(webSocket: WebSocket?, text: String?) {//接收消息的回调
super.onMessage(webSocket, text) super.onMessage(webSocket, text)
val json = JSONObject(text) val json = JSONObject(text)
val type = json.optInt("type")
val type = json.optInt("type");
if (postCallBack != null) { if (postCallBack != null) {
postCallBack!!.callBack(type) postCallBack!!.callBack(type)
} }
...@@ -135,17 +137,17 @@ class GetInfoUpdateService : Service() { ...@@ -135,17 +137,17 @@ class GetInfoUpdateService : Service() {
super.onFailure(webSocket, t, response) super.onFailure(webSocket, t, response)
Log.e(TAG, "onFailure" + t!!.message) Log.e(TAG, "onFailure" + t!!.message)
if (!this@GetInfoUpdateService.isDestroy) { if (!this@GetInfoUpdateService.isDestroy) {
Log.e(TAG, "沒銷毀") // Log.e(TAG, "沒銷毀")
initSocket()//创建一个新的连接 // initSocket()//创建一个新的连接
} else { } else {
webSocket?.cancel() webSocket?.cancel()
client.dispatcher().cancelAll() it.dispatcher().cancelAll()
} }
} }
}) })
client.dispatcher().executorService().shutdown() it.dispatcher().executorService().shutdown()
}
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE)//开启心跳检测 }, HEART_BEAT_RATE)
} }
private var soundPool: SoundPool? = null private var soundPool: SoundPool? = null
...@@ -212,28 +214,29 @@ class GetInfoUpdateService : Service() { ...@@ -212,28 +214,29 @@ class GetInfoUpdateService : Service() {
} }
private var sendTime = 0L // private var sendTime = 0L
// 发送心跳包 // 发送心跳包
private val mHandler = Handler()
private val heartBeatRunnable = object : Runnable { // private val mHandler = Handler()
override fun run() { // private val heartBeatRunnable = object : Runnable {
if (!isDestroy) { // override fun run() {
if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) { // if (!isDestroy) {
val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态 // if (System.currentTimeMillis() - sendTime >= HEART_BEAT_RATE) {
Log.e(TAG, "連接狀態:$isSuccess") // val isSuccess = mWebSocket?.send("0")//发送一个空消息给服务器,通过发送消息的成功失败来判断长连接的连接状态
// if (isSuccess != null && !isSuccess) {//长连接已断开 // Log.e(TAG, "連接狀態:$isSuccess")
mHandler.removeCallbacks(this) //// if (isSuccess != null && !isSuccess) {//长连接已断开
mWebSocket?.cancel()//取消掉以前的长连接 // mHandler.removeCallbacks(this)
InitSocketThread().start()//创建一个新的连接 // mWebSocket?.cancel()//取消掉以前的长连接
// } else {//长连接处于连接状态 // InitSocketThread().start()//创建一个新的连接
// //// } else {//长连接处于连接状态
////
//// }
// sendTime = System.currentTimeMillis()
// }
//// mHandler.postDelayed(this, HEART_BEAT_RATE)//每隔一定的时间,对长连接进行一次心跳检测
// }
// }
// } // }
sendTime = System.currentTimeMillis()
}
// mHandler.postDelayed(this, HEART_BEAT_RATE)//每隔一定的时间,对长连接进行一次心跳检测
}
}
}
private var isDestroy = false private var isDestroy = false
...@@ -241,11 +244,16 @@ class GetInfoUpdateService : Service() { ...@@ -241,11 +244,16 @@ class GetInfoUpdateService : Service() {
super.onDestroy() super.onDestroy()
Log.e(TAG, "onDestroy") Log.e(TAG, "onDestroy")
isDestroy = true isDestroy = true
client?.let {
mWebSocket?.cancel()
it.dispatcher().cancelAll()
}
if (mWebSocket != null) { if (mWebSocket != null) {
mWebSocket!!.send("-1") mWebSocket!!.send("-1")
mWebSocket!!.close(1000, null) mWebSocket!!.close(1000, null)
mHandler.removeCallbacks(heartBeatRunnable) // mHandler.removeCallbacks(heartBeatRunnable)
} }
RxTimerUtil.cancel()
} }
class MsgBean(var type: Int, var token: String) class MsgBean(var type: Int, var token: String)
......
...@@ -2,11 +2,14 @@ package com.gingersoft.gsa.other_order_mode.ui.activity ...@@ -2,11 +2,14 @@ package com.gingersoft.gsa.other_order_mode.ui.activity
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.view.View
import android.widget.TextView import android.widget.TextView
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.ethanhua.skeleton.Skeleton
import com.ethanhua.skeleton.ViewSkeletonScreen
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils
import com.gingersoft.gsa.cloud.base.widget.DialogUtils import com.gingersoft.gsa.cloud.base.widget.DialogUtils
...@@ -24,7 +27,11 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter ...@@ -24,7 +27,11 @@ import com.gingersoft.gsa.other_order_mode.ui.adapter.FoodListAdapter
import com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter import com.gingersoft.gsa.other_order_mode.ui.adapter.OrderDetailsAdapter
import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity import com.gingersoft.gsa.other_order_mode.ui.base.BaseActivity
import com.gingersoft.gsa.other_order_mode.util.InjectorUtil import com.gingersoft.gsa.other_order_mode.util.InjectorUtil
import com.qmuiteam.qmui.widget.QMUITopBar
import kotlinx.android.synthetic.main.activity_order_details.* import kotlinx.android.synthetic.main.activity_order_details.*
import kotlinx.android.synthetic.main.activity_order_details.rv_food
import kotlinx.android.synthetic.main.activity_order_details.tv_order_state
import kotlinx.android.synthetic.main.activity_order_details_loading.*
class OrderDetailsActivity : BaseActivity() { class OrderDetailsActivity : BaseActivity() {
...@@ -34,10 +41,21 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -34,10 +41,21 @@ class OrderDetailsActivity : BaseActivity() {
private lateinit var orderId: String private lateinit var orderId: String
private var orderType: Int = 0 private var orderType: Int = 0
private var orderPayType: Int = 0 private var orderPayType: Int = 0
lateinit var skeletonScreen: ViewSkeletonScreen
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_order_details) binding = DataBindingUtil.setContentView(this, R.layout.activity_order_details)
val rootView = findViewById<View>(R.id.scroll_order_info)
skeletonScreen = Skeleton.bind(rootView)
.load(R.layout.activity_order_details_loading)
.shimmer(true)
.duration(1000)
.angle(20)
.color(R.color.white)
.show()
orderId = intent.getStringExtra("orderId")//訂單id orderId = intent.getStringExtra("orderId")//訂單id
orderType = intent.getIntExtra("orderType", 0)//訂單類型 orderType = intent.getIntExtra("orderType", 0)//訂單類型
orderPayType = intent.getIntExtra("orderPayType", 0)//訂單支付方式 orderPayType = intent.getIntExtra("orderPayType", 0)//訂單支付方式
...@@ -45,16 +63,18 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -45,16 +63,18 @@ class OrderDetailsActivity : BaseActivity() {
pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply { pageViewModel = ViewModelProvider(this, InjectorUtil.getWeatherModelFactory())[PageViewModel::class.java].apply {
getOrderDetails(orderId, binding) getOrderDetails(orderId, binding)
} }
initTopBar(qm_order_details_bar)
}
qm_order_details_bar.setTitle(GsaCloudApplication.getRestaurantName(this)) private fun initTopBar(topbar: QMUITopBar) {
qm_order_details_bar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() } topbar.setTitle(GsaCloudApplication.getRestaurantName(this@OrderDetailsActivity))
qm_order_details_bar.setBackgroundColor(resources.getColor(R.color.theme_color)) topbar.addLeftImageButton(R.drawable.icon_return, R.id.iv_left_back).setOnClickListener { finish() }
topbar.setBackgroundColor(resources.getColor(R.color.theme_color))
} }
private fun PageViewModel.getOrderDetails(orderId: String, binding: ActivityOrderDetailsBinding) { private fun PageViewModel.getOrderDetails(orderId: String, binding: ActivityOrderDetailsBinding) {
showLoading()
getShipanyAndOrderInfo(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), orderId) { it -> getShipanyAndOrderInfo(GsaCloudApplication.getRestaurantId(this@OrderDetailsActivity).toString(), orderId) { it ->
cancelDialogForLoading() skeletonScreen.hide()
if (it?.data != null && it.data!!.isNotEmpty()) { if (it?.data != null && it.data!!.isNotEmpty()) {
val orderDetails = it.data!![0] val orderDetails = it.data!![0]
orderDetails.order_type = orderType orderDetails.order_type = orderType
......
...@@ -260,10 +260,10 @@ class OtherOrderActivity : BaseActivity() { ...@@ -260,10 +260,10 @@ class OtherOrderActivity : BaseActivity() {
bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE) bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE)
} }
override fun onDestroy() { // override fun onDestroy() {
super.onDestroy() // super.onDestroy()
unbindService(serviceConnection) // unbindService(serviceConnection)
} // }
private var serviceConnection = object : ServiceConnection { private var serviceConnection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName, service: IBinder) { override fun onServiceConnected(name: ComponentName, service: IBinder) {
......
package com.gingersoft.gsa.other_order_mode.util
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import java.util.concurrent.TimeUnit
class RxTimerUtil {
companion object {
var mDisposable: Disposable? = null
/**
* 执行定时任务
*/
fun timer(block: () -> Unit, milliseconds: Long) {
Observable.interval(0, milliseconds, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<Long> {
override fun onError(e: Throwable) {}
override fun onComplete() {}
override fun onNext(t: Long) {
block()
}
override fun onSubscribe(d: Disposable) {
mDisposable = d
}
})
}
/**
* 取消定时器
*/
fun cancel() {
if (mDisposable != null && !mDisposable!!.isDisposed) {
mDisposable!!.dispose()
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:endColor="#99C0A069"
android:startColor="#FFC0A069" />
</shape>
\ No newline at end of file
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
</data> </data>
<RelativeLayout <RelativeLayout
android:id="@+id/rootview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/color_f0"> android:background="@color/color_f0">
...@@ -57,7 +58,6 @@ ...@@ -57,7 +58,6 @@
app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color" app:qmui_topbar_text_btn_color_state_list="@color/theme_white_color"
app:qmui_topbar_title_color="@color/theme_white_color" /> app:qmui_topbar_title_color="@color/theme_white_color" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_details_btn" android:id="@+id/rv_order_details_btn"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
style="@style/otherOrder_details_twelve_text_Style" style="@style/otherOrder_details_twelve_text_Style"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft" android:layout_marginLeft="@dimen/other_order_info_dialog_content_marginLeft"
android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}" android:text="@{@string/create_order_time + TimeUtils.parseTimeRepeat(data.cREATE_TIME,TimeUtils.DEFAULT_DATE_FORMAT)}"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
app:layout_constraintRight_toLeftOf="@id/iv_edit" app:layout_constraintRight_toLeftOf="@id/iv_edit"
app:layout_constraintTop_toTopOf="@id/tv_difference_text" /> app:layout_constraintTop_toTopOf="@id/tv_difference_text" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton <ImageView
android:id="@+id/iv_edit" android:id="@+id/iv_edit"
android:layout_width="@dimen/dp_30" android:layout_width="@dimen/dp_30"
android:layout_height="0dp" android:layout_height="0dp"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
\ No newline at end of file
...@@ -65,7 +65,6 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -65,7 +65,6 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
@Nullable @Nullable
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
return null; return null;
} }
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
android:value="ConfigModule" /> android:value="ConfigModule" />
<meta-data <meta-data
android:name="design_width_in_dp" android:name="design_width_in_dp"
android:value="360"/> android:value="360"/>
......
...@@ -475,7 +475,6 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements ...@@ -475,7 +475,6 @@ public class OrderPayActivity extends BaseActivity<OrderPayPresenter> implements
PayMethod billMoneyBean = mPresenter.getSelectBillMoney(); PayMethod billMoneyBean = mPresenter.getSelectBillMoney();
billMoneyBean.setPayMoney(Double.parseDouble(money)); billMoneyBean.setPayMoney(Double.parseDouble(money));
mPresenter.getBillMoneyAdapter().notifyDataSetChanged(); mPresenter.getBillMoneyAdapter().notifyDataSetChanged();
setDifferenceText(); setDifferenceText();
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment