Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
1decd3ad
Commit
1decd3ad
authored
Apr 30, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add network check on start downloading
parent
56000b6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
2 deletions
+50
-2
StartPlansDownloadingDialogController.kt
...onductor/dialogs/StartPlansDownloadingDialogController.kt
+11
-0
StartToursDownloadingDialogController.kt
...ogs/tour_chooser/StartToursDownloadingDialogController.kt
+12
-0
LiveNetworkMonitor.kt
...isual/roompark/data/service/network/LiveNetworkMonitor.kt
+5
-2
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+3
-0
DataModule.kt
.../java/com/biganto/visual/roompark/di/dagger/DataModule.kt
+7
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+12
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/StartPlansDownloadingDialogController.kt
View file @
1decd3ad
...
...
@@ -14,6 +14,7 @@ import com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.network.INetworkMonitor
import
com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
...
...
@@ -68,6 +69,9 @@ class StartPlansDownloadingDialogController : Controller {
@Inject
lateinit
var
rpActivity
:
RoomParkMainActivity
@Inject
lateinit
var
networkMonitor
:
INetworkMonitor
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
...
...
@@ -120,6 +124,13 @@ class StartPlansDownloadingDialogController : Controller {
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
map
{
if
(!
networkMonitor
.
isConnected
){
snackbar
.
showSnackBar
(
R
.
string
.
no_network_error
)
return
@map
null
}
else
return
@map
it
}
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
...
...
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/StartToursDownloadingDialogController.kt
View file @
1decd3ad
...
...
@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.network.INetworkMonitor
import
com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
...
...
@@ -64,6 +65,10 @@ class StartToursDownloadingDialogController : Controller {
@Inject
lateinit
var
rpActivity
:
RoomParkMainActivity
@Inject
lateinit
var
networkMonitor
:
INetworkMonitor
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
...
...
@@ -111,6 +116,13 @@ class StartToursDownloadingDialogController : Controller {
detachDisposable
.
add
(
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
map
{
if
(!
networkMonitor
.
isConnected
){
snackbar
.
showSnackBar
(
R
.
string
.
no_network_error
)
return
@map
null
}
else
return
@map
it
}
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
Schedulers
.
io
())
.
flatMap
{
downloader
.
startToursDownloading
()}
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/network/LiveNetworkMonitor.kt
View file @
1decd3ad
package
com.biganto.visual.roompark.data.service.network
import
android.app.Application
import
android.content.Context
import
android.net.ConnectivityManager
import
javax.inject.Inject
import
javax.inject.Singleton
...
...
@@ -9,7 +11,7 @@ import javax.inject.Singleton
* Created by Vladislav Bogdashkin on 12.10.2018.
*/
@Singleton
class
LiveNetworkMonitor
(
val
context
:
Context
)
:
INetworkMonitor
{
class
LiveNetworkMonitor
@Inject
constructor
(
val
context
:
Application
)
:
INetworkMonitor
{
override
val
isConnected
:
Boolean
...
...
@@ -23,7 +25,8 @@ class LiveNetworkMonitor(val context: Context) : INetworkMonitor {
override
val
isWifiConnected
:
Boolean
get
()
{
val
cm
=
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
)
as
ConnectivityManager
return
cm
.
activeNetworkInfo
!=
null
&&
(
cm
.
activeNetworkInfo
.
type
==
ConnectivityManager
.
TYPE_WIFI
);
return
cm
.
activeNetworkInfo
!=
null
&&
(
cm
.
activeNetworkInfo
.
type
==
ConnectivityManager
.
TYPE_WIFI
);
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
View file @
1decd3ad
...
...
@@ -11,6 +11,7 @@ import com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
import
com.biganto.visual.roompark.data.service.network.INetworkMonitor
import
com.biganto.visual.roompark.data.service.notification.INotificationCenter
import
com.biganto.visual.roompark.domain.contract.*
import
dagger.BindsInstance
...
...
@@ -72,6 +73,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun
provideNotifivations
():
INotificationCenter
fun
provideNetMonitor
():
INetworkMonitor
fun
provideAppContext
():
Application
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/DataModule.kt
View file @
1decd3ad
...
...
@@ -12,6 +12,8 @@ import com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.db.requrey.RequeryRepository
import
com.biganto.visual.roompark.data.service.lifecycle.AppLifecycleListener
import
com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
import
com.biganto.visual.roompark.data.service.network.INetworkMonitor
import
com.biganto.visual.roompark.data.service.network.LiveNetworkMonitor
import
com.biganto.visual.roompark.data.service.notification.INotificationCenter
import
com.biganto.visual.roompark.data.service.notification.NotificationCenter
import
com.biganto.visual.roompark.domain.contract.*
...
...
@@ -92,4 +94,9 @@ abstract class DataModule {
@Binds
abstract
fun
provideDb
(
db
:
RequeryRepository
)
:
IDb
@Singleton
@Binds
abstract
fun
provideNetwork
(
networkMonitor
:
LiveNetworkMonitor
)
:
INetworkMonitor
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
1decd3ad
...
...
@@ -16,6 +16,7 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.StartPlansDownloadingDialogController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.tour_chooser.StartToursDownloadingDialogController
import
com.biganto.visual.roompark.data.service.network.INetworkMonitor
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
...
...
@@ -109,8 +110,15 @@ class SettingsScreenController :
@BindView
(
R
.
id
.
progress_lock_background
)
lateinit
var
progressShame
:
View
@Inject
lateinit
var
networkMonitor
:
INetworkMonitor
@OnClick
(
R
.
id
.
downloadFlatCardsIcon
)
fun
onStartTourPlans
(){
if
(!
networkMonitor
.
isConnected
){
snackbar
.
showSnackBar
(
R
.
string
.
no_network_error
)
return
}
router
.
pushController
(
RouterTransaction
.
with
(
StartPlansDownloadingDialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
...
...
@@ -131,6 +139,10 @@ class SettingsScreenController :
@OnClick
(
R
.
id
.
downloadToursIcon
)
fun
startDownloadingDialog
(){
if
(!
networkMonitor
.
isConnected
){
snackbar
.
showSnackBar
(
R
.
string
.
no_network_error
)
return
}
router
.
pushController
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
...
...
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