Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6257d72d
authored
May 08, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加Worker线程池的自定义配置项,避免开启过多的无用线程
parent
25997146
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
3 deletions
+23
-3
app/src/main/AndroidManifest.xml
+9
-1
app/src/main/java/com/bgycc/smartcanteen/RootApp.java
+13
-1
app/src/main/java/com/bgycc/smartcanteen/executor/DefaultTaskExecutor.java
+1
-1
No files found.
app/src/main/AndroidManifest.xml
View file @
6257d72d
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
package=
"com.bgycc.smartcanteen"
>
package=
"com.bgycc.smartcanteen"
>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
<uses-permission
android:name=
"android.permission.RECEIVE_BOOT_COMPLETED"
/>
...
@@ -23,7 +24,8 @@
...
@@ -23,7 +24,8 @@
android:theme=
"@style/AppTheme"
>
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".activity.MainActivity"
<activity
android:name=
".activity.MainActivity"
android:launchMode=
"singleInstance"
android:launchMode=
"singleInstance"
android:screenOrientation=
"landscape"
>
android:screenOrientation=
"landscape"
tools:ignore=
"LockedOrientationActivity"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
...
@@ -50,6 +52,11 @@
...
@@ -50,6 +52,11 @@
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
<action
android:name=
"android.intent.action.BOOT_COMPLETED"
/>
</intent-filter>
</intent-filter>
</receiver>
</receiver>
<provider
android:name=
"androidx.work.impl.WorkManagerInitializer"
android:authorities=
"${applicationId}.workmanager-init"
tools:node=
"remove"
android:exported=
"false"
/>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/bgycc/smartcanteen/RootApp.java
View file @
6257d72d
...
@@ -2,6 +2,10 @@ package com.bgycc.smartcanteen;
...
@@ -2,6 +2,10 @@ package com.bgycc.smartcanteen;
import
android.app.Application
;
import
android.app.Application
;
import
androidx.annotation.NonNull
;
import
androidx.work.Configuration
;
import
com.bgycc.smartcanteen.executor.SCTaskExecutor
;
import
com.blankj.utilcode.util.CrashUtils
;
import
com.blankj.utilcode.util.CrashUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.LogUtils
;
import
com.blankj.utilcode.util.PathUtils
;
import
com.blankj.utilcode.util.PathUtils
;
...
@@ -9,7 +13,7 @@ import com.blankj.utilcode.util.Utils;
...
@@ -9,7 +13,7 @@ import com.blankj.utilcode.util.Utils;
import
java.io.File
;
import
java.io.File
;
public
class
RootApp
extends
Application
{
public
class
RootApp
extends
Application
implements
Configuration
.
Provider
{
private
static
final
String
LOG_PREFIX
=
"app"
;
private
static
final
String
LOG_PREFIX
=
"app"
;
private
static
final
String
LOG_DIR
=
"log"
;
private
static
final
String
LOG_DIR
=
"log"
;
...
@@ -25,4 +29,12 @@ public class RootApp extends Application {
...
@@ -25,4 +29,12 @@ public class RootApp extends Application {
.
setBorderSwitch
(
false
)
.
setBorderSwitch
(
false
)
.
setFilePrefix
(
LOG_PREFIX
);
.
setFilePrefix
(
LOG_PREFIX
);
}
}
@NonNull
@Override
public
Configuration
getWorkManagerConfiguration
()
{
return
new
Configuration
.
Builder
()
.
setExecutor
(
SCTaskExecutor
.
getIOThreadExecutor
())
.
build
();
}
}
}
app/src/main/java/com/bgycc/smartcanteen/executor/DefaultTaskExecutor.java
View file @
6257d72d
...
@@ -22,7 +22,7 @@ public class DefaultTaskExecutor extends TaskExecutor {
...
@@ -22,7 +22,7 @@ public class DefaultTaskExecutor extends TaskExecutor {
private
final
Object
mLock
=
new
Object
();
private
final
Object
mLock
=
new
Object
();
private
final
ScheduledExecutorService
mThread
=
Executors
.
newScheduledThreadPool
(
6
,
new
ThreadFactory
()
{
private
final
ScheduledExecutorService
mThread
=
Executors
.
newScheduledThreadPool
(
6
,
new
ThreadFactory
()
{
private
static
final
String
THREAD_NAME_STEM
=
"
mqtt_t
hread_%d"
;
private
static
final
String
THREAD_NAME_STEM
=
"
SmartCanteen_T
hread_%d"
;
private
final
AtomicInteger
mThreadId
=
new
AtomicInteger
(
0
);
private
final
AtomicInteger
mThreadId
=
new
AtomicInteger
(
0
);
...
...
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