Commit b5628706 by Wyh

6.23 外賣接單心跳加入通知欄,點擊可停用接單服務

parent 0fc0adee
...@@ -5,6 +5,7 @@ import android.content.Context; ...@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.RemoteException; import android.os.RemoteException;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -280,8 +281,8 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -280,8 +281,8 @@ public class GsaCloudApplication extends BaseApplication {
/** /**
* 给外部的三方库 {@link Activity} 自定义适配参数, 因为三方库的 {@link Activity} 并不能通过实现 * 给外部的三方库 {@link Activity} 自定义适配参数, 因为三方库的 {@link Activity} 并不能通过实现
* {@link CustomAdapt} 接口的方式来提供自定义适配参数 (因为远程依赖改不了源码) * {@link me.jessyan.autosize.internal.CustomAdapt} 接口的方式来提供自定义适配参数 (因为远程依赖改不了源码)
* 所以使用 {@link ExternalAdaptManager} 来替代实现接口的方式, 来提供自定义适配参数 * 所以使用 {@link me.jessyan.autosize.external.ExternalAdaptManager} 来替代实现接口的方式, 来提供自定义适配参数
*/ */
private void customAdaptForExternal() { private void customAdaptForExternal() {
/** /**
...@@ -408,5 +409,4 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -408,5 +409,4 @@ public class GsaCloudApplication extends BaseApplication {
setRestaurantName(mAppContext, ""); setRestaurantName(mAppContext, "");
setBrandRestaurantInfos(mAppContext, ""); setBrandRestaurantInfos(mAppContext, "");
} }
} }
...@@ -13,4 +13,6 @@ public class AppConstans { ...@@ -13,4 +13,6 @@ public class AppConstans {
public static final String PRESSSOUND_PROGRESS = "presssound_progress";//按键音量 public static final String PRESSSOUND_PROGRESS = "presssound_progress";//按键音量
public static final String CARSH_STR = "$"; public static final String CARSH_STR = "$";
public static final String CLEAR_ORDER_RECEIVING_HEART ="CLEAR_ORDER_RECEIVING_HEART";
} }
...@@ -70,7 +70,7 @@ class OrderDetails { ...@@ -70,7 +70,7 @@ class OrderDetails {
var TOTAL_AMOUNT: String? = null var TOTAL_AMOUNT: String? = null
//後台不會返回 //後台不會返回
var order_type: Int = 0 var order_type: Int = 0
var orderPayType: Int = 0 var orderPayType: Int = 0//1為貨到付款,其他是在線支付
var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送 var isDelete: Int = 1 //默認為1,為0是第三方物流,其他則是本店配送
var payType: Int = 0//1:積分支付;2:支付寶;3:财付通;4:微信支付;5:貨到付款;6:其他支付 var payType: Int = 0//1:積分支付;2:支付寶;3:财付通;4:微信支付;5:貨到付款;6:其他支付
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<style name="AppTheme" parent="PublicTheme"> <style name="AppTheme" parent="PublicTheme">
<item name="QMUITopBarStyle">@style/QDTopBar</item> <item name="QMUITopBarStyle">@style/QDTopBar</item>
<item name="QMUITabSegmentStyle">@style/QMUITabSegmentStyle</item> <item name="QMUITabSegmentStyle">@style/QMUITabSegmentStyle</item>
<item name="android:windowActivityTransitions">true</item> <!-- <item name="android:windowActivityTransitions">false</item>-->
<!-- <item name="android:windowDisablePreview">true</item>-->
</style> </style>
</resources> </resources>
\ No newline at end of file
...@@ -487,6 +487,7 @@ ...@@ -487,6 +487,7 @@
<color name="restaurant_color_busy_close">#F56C6C</color> <color name="restaurant_color_busy_close">#F56C6C</color>
<color name="restaurant_color_busy_open">#E6A23C</color> <color name="restaurant_color_busy_open">#E6A23C</color>
<color name="close_btn_color">#E74E40</color>
<!-- 確認訂單按鈕背景色--> <!-- 確認訂單按鈕背景色-->
<color name="other_order_details_sure_btn_color">#1196DB</color> <color name="other_order_details_sure_btn_color">#1196DB</color>
<!-- 取消訂單按鈕背景色--> <!-- 取消訂單按鈕背景色-->
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
<item name="colorAccent">@color/colorAccent</item> <item name="colorAccent">@color/colorAccent</item>
<item name="android:windowAnimationStyle">@style/ui_activityAnimation <item name="android:windowAnimationStyle">@style/ui_activityAnimation
</item><!-- 设置activity切换动画 --> </item><!-- 设置activity切换动画 -->
<item name="android:windowIsTranslucent">true</item><!-- 防止Acitivity跳转黑屏 将背景设置成透明--> <item name="android:windowIsTranslucent">false</item><!-- 防止Acitivity跳转黑屏 将背景设置成透明-->
<item name="android:windowDisablePreview">true</item>
</style> </style>
<!--首頁主題 標題欄文字顏色和其他的不一樣--> <!--首頁主題 標題欄文字顏色和其他的不一樣-->
......
...@@ -116,20 +116,7 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa ...@@ -116,20 +116,7 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
RequestBody requestBody = new FormBody.Builder() RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) + "") .add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) + "")
.build(); .build();
clearHeartbeat();
CC.obtainBuilder("Component.OtherOrder")
.setActionName("closeHeart")
.build()
.call();
mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io())
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
}
});
mModel.loginOut(requestBody) mModel.loginOut(requestBody)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null)) .doOnSubscribe(disposable -> mRootView.showLoading(null))
...@@ -149,6 +136,27 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa ...@@ -149,6 +136,27 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
}); });
} }
public void clearHeartbeat(){
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(mApplication) + "")
.build();
//關閉心跳
CC.obtainBuilder("Component.OtherOrder")
.setActionName("closeHeart")
.build()
.call();
mModel.clearHeartbeat(requestBody)
.subscribeOn(Schedulers.io())
.subscribe(new ErrorHandleSubscriber<Object>(mErrorHandler) {
@Override
public void onNext(@NonNull Object info) {
}
});
}
public void updateAPK(int type, String downApkURL) { public void updateAPK(int type, String downApkURL) {
if(type == 4 || type == 5){ if(type == 4 || type == 5){
if(type == 4){ if(type == 4){
......
package com.gingersoft.gsa.cloud.main.mvp.ui.activity; package com.gingersoft.gsa.cloud.main.mvp.ui.activity;
import android.content.BroadcastReceiver;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.GradientDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.View; import android.view.View;
...@@ -17,6 +20,7 @@ import android.widget.TextView; ...@@ -17,6 +20,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
...@@ -27,6 +31,7 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils; ...@@ -27,6 +31,7 @@ import com.gingersoft.gsa.cloud.base.utils.JsonUtils;
import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils; import com.gingersoft.gsa.cloud.base.utils.RestaurantInfoUtils;
import com.gingersoft.gsa.cloud.base.utils.encryption.Aes; import com.gingersoft.gsa.cloud.base.utils.encryption.Aes;
import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils; import com.gingersoft.gsa.cloud.base.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.constans.AppConstans;
import com.gingersoft.gsa.cloud.database.bean.Function; import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.gsa.cloud.main.BuildConfig; import com.gingersoft.gsa.cloud.main.BuildConfig;
import com.gingersoft.gsa.cloud.main.R; import com.gingersoft.gsa.cloud.main.R;
...@@ -55,6 +60,8 @@ import java.util.List; ...@@ -55,6 +60,8 @@ import java.util.List;
import butterknife.BindView; import butterknife.BindView;
import butterknife.BindViews; import butterknife.BindViews;
import butterknife.OnClick; import butterknife.OnClick;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import static com.jess.arms.utils.Preconditions.checkNotNull; import static com.jess.arms.utils.Preconditions.checkNotNull;
...@@ -129,10 +136,9 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -129,10 +136,9 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
public int initView(@Nullable Bundle savedInstanceState) { public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.activity_new_main; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0 return R.layout.activity_new_main; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
} }
@Override @Override
public void initData(@Nullable Bundle savedInstanceState) { public void initData(@Nullable Bundle savedInstanceState) {
// mPresenter.requestExternalStoragePermission(); // mPresenter.requestExternalStoragePermission();
//初始化側邊欄菜單項 //初始化側邊欄菜單項
initSideMenu(); initSideMenu();
...@@ -444,6 +450,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -444,6 +450,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
finish(); finish();
} }
@OnClick({R2.id.layout_login_out, R2.id.iv_personal_center, R2.id.tv_restaurant_name}) @OnClick({R2.id.layout_login_out, R2.id.iv_personal_center, R2.id.tv_restaurant_name})
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -492,4 +499,5 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl ...@@ -492,4 +499,5 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
} }
return super.onKeyDown(keyCode, event); return super.onKeyDown(keyCode, event);
} }
} }
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTop" /> android:launchMode="singleTop" />
<service <service
android:name=".service.GetInfoUpdateService" /> android:name=".service.GetInfoUpdateService"
android:enabled="true"
/>
<activity android:name=".ui.activity.HistoryOrderActivity" /> <activity android:name=".ui.activity.HistoryOrderActivity" />
<meta-data <meta-data
android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration" android:name="com.gingersoft.gsa.cloud.globalconfig.GlobalConfiguration"
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
android:networkSecurityConfig="@xml/network_android" android:networkSecurityConfig="@xml/network_android"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".ui.activity.OrderDetailsActivity"></activity>
<activity android:name=".ui.activity.OrderDetailsActivity" />
<activity <activity
android:name=".ui.activity.OtherOrderActivity" android:name=".ui.activity.OtherOrderActivity"
android:label="@string/app_name"> android:label="@string/app_name">
......
package com.gingersoft.gsa.other_order_mode.data.network package com.gingersoft.gsa.other_order_mode.data.network
import android.util.Log
import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService import com.gingersoft.gsa.other_order_mode.data.network.api.WeatherService
import okhttp3.RequestBody import okhttp3.RequestBody
import retrofit2.Call import retrofit2.Call
......
...@@ -148,11 +148,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -148,11 +148,11 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
if (isLoadMore) { if (isLoadMore) {
if (mOrderList[position].value != null) { if (mOrderList[position].value != null) {
mOrderList[position].value!!.addAll(myData) mOrderList[position].value!!.addAll(myData)
mOrderList[position].postValue(mOrderList[position].value)
} }
} else { } else {
mOrderList[position].value = myData mOrderList[position].value = myData
} }
// mOrderList[position].postValue(mOrderList[position].value)
} else { } else {
mOrderList[position].value = null mOrderList[position].value = null
} }
...@@ -161,7 +161,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -161,7 +161,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
} }
} }
//餐廳營業狀態,控制按鈕 //餐廳營業狀態,控制按鈕
var restaurantState = MutableLiveData<Int>() var restaurantState = MutableLiveData<Int>()
...@@ -294,7 +293,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() { ...@@ -294,7 +293,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
listener.invoke(ProductionComplete, code == "1") listener.invoke(ProductionComplete, code == "1")
} }
} }
} }
}, { }, {
listener.invoke(0, false) listener.invoke(0, false)
......
package com.gingersoft.gsa.other_order_mode.service package com.gingersoft.gsa.other_order_mode.service
import android.annotation.SuppressLint
import android.app.* import android.app.*
import android.content.BroadcastReceiver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.IntentFilter
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.media.AudioAttributes import android.media.AudioAttributes
import android.media.AudioManager import android.media.AudioManager
...@@ -11,9 +14,14 @@ import android.os.Binder ...@@ -11,9 +14,14 @@ import android.os.Binder
import android.os.Build import android.os.Build
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import android.view.LayoutInflater
import android.widget.RemoteViews
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication
import com.gingersoft.gsa.cloud.base.utils.okhttpUtils.OkHttp3Utils
import com.gingersoft.gsa.cloud.constans.AppConstans
import com.gingersoft.gsa.cloud.constans.HttpsConstans
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.ui.activity.OtherOrderActivity import com.gingersoft.gsa.other_order_mode.ui.activity.OtherOrderActivity
...@@ -39,6 +47,7 @@ class GetInfoUpdateService : Service() { ...@@ -39,6 +47,7 @@ class GetInfoUpdateService : Service() {
var postCallBack: PostCallBack? = null var postCallBack: PostCallBack? = null
override fun onBind(intent: Intent?): IBinder? { override fun onBind(intent: Intent?): IBinder? {
return MyBind() return MyBind()
} }
...@@ -52,6 +61,8 @@ class GetInfoUpdateService : Service() { ...@@ -52,6 +61,8 @@ class GetInfoUpdateService : Service() {
// 在API11之后构建Notification的方式 // 在API11之后构建Notification的方式
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
createNotificationChannel() createNotificationChannel()
} else {
startNotification()
} }
return super.onStartCommand(intent, flags, startId) return super.onStartCommand(intent, flags, startId)
} }
...@@ -69,7 +80,19 @@ class GetInfoUpdateService : Service() { ...@@ -69,7 +80,19 @@ class GetInfoUpdateService : Service() {
//构建通知渠道 //构建通知渠道
val channel = NotificationChannel(CHANNEL_ID, channelName, importance) val channel = NotificationChannel(CHANNEL_ID, channelName, importance)
channel.description = "New Order Notification" channel.description = "New Order Notification"
//向系统注册通知渠道,注册后不能改变重要性以及其他通知行为
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
startNotification()
}
@SuppressLint("InflateParams")
private fun startNotification() {
val broadcastReceiver = Intent(AppConstans.CLEAR_ORDER_RECEIVING_HEART)
val broadcastIntent = PendingIntent.getBroadcast(this, 10, broadcastReceiver, 0)
// LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
val remoteViews = RemoteViews(packageName, R.layout.layout_order_receiving)
remoteViews.setOnClickPendingIntent(R.id.btn_stop_service, broadcastIntent)
val intent = Intent(this, OtherOrderActivity::class.java) val intent = Intent(this, OtherOrderActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 0, intent, 0) val pendingIntent = PendingIntent.getActivity(this, 0, intent, 0)
...@@ -79,11 +102,10 @@ class GetInfoUpdateService : Service() { ...@@ -79,11 +102,10 @@ class GetInfoUpdateService : Service() {
.setContentTitle("Ricepon Pos")//设置通知标题 .setContentTitle("Ricepon Pos")//设置通知标题
.setContentText("外賣接單服務")//设置通知内容Takeaway order service .setContentText("外賣接單服務")//设置通知内容Takeaway order service
.setContentIntent(pendingIntent) .setContentIntent(pendingIntent)
.setContent(remoteViews)
.setAutoCancel(false) //用户触摸时,自动关闭 .setAutoCancel(false) //用户触摸时,自动关闭
.setOngoing(true)//设置处于运行状态 .setOngoing(true)//设置处于运行状态
//向系统注册通知渠道,注册后不能改变重要性以及其他通知行为 .setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher))
val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
//将服务置于启动状态 NOTIFICATION_ID指的是创建的通知的ID //将服务置于启动状态 NOTIFICATION_ID指的是创建的通知的ID
startForeground(123, builder.build()) startForeground(123, builder.build())
} }
...@@ -98,9 +120,14 @@ class GetInfoUpdateService : Service() { ...@@ -98,9 +120,14 @@ class GetInfoUpdateService : Service() {
} }
} }
private lateinit var mReceiver: ClearHeartBroadcastReceiver
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
val mFilter = IntentFilter(AppConstans.CLEAR_ORDER_RECEIVING_HEART)
mReceiver = ClearHeartBroadcastReceiver()
registerReceiver(mReceiver, mFilter)
InitSocketThread().start() InitSocketThread().start()
isDestroy = false isDestroy = false
} }
...@@ -114,6 +141,7 @@ class GetInfoUpdateService : Service() { ...@@ -114,6 +141,7 @@ 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()
...@@ -260,7 +288,7 @@ class GetInfoUpdateService : Service() { ...@@ -260,7 +288,7 @@ class GetInfoUpdateService : Service() {
// private var sendTime = 0L // private var sendTime = 0L
// 发送心跳包 // 发送心跳包
// private val mHandler = Handler() // private val mHandler = Handler()
// private val heartBeatRunnable = object : Runnable { // private val heartBeatRunnable = object : Runnable {
// override fun run() { // override fun run() {
// if (!isDestroy) { // if (!isDestroy) {
...@@ -280,13 +308,14 @@ class GetInfoUpdateService : Service() { ...@@ -280,13 +308,14 @@ class GetInfoUpdateService : Service() {
// } // }
// } // }
// } // }
private var isDestroy = false private var isDestroy = false
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
Log.e(TAG, "onDestroy") Log.e(TAG, "onDestroy")
isDestroy = true isDestroy = true
unregisterReceiver(mReceiver)
//斷開鏈接
client?.let { client?.let {
mWebSocket?.cancel() mWebSocket?.cancel()
it.dispatcher().cancelAll() it.dispatcher().cancelAll()
...@@ -294,11 +323,23 @@ class GetInfoUpdateService : Service() { ...@@ -294,11 +323,23 @@ class GetInfoUpdateService : Service() {
if (mWebSocket != null) { if (mWebSocket != null) {
mWebSocket!!.send("-1") mWebSocket!!.send("-1")
mWebSocket!!.close(1000, null) mWebSocket!!.close(1000, null)
// mHandler.removeCallbacks(heartBeatRunnable)
} }
RxTimerUtil.cancel() RxTimerUtil.cancel()
//停止服務
stopForeground(true) stopForeground(true)
} }
inner class ClearHeartBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
//清除心跳並關閉service
val requestBody = FormBody.Builder()
.add("restaurantId", GsaCloudApplication.getRestaurantId(this@GetInfoUpdateService).toString() + "")
.build()
OkHttp3Utils.post(HttpsConstans.ROOT_URL + "/member-web/api/restaurant/clearHeartbeat", requestBody)//清除心跳
stopSelf()
}
}
class MsgBean(var type: Int, var token: String) class MsgBean(var type: Int, var token: String)
} }
\ No newline at end of file
...@@ -71,17 +71,13 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -71,17 +71,13 @@ class OrderDetailsActivity : BaseActivity() {
} }
private fun PageViewModel.getOrderDetails(orderId: String, binding: ActivityOrderDetailsBinding) { private fun PageViewModel.getOrderDetails(orderId: String, binding: ActivityOrderDetailsBinding) {
orderDetails.observe(this@OrderDetailsActivity, Observer { orderDetails.observe(this@OrderDetailsActivity, Observer {
skeletonScreen.hide()//隱藏骨架屏 skeletonScreen.hide()//隱藏骨架屏
Log.e("eee", "收到")
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
orderDetails.orderPayType = orderPayType orderDetails.orderPayType = orderPayType
binding.data = orderDetails binding.data = orderDetails
binding.totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble() binding.totalAmount = orderDetails.TOTAL_AMOUNT!!.toDouble()
binding.isSelf = orderDetails.order_type == 7 binding.isSelf = orderDetails.order_type == 7
...@@ -129,7 +125,6 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -129,7 +125,6 @@ class OrderDetailsActivity : BaseActivity() {
orderStatusText = "派送中" orderStatusText = "派送中"
tv_order_state.setTextColor(resources.getColor(R.color.order_state2_color)) tv_order_state.setTextColor(resources.getColor(R.color.order_state2_color))
} }
} }
else -> {//待確認訂單 else -> {//待確認訂單
btnList.add(BtnBuilder().getSureBtn()) btnList.add(BtnBuilder().getSureBtn())
...@@ -160,7 +155,6 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -160,7 +155,6 @@ class OrderDetailsActivity : BaseActivity() {
val orderBtnAdapter = OrderDetailsAdapter(btnList) val orderBtnAdapter = OrderDetailsAdapter(btnList)
rv_order_details_btn.adapter = orderBtnAdapter rv_order_details_btn.adapter = orderBtnAdapter
//--------------------------------------------------------------不同按鈕點擊事件---------------------------------------------------------------------------------------- //--------------------------------------------------------------不同按鈕點擊事件----------------------------------------------------------------------------------------
orderBtnAdapter.setOnItemClickListener { adapter, view, position -> orderBtnAdapter.setOnItemClickListener { adapter, view, position ->
when (btnList[position].type) { when (btnList[position].type) {
...@@ -174,9 +168,20 @@ class OrderDetailsActivity : BaseActivity() { ...@@ -174,9 +168,20 @@ class OrderDetailsActivity : BaseActivity() {
//取消訂單 //取消訂單
cancelOrder(orderDetails) cancelOrder(orderDetails)
BtnBuilder.closingBtn -> { BtnBuilder.closingBtn -> {
val intent = Intent(this@OrderDetailsActivity, PayActivity::class.java) //如果是在線支付的訂單,就直接修改訂單狀態
intent.putExtra("orderDetails", orderDetails) if (orderPayType != 1) {
startActivityForResult(intent, 1001) gsUpdateOrderStatus(orderDetails.ID.toString(), orderDetails.order_type) { status, isSuccess ->
if(isSuccess) {
finish()
} else {
ToastUtils.show(this@OrderDetailsActivity, "結賬失敗")
}
}
} else {
val intent = Intent(this@OrderDetailsActivity, PayActivity::class.java)
intent.putExtra("orderDetails", orderDetails)
startActivityForResult(intent, 1001)
}
} }
else -> { else -> {
showLoading() showLoading()
......
...@@ -2,10 +2,7 @@ package com.gingersoft.gsa.other_order_mode.ui.activity ...@@ -2,10 +2,7 @@ package com.gingersoft.gsa.other_order_mode.ui.activity
import android.animation.ValueAnimator import android.animation.ValueAnimator
import android.app.Dialog import android.app.Dialog
import android.content.ComponentName import android.content.*
import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable import android.graphics.drawable.GradientDrawable
import android.media.AudioAttributes import android.media.AudioAttributes
...@@ -27,6 +24,7 @@ import androidx.viewpager.widget.ViewPager ...@@ -27,6 +24,7 @@ import androidx.viewpager.widget.ViewPager
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
import com.gingersoft.gsa.cloud.constans.AppConstans
import com.gingersoft.gsa.other_order_mode.R import com.gingersoft.gsa.other_order_mode.R
import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding import com.gingersoft.gsa.other_order_mode.databinding.ActivityOtherOrderBinding
import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel import com.gingersoft.gsa.other_order_mode.model.viewModel.PageViewModel
...@@ -70,8 +68,14 @@ class OtherOrderActivity : BaseActivity() { ...@@ -70,8 +68,14 @@ class OtherOrderActivity : BaseActivity() {
private var btnHeight: Float = 0F private var btnHeight: Float = 0F
private var selectPosition = 0 private var selectPosition = 0
lateinit var mReceiver :ClearHeartBroadcastReceiver
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val mFilter = IntentFilter(AppConstans.CLEAR_ORDER_RECEIVING_HEART)
mReceiver = ClearHeartBroadcastReceiver()
registerReceiver(mReceiver, mFilter)
val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order) val binding: ActivityOtherOrderBinding = DataBindingUtil.setContentView(this, R.layout.activity_other_order)
initWebsocket() initWebsocket()
...@@ -94,7 +98,6 @@ class OtherOrderActivity : BaseActivity() { ...@@ -94,7 +98,6 @@ class OtherOrderActivity : BaseActivity() {
selectPosition = position selectPosition = position
} }
}) })
searchMethod(view_pager) searchMethod(view_pager)
initTabs() initTabs()
//餐廳營業信息 //餐廳營業信息
...@@ -283,6 +286,7 @@ class OtherOrderActivity : BaseActivity() { ...@@ -283,6 +286,7 @@ class OtherOrderActivity : BaseActivity() {
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
unregisterReceiver(mReceiver)
unbindService(serviceConnection) unbindService(serviceConnection)
} }
...@@ -456,4 +460,10 @@ class OtherOrderActivity : BaseActivity() { ...@@ -456,4 +460,10 @@ class OtherOrderActivity : BaseActivity() {
// } // }
qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color)) qm_other_order_bar.setBackgroundColor(resources.getColor(R.color.theme_color))
} }
inner class ClearHeartBroadcastReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
finish()
}
}
} }
\ No newline at end of file
...@@ -57,13 +57,13 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan ...@@ -57,13 +57,13 @@ public class PrjService extends Service implements PrintSocketHolder.OnStateChan
super.onCreate(); super.onCreate();
//讀取本地ip打印機 //讀取本地ip打印機
Log.e("eee", "開啟打印服務"); Log.e("eee", "開啟打印服務");
// if (printerDeviceBeans == null) { if (printerDeviceBeans == null) {
// PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this); PrinterDeviceDaoUtils printerDeviceDaoUtils = new PrinterDeviceDaoUtils(this);
// printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean(); printerDeviceBeans = printerDeviceDaoUtils.queryAllPrinterDeviceBean();
// printerDeviceDaoUtils.closeConnection(); printerDeviceDaoUtils.closeConnection();
// } }
// //開始請求 //開始請求
// startGetPrjInfo(); startGetPrjInfo();
} }
@Nullable @Nullable
......
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