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
0212e3ab
Verified
Commit
0212e3ab
authored
4 years ago
by
Torsten Grote
Browse files
Options
Downloads
Patches
Plain Diff
Turn ViewModel into an AndroidViewModel
parent
549da2da
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Add web server for app downloading and small fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+16
-14
16 additions, 14 deletions
...src/main/java/org/briarproject/hotspot/MainViewModel.java
with
16 additions
and
14 deletions
app/src/main/java/org/briarproject/hotspot/MainViewModel.java
+
16
−
14
View file @
0212e3ab
...
...
@@ -10,9 +10,10 @@ import android.net.wifi.p2p.WifiP2pManager.Channel;
import
android.net.wifi.p2p.WifiP2pManager.GroupInfoListener
;
import
android.os.Handler
;
import
androidx.annotation.NonNull
;
import
androidx.lifecycle.AndroidViewModel
;
import
androidx.lifecycle.LiveData
;
import
androidx.lifecycle.MutableLiveData
;
import
androidx.lifecycle.ViewModel
;
import
static
android
.
content
.
Context
.
WIFI_P2P_SERVICE
;
import
static
android
.
content
.
Context
.
WIFI_SERVICE
;
...
...
@@ -20,29 +21,30 @@ import static android.net.wifi.WifiManager.WIFI_MODE_FULL;
import
static
android
.
net
.
wifi
.
WifiManager
.
WIFI_MODE_FULL_HIGH_PERF
;
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
public
class
MainViewModel
extends
ViewModel
{
public
class
MainViewModel
extends
Android
ViewModel
{
private
static
final
int
MAX_GROUP_INFO_ATTEMPTS
=
5
;
private
final
MutableLiveData
<
NetworkConfig
>
config
=
new
MutableLiveData
<>();
private
final
MutableLiveData
<
String
>
status
=
new
MutableLiveData
<>();
private
Application
app
;
private
String
lockTag
;
private
WifiManager
wifiManager
;
private
WifiP2pManager
wifiP2pManager
;
private
Handler
handler
;
private
final
Application
app
;
private
final
String
lockTag
;
private
final
WifiManager
wifiManager
;
private
final
WifiP2pManager
wifiP2pManager
;
private
final
Handler
handler
;
private
WifiLock
wifiLock
;
private
Channel
channel
;
void
setApplication
(
Application
app
)
{
this
.
app
=
app
;
lockTag
=
app
.
getString
(
R
.
string
.
app_name
);
wifiManager
=
(
WifiManager
)
app
.
getSystemService
(
WIFI_SERVICE
);
wifiP2pManager
=
(
WifiP2pManager
)
app
.
getSystemService
(
WIFI_P2P_SERVICE
);
handler
=
new
Handler
(
app
.
getMainLooper
());
}
public
MainViewModel
(
@NonNull
Application
application
)
{
super
(
application
);
app
=
application
;
lockTag
=
app
.
getString
(
R
.
string
.
app_name
);
wifiManager
=
(
WifiManager
)
app
.
getSystemService
(
WIFI_SERVICE
);
wifiP2pManager
=
(
WifiP2pManager
)
app
.
getSystemService
(
WIFI_P2P_SERVICE
);
handler
=
new
Handler
(
app
.
getMainLooper
());
}
LiveData
<
NetworkConfig
>
getWifiConfiguration
()
{
return
config
;
...
...
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