Commit 2b3e65d7 by Wyh

6.24

parent b5628706
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:gravity="center" android:gravity="center"
android:text="gs1" android:text="gs1"
app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_restaurant_name"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<TextView <TextView
...@@ -30,12 +29,11 @@ ...@@ -30,12 +29,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginLeft="5dp"
android:gravity="center" android:gravity="center"
android:text="yan" android:text="yan"
app:layout_constraintLeft_toRightOf="@id/tv_brand_name" app:layout_constraintTop_toBottomOf="@id/tv_brand_name"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_brand_name" /> app:layout_constraintRight_toRightOf="parent" />
<TextView <TextView
android:id="@+id/tv_print_bill_order_num" android:id="@+id/tv_print_bill_order_num"
......
...@@ -141,7 +141,6 @@ class GetInfoUpdateService : Service() { ...@@ -141,7 +141,6 @@ class GetInfoUpdateService : Service() {
// 初始化socket // 初始化socket
private fun initSocket() { private fun initSocket() {
Log.e("eee", "啊啊啊啊" + application.isRestricted)
RxTimerUtil.cancel() RxTimerUtil.cancel()
RxTimerUtil.timer({ RxTimerUtil.timer({
client = OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).build() client = OkHttpClient.Builder().readTimeout(0, TimeUnit.MILLISECONDS).build()
...@@ -312,10 +311,13 @@ class GetInfoUpdateService : Service() { ...@@ -312,10 +311,13 @@ class GetInfoUpdateService : Service() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
Log.e(TAG, "onDestroy") Log.e("eee", "onDestroy")
//清除心跳
clearHeart()
isDestroy = true isDestroy = true
//取消廣播
unregisterReceiver(mReceiver) unregisterReceiver(mReceiver)
//斷開鏈接 //斷開鏈接
client?.let { client?.let {
mWebSocket?.cancel() mWebSocket?.cancel()
it.dispatcher().cancelAll() it.dispatcher().cancelAll()
...@@ -324,19 +326,22 @@ class GetInfoUpdateService : Service() { ...@@ -324,19 +326,22 @@ class GetInfoUpdateService : Service() {
mWebSocket!!.send("-1") mWebSocket!!.send("-1")
mWebSocket!!.close(1000, null) mWebSocket!!.close(1000, null)
} }
//停止定時心跳
RxTimerUtil.cancel() RxTimerUtil.cancel()
//停止服務 //停止前台服務
stopForeground(true) stopForeground(true)
} }
private fun clearHeart() {
val requestBody = FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService).toString() + "")
.build()
OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/restaurant/clearHeartbeat", requestBody)//清除心跳
}
inner class ClearHeartBroadcastReceiver : BroadcastReceiver() { inner class ClearHeartBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
//清除心跳並關閉service //關閉service,會調用service的onDestroy
val requestBody = FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService).toString() + "")
.build()
OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/restaurant/clearHeartbeat", requestBody)//清除心跳
stopSelf() stopSelf()
} }
} }
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_8" />
<solid android:color="@color/close_btn_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:padding="@dimen/dp_10">
<ImageView
android:id="@+id/iv_launch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_launcher" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_toEndOf="@id/iv_launch"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ricepon pos"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:text="外賣接單服務"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
</LinearLayout>
<Button
android:id="@+id/btn_stop_service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:background="@drawable/shape_cloas_btn"
android:text="停止接單"
android:textColor="@color/white"
android:textSize="@dimen/dp_14" />
</RelativeLayout>
\ No newline at end of file
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