|
|
@@ -1,16 +1,33 @@
|
|
|
package com.jld.vod.view
|
|
|
|
|
|
+import android.app.Notification
|
|
|
+import android.app.NotificationManager
|
|
|
+import android.app.PendingIntent
|
|
|
+import android.content.Context
|
|
|
+import android.content.Intent
|
|
|
+import android.graphics.Bitmap
|
|
|
+import android.os.Handler
|
|
|
+import android.view.WindowManager
|
|
|
import android.widget.ImageView
|
|
|
import com.jld.vod.R
|
|
|
import com.jld.vod.base.BaseActivity
|
|
|
+import com.jld.vod.model.bean.PositionAdvertBean
|
|
|
+import com.jld.vod.model.event.NewOrderEvent
|
|
|
+import com.jld.vod.service.LatLongService
|
|
|
+import com.jld.vod.utils.LogUtils
|
|
|
+import com.jld.vod.utils.SharedPrefUtils
|
|
|
+import com.jld.vod.view.widget.CustomAdDialog
|
|
|
import com.xuexiang.xpage.enums.CoreAnim
|
|
|
import com.xuexiang.xui.widget.tabbar.EasyIndicator
|
|
|
import com.xuexiang.xui.widget.tabbar.EasyIndicator.onTabClickListener
|
|
|
import com.xuexiang.xutil.tip.ToastUtils
|
|
|
+import org.greenrobot.eventbus.EventBus
|
|
|
+import org.greenrobot.eventbus.Subscribe
|
|
|
|
|
|
class HostOrderActivity : BaseActivity() {
|
|
|
private lateinit var iv_order_back:ImageView
|
|
|
private lateinit var mEasyIndicator1: EasyIndicator
|
|
|
+ private val mHandler = Handler()
|
|
|
|
|
|
override fun getLayoutId(): Int {
|
|
|
return R.layout.activity_host_order
|
|
|
@@ -18,6 +35,7 @@ class HostOrderActivity : BaseActivity() {
|
|
|
|
|
|
override fun initView() {
|
|
|
super.initView()
|
|
|
+ EventBus.getDefault().register(this)
|
|
|
iv_order_back = findViewById(R.id.iv_order_back)
|
|
|
mEasyIndicator1 = findViewById(R.id.easy_indicator1)
|
|
|
openPage("HostAllOrdersFragment", null, CoreAnim.none,false)
|
|
|
@@ -52,4 +70,62 @@ class HostOrderActivity : BaseActivity() {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 接收新订单通知
|
|
|
+ */
|
|
|
+ @Subscribe
|
|
|
+ fun onReceive( mNewOrderEvent :NewOrderEvent) {
|
|
|
+ if (mNewOrderEvent.data != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ val neworder = SharedPrefUtils.getString(this,"neworder")
|
|
|
+ if (neworder != mNewOrderEvent.data)
|
|
|
+ {
|
|
|
+ LogUtils.logD("我收到了消息"+mNewOrderEvent.data)
|
|
|
+ addNotification()
|
|
|
+
|
|
|
+ mHandler.postDelayed(Runnable {
|
|
|
+ cleanNotification()
|
|
|
+ },3000)
|
|
|
+
|
|
|
+ }
|
|
|
+ SharedPrefUtils.putString(this,"neworder",mNewOrderEvent.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onDestroy() {
|
|
|
+ super.onDestroy()
|
|
|
+ EventBus.getDefault().unregister(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新订单通知
|
|
|
+ * @param pat
|
|
|
+ */
|
|
|
+ private fun addNotification() {
|
|
|
+ val intent = getIntent()
|
|
|
+ val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)
|
|
|
+ val noti =
|
|
|
+ Notification.Builder(this) // .setTicker("你懂的!")
|
|
|
+ .setContentTitle(getString(R.string.neworders))
|
|
|
+ .setSmallIcon(R.mipmap.maps_dialog) //设置图标
|
|
|
+ .setDefaults(Notification.DEFAULT_SOUND) //设置声音
|
|
|
+ .setContentIntent(pendingIntent) //点击之后的页面
|
|
|
+ .setFullScreenIntent(pendingIntent, true)
|
|
|
+ .build()
|
|
|
+ val manager =
|
|
|
+ this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
|
+ manager.notify(666, noti)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消新订单通知
|
|
|
+ */
|
|
|
+ private fun cleanNotification() {
|
|
|
+ val manager =
|
|
|
+ getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
|
+ manager.cancel(R.mipmap.ic_launcher)
|
|
|
+ manager.cancel(666)
|
|
|
+ }
|
|
|
}
|