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
66ac5bdb
Commit
66ac5bdb
authored
5 years ago
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore model;
settings sub checker
parent
9ed39b84
master
bugfix/sdk29_nullable_safe
develop
feature/fix_furniture_walls_condition
feature/subs_fix
feature/subscriptions
feature/subscriptions_refresh
production/v.0.9.5
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
95 additions
and
5 deletions
+95
-5
ScreenContract.kt
...l/roompark/presentation/screen/settings/ScreenContract.kt
+2
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+24
-1
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+53
-3
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+3
-0
Adapter.kt
...ual/roompark/presentation/screen/settings/util/Adapter.kt
+13
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenContract.kt
View file @
66ac5bdb
package
com.biganto.visual.roompark.presentation.screen.settings
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
io.reactivex.Observable
/**
...
...
@@ -11,5 +12,6 @@ interface SettingsScreen : BigantoBaseContract<SettingsScreenViewState> {
fun
signOut
():
Observable
<
Int
>
fun
clearCache
():
Observable
<
Int
>
fun
refreshCacheInfo
():
Observable
<
Int
>
fun
onSubscription
():
Observable
<
SubscriptionModel
>
}
This diff is collapsed.
Click to expand it.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
66ac5bdb
...
...
@@ -12,11 +12,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.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
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.google.android.material.textview.MaterialTextView
...
...
@@ -50,8 +52,17 @@ class SettingsScreenController :
.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
val
refreshEmitter
=
BehaviorRelay
.
create
<
Int
>()
override
fun
refreshCacheInfo
():
Observable
<
Int
>
=
refreshEmitter
override
fun
onSubscription
():
Observable
<
SubscriptionModel
>
=
(
pushRecycler
.
adapter
as
PushListAdapter
)
.
onItemClicked
.
map
{
it
.
subModel
}
.
debounce
(
600
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
injectDependencies
()
{
getComponent
()
}
...
...
@@ -133,6 +144,8 @@ class SettingsScreenController :
is
SettingsScreenViewState
.
OnCacheDeleting
->
render
(
viewState
)
is
SettingsScreenViewState
.
LoadCachInfo
->
render
(
viewState
)
is
SettingsScreenViewState
.
LoadSubscriptions
->
render
(
viewState
)
is
SettingsScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
SettingsScreenViewState
.
SubscriptionError
->
render
(
viewState
)
}
}
...
...
@@ -148,11 +161,21 @@ class SettingsScreenController :
(
pushRecycler
.
adapter
as
PushListAdapter
).
setItems
(
viewState
.
list
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadCachInfo
){
(
cachedRecycler
.
adapter
as
CahcedListAdapter
).
setItems
(
viewState
.
list
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
SubscriptionStatus
){
(
pushRecycler
.
adapter
as
PushListAdapter
).
setSubState
(
viewState
.
subId
,
viewState
.
subState
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
SubscriptionError
){
(
pushRecycler
.
adapter
as
PushListAdapter
).
setSubState
(
viewState
.
subId
,
viewState
.
subState
)
if
(
viewState
.
subState
)
showError
(
ExceptionString
(
R
.
string
.
unsubscribe_error_message
,
null
))
else
showError
(
ExceptionString
(
R
.
string
.
subscribe_error_message
,
null
))
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnCacheDeleting
){
val
isProgressed
=
viewState
.
progress
>=
1f
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
66ac5bdb
...
...
@@ -3,6 +3,9 @@ package com.biganto.visual.roompark.presentation.screen.settings
import
android.content.Context
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
...
...
@@ -21,16 +24,54 @@ class SettingsScreenPresenter @Inject constructor(
)
:
BigantoBasePresenter
<
SettingsScreen
,
SettingsScreenViewState
>()
{
private
val
restoreModel
=
RestoreModel
(
mutableListOf
(),
arrayListOf
(),
arrayListOf
())
override
fun
detachView
()
{
super
.
detachView
()
restoreStateObservable
.
accept
(
SettingsScreenViewState
.
RestoreView
(
restoreModel
))
}
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
SettingsScreenViewState
.
SomeError
(
e
)
}
override
fun
bindIntents
()
{
val
onSubChecked
=
intent
(
SettingsScreen
::
onSubscription
)
.
flatMap
{
sub
->
interactor
.
switchSubscription
(
sub
,
!
sub
.
state
)
.
andThen
(
Observable
.
just
<
SettingsScreenViewState
>(
SettingsScreenViewState
.
SubscriptionStatus
(
sub
.
id
,
!
sub
.
state
)
)
.
doOnNext
{
val
ind
=
restoreModel
.
subs
.
indexOfFirst
{
it
.
subModel
.
id
==
sub
.
id
}
restoreModel
.
subs
[
ind
]
=
TitledSubscriptionModel
(
title
=
restoreModel
.
subs
[
ind
].
title
,
subModel
=
SubscriptionModel
(
topic
=
sub
.
topic
,
id
=
restoreModel
.
subs
[
ind
].
subModel
.
id
,
state
=
!
sub
.
state
)
)
}
)
.
onErrorReturn
{
SettingsScreenViewState
.
SubscriptionError
(
sub
.
id
,
sub
.
state
)
}
}
val
fetchSettings
=
interactor
.
fetchSettings
()
.
map
{
SettingsScreenViewState
.
LoadSettingsList
(
it
)
}
val
fetchCache
=
interactor
.
getCacheInfo
()
.
doOnNext
{
cached
->
cached
.
sortBy
{
it
.
id
}
}
.
doOnNext
{
restoreModel
.
cacheInfo
=
it
}
.
map
{
SettingsScreenViewState
.
LoadCachInfo
(
it
)
}
val
fetchSubscriptions
=
interactor
.
getSubscriptions
()
...
...
@@ -64,11 +105,12 @@ class SettingsScreenPresenter @Inject constructor(
arrayListOf
(
restoreStateObservable
,
fetchSettings
,
fetchSettings
,
onSignOut
,
onClearCache
,
refreshInfo
,
fetchSubscriptions
fetchSubscriptions
,
fetchCache
,
onSubChecked
)
)
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
@@ -79,4 +121,12 @@ class SettingsScreenPresenter @Inject constructor(
subscribeViewState
(
state
.
cast
(
SettingsScreenViewState
::
class
.
java
),
SettingsScreen
::
render
)
}
}
\ No newline at end of file
}
data class
RestoreModel
(
var
subs
:
MutableList
<
TitledSubscriptionModel
>,
var
cacheInfo
:
MutableList
<
CachedDataModel
>,
var
offlineStoreData
:
MutableList
<
CachedDataModel
>
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenViewState.kt
View file @
66ac5bdb
...
...
@@ -20,4 +20,7 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class
OnCacheDeleting
(
val
progress
:
Float
)
:
SettingsScreenViewState
()
class
LoadSubscriptions
(
val
list
:
List
<
TitledSubscriptionModel
>)
:
SettingsScreenViewState
()
class
LoadCachInfo
(
val
list
:
List
<
CachedDataModel
>)
:
SettingsScreenViewState
()
class
SubscriptionStatus
(
val
subId
:
Int
,
val
subState
:
Boolean
)
:
SettingsScreenViewState
()
class
SubscriptionError
(
val
subId
:
Int
,
val
subState
:
Boolean
)
:
SettingsScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
SettingsScreenViewState
()
}
This diff is collapsed.
Click to expand it.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/util/Adapter.kt
View file @
66ac5bdb
...
...
@@ -9,6 +9,7 @@ import butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.domain.model.CachedDataModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.TitledSubscriptionModel
import
com.biganto.visual.roompark.util.extensions.bytesToSize
import
com.google.android.material.switchmaterial.SwitchMaterial
...
...
@@ -97,6 +98,17 @@ class PushListAdapter : CommonRecyclerAdapter<PushViewHolder,TitledSubscriptionM
get
()
=
PushViewHolder
::
class
override
fun
getVhLayout
():
Int
=
R
.
layout
.
bell_switcher_with_text_viewholder
fun
setSubState
(
subId
:
Int
,
state
:
Boolean
){
val
ind
=
list
.
indexOfFirst
{
it
.
subModel
.
id
==
subId
}
list
[
ind
]
=
TitledSubscriptionModel
(
list
[
ind
].
title
,
SubscriptionModel
(
topic
=
list
[
ind
].
subModel
.
topic
,
id
=
list
[
ind
].
subModel
.
id
,
state
=
state
))
notifyItemChanged
(
ind
)
}
}
...
...
@@ -108,7 +120,7 @@ class PushViewHolder(itemView: View) : CommonViewHolder<TitledSubscriptionModel>
@BindView
(
R
.
id
.
bellSwitch
)
lateinit
var
switcher
:
ViewGroup
override
fun
onViewBound
(
model
:
TitledSubscriptionModel
)
{
override
fun
onViewBound
(
model
:
TitledSubscriptionModel
)
{
Timber
.
d
(
"model is : $model"
)
bellTitle
.
text
=
model
.
title
switcher
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
model
.
subModel
.
state
...
...
This diff is collapsed.
Click to expand it.
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