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
d13adef1
Commit
d13adef1
authored
Apr 29, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/settings_impr' into develop
parents
5f48d403
ce1a143c
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
365 additions
and
84 deletions
+365
-84
StartPlansDownloadingDialogController.kt
...onductor/dialogs/StartPlansDownloadingDialogController.kt
+173
-0
StartToursDownloadingDialogController.kt
...ogs/tour_chooser/StartToursDownloadingDialogController.kt
+21
-9
AuthRepository.kt
...anto/visual/roompark/data/data_provider/AuthRepository.kt
+53
-0
SubscriptionRepository.kt
...ual/roompark/data/data_provider/SubscriptionRepository.kt
+9
-5
RetrofitModule.kt
...oompark/data/repository/api/retrofit/di/RetrofitModule.kt
+1
-1
TourDownloadService.kt
...ual/roompark/data/service/download/TourDownloadService.kt
+19
-0
NotificationCenter.kt
.../roompark/data/service/notification/NotificationCenter.kt
+60
-14
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+3
-30
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+19
-22
tours_download_dialog_screen.xml
app/src/main/res/layout/tours_download_dialog_screen.xml
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+6
-3
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/StartPlansDownloadingDialogController.kt
0 → 100644
View file @
d13adef1
package
com.biganto.visual.roompark.conductor.dialogs
import
android.content.Context
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.ImageView
import
androidx.annotation.LayoutRes
import
com.biganto.visual.roompark.R
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.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.model.bytesToSize
import
com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import
com.bluelinelabs.conductor.Controller
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
dagger.Binds
import
dagger.BindsInstance
import
dagger.Component
import
dagger.Module
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
private
const
val
TYPICAL_PLAN_SIZE
=
(
1.2f
*
1024L
*
1024L
).
toLong
()
class
StartPlansDownloadingDialogController
:
Controller
{
constructor
()
:
super
()
constructor
(
args
:
Bundle
)
:
super
(
args
)
private
val
detachDisposable
=
CompositeDisposable
()
override
fun
onDetach
(
view
:
View
)
{
detachDisposable
.
clear
()
super
.
onDetach
(
view
)
}
@Inject
lateinit
var
interactor
:
SettingsInteractor
@Inject
lateinit
var
file
:
FileModule
lateinit
var
snackbar
:
ISnackBarProvider
@Inject
lateinit
var
rpActivity
:
RoomParkMainActivity
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
DaggerStartPlansDownloadingDialogScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
snackbar
=
ActivityModule
.
provideSnackBar
(
rpActivity
)
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
download_dialog_title
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plans_notice_text
)
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plans_size_title
,
"0"
)
file
.
freeSpace
.
bytesToSize
().
let
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
disk_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_disk_size_title
,
it
)
}
view
.
findViewById
<
Button
>(
R
.
id
.
alert_dismiss_button
)
.
setOnClickListener
{
handleBack
()
}
view
.
findViewById
<
ImageView
>(
R
.
id
.
close_current_button
)
.
setOnClickListener
{
handleBack
()
}
detachDisposable
.
add
(
interactor
.
fetchPlanTypesSizes
()
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
({
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plans_size_title
,(
it
*
TYPICAL_PLAN_SIZE
).
bytesToSize
())
},
{
err
->
Timber
.
e
(
err
)
snackbar
.
showSnackBar
(
R
.
string
.
download_all_plans_errors_snackbar_message
)
})
)
detachDisposable
.
add
(
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
router
.
replaceTopController
(
RouterTransaction
.
with
(
DownloadPlansDialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
)
}
)
view
.
findViewById
<
View
>(
R
.
id
.
close_current_button
).
setOnClickListener
{
handleBack
()
}
// view.setOnClickListener { handleBack() }
return
view
}
@LayoutRes
fun
getLayoutId
()
=
R
.
layout
.
tours_download_dialog_screen
override
fun
handleBack
():
Boolean
{
return
router
.
popCurrentController
()
}
}
@PerScreen
@Component
(
modules
=
[
StartPlansDownloadingDialogScreenModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
interface
StartPlansDownloadingDialogScreenComponent
{
@Component
.
Factory
interface
Factory
{
fun
create
(
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
):
StartPlansDownloadingDialogScreenComponent
}
fun
inject
(
controller
:
StartPlansDownloadingDialogController
)
}
@Module
abstract
class
StartPlansDownloadingDialogScreenModule
{
@PerScreen
@Binds
abstract
fun
provideActivity
(
activity
:
RoomParkMainActivity
):
BaseRoomParkActivity
}
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/StartToursDownloadingDialogController.kt
View file @
d13adef1
...
...
@@ -38,13 +38,11 @@ import javax.inject.Inject
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
private
const
val
TOTAL_SIZE_DOWNLOAD_KEY
=
"TOURS_TO_DOWNLOAD_OVERALL_SIZE"
class
StartToursDownloadingDialogController
:
Controller
{
constructor
(
args
:
Bundle
)
:
super
(
args
)
constructor
(
size
:
Long
)
:
super
(
Bundle
().
apply
{
putLong
(
TOTAL_SIZE_DOWNLOAD_KEY
,
size
)
}
)
constructor
():
super
()
constructor
(
args
:
Bundle
):
super
(
args
)
private
val
detachDisposable
=
CompositeDisposable
()
...
...
@@ -78,12 +76,15 @@ class StartToursDownloadingDialogController : Controller {
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
snackbar
=
ActivityModule
.
provideSnackBar
(
rpActivity
)
args
.
getLong
(
TOTAL_SIZE_DOWNLOAD_KEY
).
let
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_size_title
,
it
.
bytesToSize
())
}
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
download_dialog_title
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_notice_text
)
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_size_title
,
"0"
)
snackbar
=
ActivityModule
.
provideSnackBar
(
rpActivity
)
file
.
freeSpace
.
bytesToSize
().
let
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
disk_size_textView
)
...
...
@@ -96,6 +97,17 @@ class StartToursDownloadingDialogController : Controller {
view
.
findViewById
<
ImageView
>(
R
.
id
.
close_current_button
)
.
setOnClickListener
{
handleBack
()
}
detachDisposable
.
add
(
downloader
.
fetchToursSizes
()
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_size_title
,
it
.
bytesToSize
())
}
)
detachDisposable
.
add
(
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AuthRepository.kt
View file @
d13adef1
...
...
@@ -4,11 +4,13 @@ import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import
com.biganto.visual.roompark.data.local.UserState
import
com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.SubscriptionEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.AuthInfoModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Completable
import
io.reactivex.Observable
...
...
@@ -37,6 +39,19 @@ class AuthContractModule @Inject constructor(
api
.
authenticate
(
email
,
password
)
.
map
(
::
fromRaw
)
.
flatMap
{
db
.
upsertUser
(
it
)
}
.
flatMap
{
user
->
val
userSubs
=
user
.
subscriptions
?.
map
{
it
as
SubscriptionEntity
}
var
newSubs
=
defaultSubsList
(
user
)
if
(!
userSubs
.
isNullOrEmpty
()){
newSubs
=
newSubs
.
filter
{
defSub
->
!
userSubs
.
map
{
it
.
topic
}.
contains
(
defSub
.
topic
)
}.
toList
()
}
if
(
newSubs
.
isNullOrEmpty
())
return
@flatMap
Observable
.
just
(
user
)
return
@flatMap
db
.
upsert
(
newSubs
)
.
toObservable
()
.
flatMap
{
db
.
refreshUser
(
user
)
}
}
.
doOnNext
{
Timber
.
d
(
"user id: ${it.uuid}"
)}
.
doOnNext
{
local
.
setRecentUser
(
it
.
uuid
.
toString
()).
blockingAwait
()
}
.
map
(
::
fromEntity
)
...
...
@@ -60,3 +75,41 @@ class AuthContractModule @Inject constructor(
}
}
}
private
fun
defaultSubsList
(
owner
:
UserEntity
)
:
List
<
SubscriptionEntity
>
=
arrayListOf
(
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_1
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_2
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_3
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Progress_kindergarden
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
News
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Blog
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
,
SubscriptionEntity
().
apply
{
setTopic
(
SubscriptionTopic
.
Construction
().
topicName
)
setOwner
(
owner
)
setState
(
false
)
}
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/data_provider/SubscriptionRepository.kt
View file @
d13adef1
...
...
@@ -80,11 +80,15 @@ class SubscriptionRepository @Inject constructor(
cachedSub
.
setState
(
apiSub
.
active
)
newSubList
.
add
(
cachedSub
)
}
userSubs
?.
filter
{
!
newSubList
.
map
{
s
->
s
.
id
}.
contains
(
it
.
id
)
}
?.
toList
()
?.
let
{
Timber
.
w
(
"to delete; ${it.size}"
)
db
.
deleteSubscriptions
(
it
)
}
userSubs
?.
filter
{
!
newSubList
.
map
{
s
->
s
.
id
}.
contains
(
it
.
id
)
}
?.
forEach
{
(
it
as
SubscriptionEntity
).
setState
(
false
)
}
userSubs
?.
forEach
{
s
->
if
(
newSubList
.
firstOrNull
{
s
.
topic
==
it
.
topic
&&
s
.
number
==
it
.
number
}
==
null
)
newSubList
.
add
(
s
as
SubscriptionEntity
)
}
return
db
.
upsert
(
newSubList
)
.
map
{
list
->
list
.
map
{
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/di/RetrofitModule.kt
View file @
d13adef1
...
...
@@ -36,7 +36,7 @@ private const val TIMEOUT_SECONDS=120L
private
const
val
WRITE_SECONDS
=
120L
private
const
val
READ_SECONDS
=
120L
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
BODY
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
NONE
@Module
class
RetrofitModule
{
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/download/TourDownloadService.kt
View file @
d13adef1
...
...
@@ -47,6 +47,8 @@ private const val META_PREDICTION="/tourMeta_"
private
const
val
META_FILE_TYPE
=
".json"
const
val
DOWNLOAD_MANAGER_COMMAND_KEY
=
"TOURS_DOWNLOAD_MANAGER_COMMAND"
const
val
DOWNLOAD_MANAGER_ADD_IDS_TO_LOAD_COMMAND
=
"ADD_TOUR_IDS_TO_QUEUE"
const
val
DOWNLOAD_MANAGER_STOP_COMMAND
=
"STOP_SERVICE"
@Singleton
class
DownloadManagerService
@Inject
constructor
(
...
...
@@ -117,7 +119,24 @@ class DownloadManagerService @Inject constructor(
return
null
}
override
fun
onStart
(
intent
:
Intent
?,
startId
:
Int
)
{
Timber
.
d
(
"Got intent: $intent"
)
val
v
=
intent
?.
extras
?.
getString
(
DOWNLOAD_MANAGER_COMMAND_KEY
)
Timber
.
d
(
"Got intent: $v"
)
if
(
v
==
DOWNLOAD_MANAGER_STOP_COMMAND
){
Timber
.
d
(
"Got DOWNLOAD_MANAGER_STOP_COMMAND"
)
disposable
.
clear
()
stopSelf
()
}
super
.
onStart
(
intent
,
startId
)
}
override
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
val
v
=
intent
?.
extras
?.
getString
(
DOWNLOAD_MANAGER_COMMAND_KEY
)
if
(
v
==
DOWNLOAD_MANAGER_STOP_COMMAND
){
disposable
.
clear
()
stopSelf
()
}
// Timber.d(" GOT INTENT $intent with action ${intent?.action}")
// if (intent?.action == NOTIFICATION_INTENT_STOP_SERVICE_ACTION)
// {
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/notification/NotificationCenter.kt
View file @
d13adef1
...
...
@@ -2,6 +2,8 @@ package com.biganto.visual.roompark.data.service.notification
import
android.annotation.TargetApi
import
android.app.*
import
android.app.PendingIntent.FLAG_ONE_SHOT
import
android.app.PendingIntent.FLAG_UPDATE_CURRENT
import
android.content.Context
import
android.content.Intent
import
android.graphics.BitmapFactory
...
...
@@ -11,6 +13,9 @@ import androidx.core.app.NotificationCompat
import
androidx.core.content.ContextCompat
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.data.service.download.DOWNLOAD_MANAGER_COMMAND_KEY
import
com.biganto.visual.roompark.data.service.download.DOWNLOAD_MANAGER_STOP_COMMAND
import
com.biganto.visual.roompark.data.service.download.DownloadManagerService
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
javax.inject.Inject
import
javax.inject.Singleton
...
...
@@ -135,7 +140,7 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
,
PENDING_REQUEST_CODE
,
toDownloadsIntent
,
PendingIntent
.
FLAG_ONE_SHOT
,
FLAG_ONE_SHOT
)
...
...
@@ -160,36 +165,77 @@ class NotificationCenter @Inject constructor(val context: Application) : INotif
,
noty
)
}
private
val
cancelServicePendingIntent
:
NotificationCompat
.
Action
by
lazy
{
val
stopServiceIntent
=
Intent
(
context
,
DownloadManagerService
::
class
.
java
)
stopServiceIntent
.
putExtra
(
DOWNLOAD_MANAGER_COMMAND_KEY
,
DOWNLOAD_MANAGER_STOP_COMMAND
)
val
pendingStopServiceIntent
=
PendingIntent
.
getService
(
context
,
546
,
stopServiceIntent
,
FLAG_UPDATE_CURRENT
)
NotificationCompat
.
Action
.
Builder
(
R
.
drawable
.
ic_back
,
"Отмена"
,
pendingStopServiceIntent
).
build
()
}
override
fun
donwloadServiceProgressNotfication
(
progress
:
Int
,
progressMax
:
Int
,
indeterminate
:
Boolean
,
message
:
String
){
val
pendingIntent
=
PendingIntent
.
getActivity
(
context
val
b
=
(
if
(
indeterminate
)
updateProgressNotificationIndeterminate
else
updateProgressNotification
)
b
.
setContentText
(
message
)
b
.
setProgress
(
progress
,
progressMax
,
indeterminate
)
actualNotifyManager
.
notify
(
(
if
(
indeterminate
)
DOWNLOAD_SERVICE_ID
else
TOUR_INFO_SERVICE_ID
)
,
b
.
build
()
)
}
private
val
defPendingIntent
by
lazy
{
PendingIntent
.
getActivity
(
context
,
PENDING_REQUEST_CODE
,
toDownloadsIntent
,
PendingIntent
.
FLAG_ONE_SHO
T
,
FLAG_UPDATE_CURREN
T
)
}
val
notification
=
(
if
(
indeterminate
)
builder
else
toursNotyBuilder
)
// builder
private
val
updateProgressNotificationIndeterminate
by
lazy
{
builder
.
setOnlyAlertOnce
(
true
)
.
setContentTitle
(
context
.
getString
(
R
.
string
.
notification_content_title
))
.
setContentText
(
message
)
.
setProgress
(
progress
,
progressMax
,
indeterminate
)
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
.
setBadgeIconType
(
NotificationCompat
.
BADGE_ICON_LARGE
)
.
setColor
(
notificationSystemColor
)
.
setLargeIcon
(
icon
)
.
setContentIntent
(
pendingIntent
)
.
setContentIntent
(
defPendingIntent
)
.
addAction
(
cancelServicePendingIntent
)
.
setAutoCancel
(
true
)
.
build
()
}
actualNotifyManager
.
notify
(
(
if
(
indeterminate
)
DOWNLOAD_SERVICE_ID
else
TOUR_INFO_SERVICE_ID
)
,
notification
)
private
val
updateProgressNotification
by
lazy
{
toursNotyBuilder
.
setOnlyAlertOnce
(
true
)
.
setContentTitle
(
context
.
getString
(
R
.
string
.
notification_content_title
))
.
setSmallIcon
(
R
.
mipmap
.
ic_launcher
)
.
setBadgeIconType
(
NotificationCompat
.
BADGE_ICON_LARGE
)
.
setColor
(
notificationSystemColor
)
.
setLargeIcon
(
icon
)
.
setContentIntent
(
defPendingIntent
)
.
addAction
(
cancelServicePendingIntent
)
.
setAutoCancel
(
true
)
}
@TargetApi
(
Build
.
VERSION_CODES
.
O
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
d13adef1
...
...
@@ -13,14 +13,13 @@ import com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.
DownloadPlans
DialogController
import
com.biganto.visual.roompark.conductor.dialogs.
StartPlansDownloading
DialogController
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.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import
com.biganto.visual.roompark.util.extensions.bytesToSize
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.bluelinelabs.conductor.RouterTransaction
...
...
@@ -112,7 +111,7 @@ class SettingsScreenController :
@OnClick
(
R
.
id
.
downloadFlatCardsIcon
)
fun
onStartTourPlans
(){
router
.
pushController
(
RouterTransaction
.
with
(
DownloadPlans
DialogController
())
router
.
pushController
(
RouterTransaction
.
with
(
StartPlansDownloading
DialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
)
...
...
@@ -132,13 +131,12 @@ class SettingsScreenController :
@OnClick
(
R
.
id
.
downloadToursIcon
)
fun
startDownloadingDialog
(){
router
.
pushController
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
(
tempToursSize
))
router
.
pushController
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
)
}
private
var
tempToursSize
=
0L
private
fun
bindRecycler
(){
pushRecycler
.
isNestedScrollingEnabled
=
true
...
...
@@ -157,14 +155,6 @@ class SettingsScreenController :
override
fun
onViewBound
(
v
:
View
)
{
bottomNavigationController
.
show
()
toursDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
"-"
)
flatDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plan_types_settings_with_sizes
,
"-"
)
setToolbar
()
bindRecycler
()
}
...
...
@@ -195,23 +185,6 @@ class SettingsScreenController :
clearCacheButton
.
setGone
(
false
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnSizePrefetch
)
{
tempToursSize
=
viewState
.
size
toursDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
viewState
.
size
.
bytesToSize
()
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnPlanTypesPrefetch
)
{
flatDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plan_types_settings_with_sizes
,
viewState
.
size
.
bytesToSize
()
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadSubscriptions
){
(
pushRecycler
.
adapter
as
PushListAdapter
).
setItems
(
viewState
.
list
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
d13adef1
...
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.jakewharton.rxrelay2.PublishRelay
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
...
...
@@ -18,8 +17,6 @@ import javax.inject.Inject
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
private
const
val
TYPICAL_PLAN_SIZE
=
(
1.2f
*
1024L
*
1024L
).
toLong
()
class
SettingsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
SettingsInteractor
,
private
val
activity
:
BaseRoomParkActivity
...
...
@@ -37,23 +34,23 @@ class SettingsScreenPresenter @Inject constructor(
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
SettingsScreenViewState
.
SomeError
(
e
)
}
private
val
cacheSizeRefresher
=
PublishRelay
.
create
<
Int
>()
private
val
cahcObs
=
cacheSizeRefresher
.
flatMap
{
Observable
.
merge
(
arrayListOf
(
fetchToursSize
,
fetchPlansSize
)
)
}
// private val cacheSizeRefresher = PublishRelay.create<Int>()
private
val
fetchToursSize
:
Observable
<
SettingsScreenViewState
>
=
interactor
.
fetchToursSizes
()
.
map
{
SettingsScreenViewState
.
OnSizePrefetch
(
it
)
}
// private val cahcObs =
// cacheSizeRefresher.flatMap {
// Observable.merge(
// arrayListOf(
// fetchToursSize, fetchPlansSize
// )
// )
// }
private
val
fetchPlansSize
:
Observable
<
SettingsScreenViewState
>
=
interactor
.
fetchPlanTypesSizes
()
.
map
{
it
*
TYPICAL_PLAN_SIZE
}
.
map
{
SettingsScreenViewState
.
OnPlanTypesPrefetch
(
it
)
}
// private val fetchToursSize: Observable<SettingsScreenViewState> = interactor.fetchToursSizes()
// .map { SettingsScreenViewState.OnSizePrefetch(it) }
//
// private val fetchPlansSize: Observable<SettingsScreenViewState> = interactor.fetchPlanTypesSizes()
// .map { it* TYPICAL_PLAN_SIZE }
// .map { SettingsScreenViewState.OnPlanTypesPrefetch(it) }
override
fun
bindIntents
()
{
...
...
@@ -82,7 +79,7 @@ class SettingsScreenPresenter @Inject constructor(
.
doOnNext
{
cached
->
cached
.
sortBy
{
it
.
id
}
}
.
doOnNext
{
restoreModel
.
cacheInfo
=
it
}
.
map
{
SettingsScreenViewState
.
LoadCachInfo
(
it
)
}
.
doOnNext
{
cacheSizeRefresher
.
accept
(
1
)
}
//
.doOnNext {cacheSizeRefresher.accept(1) }
val
fetchSubscriptions
=
interactor
.
getSubscriptions
()
.
map
{
list
->
...
...
@@ -107,8 +104,8 @@ class SettingsScreenPresenter @Inject constructor(
.
map
<
SettingsScreenViewState
>
{
Timber
.
d
(
" got progress: ${it.first} / ${it.second.toFloat()}"
)
if
(
it
.
first
==
it
.
second
)
cacheSizeRefresher
.
accept
(
1
)
//
if (it.first == it.second)
//
cacheSizeRefresher.accept(1)
SettingsScreenViewState
.
OnCacheDeleting
(
it
.
first
/
it
.
second
.
toFloat
()
...
...
@@ -124,7 +121,7 @@ class SettingsScreenPresenter @Inject constructor(
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
restoreStateObservable
,
cahcObs
,
//
cahcObs,
// fetchPlansSize,
fetchSettings
,
onSignOut
,
...
...
app/src/main/res/layout/tours_download_dialog_screen.xml
View file @
d13adef1
...
...
@@ -29,6 +29,7 @@
android:orientation=
"vertical"
>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/download_dialog_title"
style=
"@style/Default_TextView.Header_Text"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
app/src/main/res/values/strings.xml
View file @
d13adef1
...
...
@@ -40,7 +40,7 @@
<string
name=
"api_error_2001"
>
Тур не найден!
</string>
<string
name=
"api_error_default"
>
Неизвестная ошибка сервера!
</string>
<string
name=
"no_network_error"
>
No network
!
</string>
<string
name=
"no_network_error"
>
Нет сети
!
</string>
<string
name=
"unknown_error"
>
Unexpected error!
</string>
<string
name=
"cant_load_item_error"
>
Can\'t load item!
</string>
<string
name=
"object_not_found_error"
>
Object not found!
</string>
...
...
@@ -128,16 +128,19 @@
<string
name=
"game_view_content_description"
/>
<string
name=
"download_all_tours_settings_with_size"
>
Скачать виртуальные туры моих квартир из избранного и сделок
(%s)
</string>
<string
name=
"download_all_plan_types_settings_with_sizes"
>
Скачать карточки моих квартир из избранного и сделок
(%s)
</string>
<string
name=
"download_all_tours_settings_with_size"
>
Скачать виртуальные туры моих квартир из избранного и сделок
</string>
<string
name=
"download_all_plan_types_settings_with_sizes"
>
Скачать карточки моих квартир из избранного и сделок
</string>
<string
name=
"plan_types_download_completed"
>
Загрузка планов завершена.
</string>
<string
name=
"download_plan_types_screen_title"
>
Cкачиваются планировки
</string>
<string
name=
"download_all_tours_notice_text"
>
Загрузить все туры?
</string>
<string
name=
"download_all_plans_notice_text"
>
Загрузить все \n планировки?
</string>
<string
name=
"download_all_tours_size_title"
>
Размер всех туров: %s
</string>
<string
name=
"download_all_plans_size_title"
>
Размер всех планировок: %s
</string>
<string
name=
"download_all_tours_disk_size_title"
>
Размер свободного места на диске: %s
</string>
<string
name=
"download_all_tours_yes_action"
>
Скачать
</string>
<string
name=
"download_all_tours_cancel_action"
>
Отмена
</string>
<string
name=
"download_all_tours_errors_snackbar_message"
>
Ошибка при попытке загрузить туры!
</string>
<string
name=
"download_all_plans_errors_snackbar_message"
>
Ошибка при попытке загрузить планировки!
</string>
<string
name=
"download_all_tours_start_snackbar_message"
>
Загрузка туров началась!
</string>
</resources>
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