Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
P
PDF Viewer Scanner White
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
PDF Viewer Scanner White
Commits
8510c038
Commit
8510c038
authored
Nov 06, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
workmanager
parent
c011d238
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
1 deletion
+50
-1
build.gradle.kts
app/build.gradle.kts
+4
-1
PopupConstObject.kt
...va/com/base/pdfviewerscannerwhite/fcm/PopupConstObject.kt
+1
-0
MyApplication.kt
...va/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
+3
-0
RepeatingWorker.kt
...va/com/base/pdfviewerscannerwhite/work/RepeatingWorker.kt
+42
-0
No files found.
app/build.gradle.kts
View file @
8510c038
...
...
@@ -134,5 +134,8 @@ dependencies {
//mintegral
implementation
(
"com.reyun.solar.engine.oversea:solar-engine-core:1.2.8.3"
)
//work
implementation
(
"androidx.work:work-runtime-ktx:2.7.1"
)
// 请使用最新版本
}
}
\ No newline at end of file
app/src/main/java/com/base/pdfviewerscannerwhite/fcm/PopupConstObject.kt
View file @
8510c038
...
...
@@ -7,6 +7,7 @@ object PopupConstObject {
const
val
POPUP_WHERE_TIMBER
=
"Timer"
const
val
POPUP_WHERE_LOCK
=
"Lock"
const
val
POPUP_WHERE_FCM
=
"fcm"
const
val
POPUP_WHERE_WORK_MANAGER
=
"workmanager"
const
val
POPUP_WHERE_MEDIA_CHANGE
=
"media_change"
const
val
POPUP_WHERE_HOVER_HANDLE
=
"hover_handle"
//悬停调用
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/helper/MyApplication.kt
View file @
8510c038
...
...
@@ -15,6 +15,7 @@ import com.base.pdfviewerscannerwhite.utils.ActivityManagerUtils
import
com.base.pdfviewerscannerwhite.utils.AppPreferences
import
com.base.pdfviewerscannerwhite.utils.KotlinExt.toFormatMinute
import
com.base.pdfviewerscannerwhite.utils.LogEx
import
com.base.pdfviewerscannerwhite.work.schedulePeriodicWork
import
com.facebook.FacebookSdk
import
com.reyun.solar.engine.OnAttributionListener
import
com.reyun.solar.engine.OnInitializationCallback
...
...
@@ -58,6 +59,8 @@ class MyApplication : Application() {
initApp
()
PDFBoxResourceLoader
.
init
(
applicationContext
)
initWeather
()
schedulePeriodicWork
(
this
)
}
private
fun
initWeather
()
{
...
...
app/src/main/java/com/base/pdfviewerscannerwhite/work/RepeatingWorker.kt
0 → 100644
View file @
8510c038
package
com.base.pdfviewerscannerwhite.work
import
android.content.Context
import
androidx.work.Constraints
import
androidx.work.ExistingPeriodicWorkPolicy
import
androidx.work.NetworkType
import
androidx.work.PeriodicWorkRequestBuilder
import
androidx.work.WorkManager
import
androidx.work.Worker
import
androidx.work.WorkerParameters
import
com.base.pdfviewerscannerwhite.fcm.NotificationUiUtil.getNextActionId
import
com.base.pdfviewerscannerwhite.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.pdfviewerscannerwhite.fcm.PopupConstObject
import
com.base.pdfviewerscannerwhite.helper.EventUtils
import
java.util.concurrent.TimeUnit
fun
schedulePeriodicWork
(
context
:
Context
)
{
val
request
=
PeriodicWorkRequestBuilder
<
RepeatingWorker
>(
15
,
TimeUnit
.
MINUTES
)
.
setConstraints
(
Constraints
.
Builder
().
setRequiredNetworkType
(
NetworkType
.
CONNECTED
).
build
()
)
.
build
()
WorkManager
.
getInstance
(
context
).
enqueueUniquePeriodicWork
(
"uniqueWorkName"
,
ExistingPeriodicWorkPolicy
.
KEEP
,
request
)
}
class
RepeatingWorker
(
val
appContext
:
Context
,
workerParams
:
WorkerParameters
)
:
Worker
(
appContext
,
workerParams
)
{
override
fun
doWork
():
Result
{
// 这里执行你的任务
// 例如,更新UI,发送网络请求等
EventUtils
.
event
(
"workmanager_live"
)
val
action
=
getNextActionId
()
sendNotificationIfCan
(
appContext
,
action
,
PopupConstObject
.
POPUP_WHERE_WORK_MANAGER
)
return
Result
.
success
()
}
}
\ No newline at end of file
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