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
463ed781
Commit
463ed781
authored
Apr 22, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache update info etc
parent
d9a1127f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
23 deletions
+58
-23
StartToursDownloadingDialogController.kt
...ogs/tour_chooser/StartToursDownloadingDialogController.kt
+16
-5
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+7
-2
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+3
-3
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+30
-9
tours_download_dialog_screen.xml
app/src/main/res/layout/tours_download_dialog_screen.xml
+2
-4
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/StartToursDownloadingDialogController.kt
View file @
463ed781
...
@@ -28,6 +28,7 @@ import dagger.Component
...
@@ -28,6 +28,7 @@ import dagger.Component
import
dagger.Module
import
dagger.Module
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -43,7 +44,7 @@ class StartToursDownloadingDialogController : Controller {
...
@@ -43,7 +44,7 @@ class StartToursDownloadingDialogController : Controller {
constructor
(
args
:
Bundle
)
:
super
(
args
)
constructor
(
args
:
Bundle
)
:
super
(
args
)
constructor
(
size
:
Long
)
:
super
(
Bundle
().
apply
{
putLong
(
TOTAL_SIZE_DOWNLOAD_KEY
,
size
)
}
)
constructor
(
size
:
Long
)
:
super
(
Bundle
().
apply
{
putLong
(
TOTAL_SIZE_DOWNLOAD_KEY
,
size
)
}
)
private
val
detachDisposable
=
CompositeDisposable
()
private
val
detachDisposable
=
CompositeDisposable
()
...
@@ -98,10 +99,20 @@ class StartToursDownloadingDialogController : Controller {
...
@@ -98,10 +99,20 @@ class StartToursDownloadingDialogController : Controller {
detachDisposable
.
add
(
detachDisposable
.
add
(
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
clicks
()
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
Schedulers
.
io
())
.
flatMap
{
downloader
.
startToursDownloading
()
// .subscribeOn(Schedulers.computation())
.
doOnComplete
{
Timber
.
d
(
" C "
)
}
}
.
doOnComplete
{
Timber
.
d
(
" X "
)
}
// .subscribeOn(AndroidSchedulers.mainThread())
.
doOnComplete
{
Timber
.
d
(
" Xss "
)
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
flatMapCompletable
{
downloader
.
startToursDownloading
()
}
.
subscribe
({
.
subscribe
({
Timber
.
d
(
" SUBSCRIBER "
)
snackbar
.
showSnackBar
(
R
.
string
.
download_all_tours_start_snackbar_message
)
snackbar
.
showSnackBar
(
R
.
string
.
download_all_tours_start_snackbar_message
)
handleBack
()
handleBack
()
},{
},{
...
@@ -112,8 +123,8 @@ class StartToursDownloadingDialogController : Controller {
...
@@ -112,8 +123,8 @@ class StartToursDownloadingDialogController : Controller {
)
)
)
)
//
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view
.
findViewById
<
View
>(
R
.
id
.
close_current_button
).
setOnClickListener
{
handleBack
()
}
view
.
setOnClickListener
{
handleBack
()
}
//
view.setOnClickListener { handleBack() }
return
view
return
view
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
463ed781
...
@@ -67,14 +67,19 @@ class SettingsInteractor @Inject constructor(
...
@@ -67,14 +67,19 @@ class SettingsInteractor @Inject constructor(
}
}
}
}
fun
startToursDownloading
()
:
Completable
=
fun
startToursDownloading
()
=
toursUc
.
downloadAllDeelsAndEstates
()
toursUc
.
downloadAllDeelsAndEstates
()
.
doOnNext
{
Timber
.
d
(
" gonna startService"
)
}
.
doOnNext
{
Timber
.
d
(
" gonna startService"
)
}
.
doOnNext
{
this
.
startDownloadService
()
}
.
doOnNext
{
this
.
startDownloadService
()
}
.
delay
(
100
,
TimeUnit
.
MILLISECONDS
)
.
delay
(
100
,
TimeUnit
.
MILLISECONDS
)
.
doOnNext
{
Timber
.
d
(
" gonna startServic222e"
)
}
.
doOnNext
{
tours
->
.
doOnNext
{
tours
->
startDownloadService
(
tours
.
map
{
tour
->
tour
.
id
})
startDownloadService
(
tours
.
map
{
tour
->
tour
.
id
})
}.
ignoreElements
()
}
.
doOnNext
{
Timber
.
d
(
" gonna startServsdfsfdsice"
)
}
// .doOnComplete { Timber.w(" azzaza complete") }
fun
getSubscriptions
()
=
fun
getSubscriptions
()
=
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
463ed781
...
@@ -132,9 +132,9 @@ class SettingsScreenController :
...
@@ -132,9 +132,9 @@ class SettingsScreenController :
@OnClick
(
R
.
id
.
downloadToursIcon
)
@OnClick
(
R
.
id
.
downloadToursIcon
)
fun
startDownloadingDialog
(){
fun
startDownloadingDialog
(){
router
.
setRoot
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
(
tempToursSize
))
router
.
pushController
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
(
tempToursSize
))
.
pushChangeHandler
(
Fade
ChangeHandler
())
.
pushChangeHandler
(
Dialog
ChangeHandler
())
.
popChangeHandler
(
Fade
ChangeHandler
())
.
popChangeHandler
(
Dialog
ChangeHandler
())
)
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
463ed781
...
@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.domain.model.CachedDataModel
...
@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.jakewharton.rxrelay2.PublishRelay
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
import
io.reactivex.schedulers.Schedulers
...
@@ -37,14 +38,26 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -37,14 +38,26 @@ class SettingsScreenPresenter @Inject constructor(
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
SettingsScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
SettingsScreenViewState
.
SomeError
(
e
)
}
override
fun
bindIntents
()
{
private
val
cacheSizeRefresher
=
PublishRelay
.
create
<
Int
>()
private
val
cahcObs
=
cacheSizeRefresher
.
flatMap
{
Observable
.
merge
(
arrayListOf
(
fetchToursSize
,
fetchPlansSize
)
)
}
val
fetchToursSize
=
interactor
.
fetchToursSizes
()
private
val
fetchToursSize
:
Observable
<
SettingsScreenViewState
>
=
interactor
.
fetchToursSizes
()
.
map
{
SettingsScreenViewState
.
OnSizePrefetch
(
it
)
}
.
map
{
SettingsScreenViewState
.
OnSizePrefetch
(
it
)
}
private
val
fetchPlansSize
:
Observable
<
SettingsScreenViewState
>
=
interactor
.
fetchPlanTypesSizes
()
.
map
{
it
*
TYPICAL_PLAN_SIZE
}
.
map
{
SettingsScreenViewState
.
OnPlanTypesPrefetch
(
it
)
}
override
fun
bindIntents
()
{
val
fetchPlansSize
=
interactor
.
fetchPlanTypesSizes
()
.
map
{
it
*
TYPICAL_PLAN_SIZE
}
.
map
{
SettingsScreenViewState
.
OnPlanTypesPrefetch
(
it
)
}
// val onDownloadTours = intent(SettingsScreen::downloadAllTours)
// val onDownloadTours = intent(SettingsScreen::downloadAllTours)
// .flatMap { interactor.startToursDownloading()
// .flatMap { interactor.startToursDownloading()
...
@@ -88,6 +101,7 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -88,6 +101,7 @@ class SettingsScreenPresenter @Inject constructor(
.
doOnNext
{
cached
->
cached
.
sortBy
{
it
.
id
}
}
.
doOnNext
{
cached
->
cached
.
sortBy
{
it
.
id
}
}
.
doOnNext
{
restoreModel
.
cacheInfo
=
it
}
.
doOnNext
{
restoreModel
.
cacheInfo
=
it
}
.
map
{
SettingsScreenViewState
.
LoadCachInfo
(
it
)
}
.
map
{
SettingsScreenViewState
.
LoadCachInfo
(
it
)
}
.
doOnNext
{
cacheSizeRefresher
.
accept
(
1
)
}
val
fetchSubscriptions
=
interactor
.
getSubscriptions
()
val
fetchSubscriptions
=
interactor
.
getSubscriptions
()
.
doOnNext
{
restoreModel
.
subs
=
it
.
toMutableList
()
}
.
doOnNext
{
restoreModel
.
subs
=
it
.
toMutableList
()
}
...
@@ -109,28 +123,35 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -109,28 +123,35 @@ class SettingsScreenPresenter @Inject constructor(
interactor
.
deleteCacheFiles
()
interactor
.
deleteCacheFiles
()
.
map
<
SettingsScreenViewState
>
{
.
map
<
SettingsScreenViewState
>
{
Timber
.
d
(
" got progress: ${it.first} / ${it.second.toFloat()}"
)
Timber
.
d
(
" got progress: ${it.first} / ${it.second.toFloat()}"
)
if
(
it
.
first
==
it
.
second
)
cacheSizeRefresher
.
accept
(
1
)
SettingsScreenViewState
.
OnCacheDeleting
(
SettingsScreenViewState
.
OnCacheDeleting
(
it
.
first
/
it
.
second
.
toFloat
()
it
.
first
/
it
.
second
.
toFloat
()
)
)
}
}
.
delay
(
600
,
TimeUnit
.
MILLISECONDS
)
.
delay
(
600
,
TimeUnit
.
MILLISECONDS
)
.
startWith
(
SettingsScreenViewState
.
OnCacheDeleting
(
0f
))
.
startWith
(
SettingsScreenViewState
.
OnCacheDeleting
(
0f
))
.
doOnError
{
Timber
.
e
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
.
subscribeOn
(
Schedulers
.
io
())
}
}
val
state
=
Observable
.
mergeDelayError
(
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
arrayListOf
(
restoreStateObservable
,
restoreStateObservable
,
fetchPlansSize
,
cahcObs
,
// fetchPlansSize,
fetchSettings
,
fetchSettings
,
onSignOut
,
onSignOut
,
onClearCache
,
onClearCache
,
refreshInfo
,
refreshInfo
,
fetchSubscriptions
,
fetchSubscriptions
,
fetchCache
,
fetchCache
,
onSubChecked
,
onSubChecked
// onDownloadTours,
// onDownloadTours,
fetchToursSize
//
fetchToursSize
)
)
)
)
.
doOnError
{
Timber
.
e
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
app/src/main/res/layout/tours_download_dialog_screen.xml
View file @
463ed781
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"8dp"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
...
@@ -40,8 +42,6 @@
...
@@ -40,8 +42,6 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"2dp"
android:layout_margin=
"2dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:text=
"@string/download_all_tours_size_title"
/>
android:text=
"@string/download_all_tours_size_title"
/>
...
@@ -51,8 +51,6 @@
...
@@ -51,8 +51,6 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"2dp"
android:layout_margin=
"2dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:text=
"@string/download_all_tours_disk_size_title"
/>
android:text=
"@string/download_all_tours_disk_size_title"
/>
<LinearLayout
<LinearLayout
...
...
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