Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
eb61db35
Commit
eb61db35
authored
Feb 26, 2021
by
宁斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、長連接通知欄調整
parent
7e27ec13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
18 deletions
+23
-18
component-print/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
+3
-1
library-common/src/main/java/com/gingersoft/gsa/cloud/common/service/DataNotificationService.kt
+20
-17
No files found.
component-print/src/main/java/com/joe/print/mvp/ui/activity/PrintActivity.java
View file @
eb61db35
...
@@ -166,6 +166,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -166,6 +166,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
@Override
public
void
connectionError
(
Exception
e
)
{
public
void
connectionError
(
Exception
e
)
{
printerResult
=
false
;
printerLoadingDialog
.
setStep
(
2
,
PrinterLoadingDialog
.
status_error
,
e
.
getMessage
());
printerLoadingDialog
.
setStep
(
2
,
PrinterLoadingDialog
.
status_error
,
e
.
getMessage
());
}
}
...
@@ -192,6 +193,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -192,6 +193,7 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
@Override
public
void
onPrintError
(
Exception
e
,
int
errorCode
)
{
public
void
onPrintError
(
Exception
e
,
int
errorCode
)
{
printerResult
=
false
;
printerLoadingDialog
.
setStep
(
3
,
PrinterLoadingDialog
.
status_error
,
e
.
getMessage
());
printerLoadingDialog
.
setStep
(
3
,
PrinterLoadingDialog
.
status_error
,
e
.
getMessage
());
}
}
});
});
...
@@ -515,8 +517,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
...
@@ -515,8 +517,8 @@ public class PrintActivity extends BaseActivity<PrintPresenter> implements Print
@Override
@Override
public
void
printSuccess
()
{
public
void
printSuccess
()
{
LoganManager
.
w_printer
(
TAG
,
"printFailure 打印成功"
);
LoganManager
.
w_printer
(
TAG
,
"printFailure 打印成功"
);
CC
.
sendCCResult
(
callId
,
CCResult
.
success
());
killMyself
();
killMyself
();
CC
.
sendCCResult
(
callId
,
CCResult
.
success
());
}
}
@Override
@Override
...
...
library-common/src/main/java/com/gingersoft/gsa/cloud/common/service/DataNotificationService.kt
View file @
eb61db35
...
@@ -132,9 +132,9 @@ class DataNotificationService : Service() {
...
@@ -132,9 +132,9 @@ class DataNotificationService : Service() {
if
(
mCurrConnectionType
==
OPEN_DELIVET_ORDER_CONNECTION
)
{
if
(
mCurrConnectionType
==
OPEN_DELIVET_ORDER_CONNECTION
)
{
// 在API11之后构建Notification的方式
// 在API11之后构建Notification的方式
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
createNotificationChannel
()
createNotificationChannel
(
"Ricepon Pos"
,
"外賣接單服務"
)
}
else
{
}
else
{
startNotification
()
startNotification
(
"Ricepon Pos"
,
"外賣接單服務"
)
}
}
}
}
if
(
isCreate
)
{
if
(
isCreate
)
{
...
@@ -150,7 +150,7 @@ class DataNotificationService : Service() {
...
@@ -150,7 +150,7 @@ class DataNotificationService : Service() {
* 创建通知渠道
* 创建通知渠道
*/
*/
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
fun
createNotificationChannel
()
{
fun
createNotificationChannel
(
title
:
String
,
text
:
String
)
{
if
(!
UserContext
.
newInstance
().
isLogin
)
{
if
(!
UserContext
.
newInstance
().
isLogin
)
{
stopSelf
()
stopSelf
()
return
return
...
@@ -166,11 +166,11 @@ class DataNotificationService : Service() {
...
@@ -166,11 +166,11 @@ class DataNotificationService : Service() {
val
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationManager
=
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
notificationManager
.
createNotificationChannel
(
channel
)
notificationManager
.
createNotificationChannel
(
channel
)
notificationManager
.
cancelAll
()
notificationManager
.
cancelAll
()
startNotification
()
startNotification
(
title
,
text
)
}
}
@SuppressLint
(
"InflateParams"
)
@SuppressLint
(
"InflateParams"
)
private
fun
startNotification
()
{
private
fun
startNotification
(
title
:
String
,
text
:
String
)
{
val
broadcastReceiver
=
Intent
(
AppConstans
.
CLEAR_ORDER_RECEIVING_HEART
)
val
broadcastReceiver
=
Intent
(
AppConstans
.
CLEAR_ORDER_RECEIVING_HEART
)
val
broadcastIntent
=
PendingIntent
.
getBroadcast
(
this
,
10
,
broadcastReceiver
,
0
)
val
broadcastIntent
=
PendingIntent
.
getBroadcast
(
this
,
10
,
broadcastReceiver
,
0
)
val
remoteViews
=
RemoteViews
(
packageName
,
R
.
layout
.
layout_order_receiving
)
val
remoteViews
=
RemoteViews
(
packageName
,
R
.
layout
.
layout_order_receiving
)
...
@@ -187,8 +187,8 @@ class DataNotificationService : Service() {
...
@@ -187,8 +187,8 @@ class DataNotificationService : Service() {
//在创建的通知渠道上发送通知
//在创建的通知渠道上发送通知
val
builder
=
NotificationCompat
.
Builder
(
this
,
CHANNEL_ID
)
val
builder
=
NotificationCompat
.
Builder
(
this
,
CHANNEL_ID
)
builder
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
//设置通知图标
builder
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
//设置通知图标
.
setContentTitle
(
"Ricepon Pos"
)
//设置通知标题
.
setContentTitle
(
title
)
//设置通知标题
.
setContentText
(
"外賣接單服務"
)
//设置通知内容Takeaway order service
.
setContentText
(
text
)
//设置通知内容Takeaway order service
.
setContent
(
remoteViews
)
.
setContent
(
remoteViews
)
.
setContentIntent
(
pendingIntent
)
.
setContentIntent
(
pendingIntent
)
.
setAutoCancel
(
false
)
//用户触摸时,自动关闭
.
setAutoCancel
(
false
)
//用户触摸时,自动关闭
...
@@ -198,12 +198,15 @@ class DataNotificationService : Service() {
...
@@ -198,12 +198,15 @@ class DataNotificationService : Service() {
startForeground
(
123
,
builder
.
build
())
startForeground
(
123
,
builder
.
build
())
}
}
fun
cleanNotification
()
{
fun
restartNotification
()
{
// val notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
//先停止前台服務
// notificationManager.cancelAll()
stopForeground
(
true
)
// notificationManager.cancel(123)
// 在API11之后构建Notification的方式
// //停止前台服務
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
// stopForeground(true)
createNotificationChannel
(
"Ricepon Pos"
,
"打印服務"
)
}
else
{
startNotification
(
"Ricepon Pos"
,
"打印服務"
)
}
}
}
inner
class
MyBind
:
Binder
()
{
inner
class
MyBind
:
Binder
()
{
...
@@ -212,9 +215,9 @@ class DataNotificationService : Service() {
...
@@ -212,9 +215,9 @@ class DataNotificationService : Service() {
set
(
value
)
{
set
(
value
)
{
field
=
value
field
=
value
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
createNotificationChannel
()
createNotificationChannel
(
"Ricepon Pos"
,
"外賣接單服務"
)
}
else
{
}
else
{
startNotification
()
startNotification
(
"Ricepon Pos"
,
"外賣接單服務"
)
}
}
}
}
...
@@ -427,7 +430,7 @@ class DataNotificationService : Service() {
...
@@ -427,7 +430,7 @@ class DataNotificationService : Service() {
private
fun
clearHeart
()
{
private
fun
clearHeart
()
{
val
requestBody
=
FormBody
.
Builder
()
val
requestBody
=
FormBody
.
Builder
()
.
add
(
"restaurantId"
,
RestaurantInfoManager
.
newInstance
().
restaurantId
.
toString
())
.
add
(
"restaurantId"
,
RestaurantInfoManager
.
newInstance
().
restaurantId
.
toString
())
.
build
()
.
build
()
OkHttp3Utils
.
post
(
HttpsConstans
.
ROOT_URL
+
"/member-web/api/restaurant/clearHeartbeat"
,
requestBody
)
OkHttp3Utils
.
post
(
HttpsConstans
.
ROOT_URL
+
"/member-web/api/restaurant/clearHeartbeat"
,
requestBody
)
.
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
.
subscribeOn
(
Schedulers
.
io
()).
subscribe
()
...
@@ -437,7 +440,7 @@ class DataNotificationService : Service() {
...
@@ -437,7 +440,7 @@ class DataNotificationService : Service() {
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
//關閉service,會調用service的onDestroy
//關閉service,會調用service的onDestroy
// stopSelf()
// stopSelf()
clean
Notification
()
restart
Notification
()
mCurrConnectionType
=
OPEN_OTHER_CONNECTION
;
mCurrConnectionType
=
OPEN_OTHER_CONNECTION
;
send
(
mCurrConnectionType
)
send
(
mCurrConnectionType
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment