Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hotspot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
hotspot
Commits
94b245e9
Commit
94b245e9
authored
4 years ago
by
Sebastian Kürten
Browse files
Options
Downloads
Patches
Plain Diff
Improve concurrency safety
parent
747a85b5
No related branches found
No related tags found
1 merge request
!6
ViewModel cleanup
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+4
-2
4 additions, 2 deletions
...src/main/java/org/briarproject/hotspot/MainViewModel.java
app/src/main/java/org/briarproject/hotspot/WebServerManager.java
+12
-6
12 additions, 6 deletions
.../main/java/org/briarproject/hotspot/WebServerManager.java
with
16 additions
and
8 deletions
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+
4
−
2
View file @
94b245e9
...
...
@@ -11,6 +11,7 @@ import org.briarproject.hotspot.HotspotState.StartingHotspot;
import
java.util.logging.Logger
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.UiThread
;
import
androidx.lifecycle.AndroidViewModel
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
...
...
@@ -110,17 +111,18 @@ public class MainViewModel extends AndroidViewModel
@Override
public
void
onWebServerStarted
()
{
webServerStatus
.
s
e
tValue
(
STARTED
);
webServerStatus
.
po
stValue
(
STARTED
);
}
@Override
@UiThread
public
void
onWebServerStopped
()
{
webServerStatus
.
setValue
(
STOPPED
);
}
@Override
public
void
onWebServerError
()
{
webServerStatus
.
s
e
tValue
(
ERROR
);
webServerStatus
.
po
stValue
(
ERROR
);
}
}
This diff is collapsed.
Click to expand it.
app/src/main/java/org/briarproject/hotspot/WebServerManager.java
+
12
−
6
View file @
94b245e9
...
...
@@ -5,6 +5,8 @@ import android.content.Context;
import
java.io.IOException
;
import
java.util.logging.Logger
;
import
androidx.annotation.UiThread
;
import
static
java
.
util
.
logging
.
Level
.
WARNING
;
import
static
java
.
util
.
logging
.
Logger
.
getLogger
;
import
static
org
.
briarproject
.
hotspot
.
LogUtils
.
logException
;
...
...
@@ -15,6 +17,7 @@ class WebServerManager {
void
onWebServerStarted
();
@UiThread
void
onWebServerStopped
();
void
onWebServerError
();
...
...
@@ -33,13 +36,16 @@ class WebServerManager {
}
void
startWebServer
()
{
try
{
webServer
.
start
();
// TODO: offload this to the IoExecutor
new
Thread
(()
->
{
try
{
webServer
.
start
();
}
catch
(
IOException
e
)
{
logException
(
LOG
,
WARNING
,
e
);
listener
.
onWebServerError
();
}
listener
.
onWebServerStarted
();
}
catch
(
IOException
e
)
{
logException
(
LOG
,
WARNING
,
e
);
listener
.
onWebServerError
();
}
}).
start
();
}
void
stopWebServer
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment