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
f697ad78
Commit
f697ad78
authored
Apr 02, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix album subscription
parent
991e8526
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
26 deletions
+40
-26
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+2
-2
subscriptionUseCase.kt
...to/visual/roompark/domain/use_case/subscriptionUseCase.kt
+1
-1
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+9
-5
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+24
-17
albums_screen.xml
app/src/main/res/layout/albums_screen.xml
+1
-0
bell_switcher_with_text_viewholder.xml
...rc/main/res/layout/bell_switcher_with_text_viewholder.xml
+3
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
f697ad78
...
@@ -31,8 +31,8 @@ class DbModule{
...
@@ -31,8 +31,8 @@ class DbModule{
Timber
.
d
(
"Kotlin store creating.."
)
Timber
.
d
(
"Kotlin store creating.."
)
val
source
=
DatabaseSource
(
context
,
Models
.
DEFAULT
,
"BigantoPerfect"
,
DATABASE_VERSION
)
val
source
=
DatabaseSource
(
context
,
Models
.
DEFAULT
,
"BigantoPerfect"
,
DATABASE_VERSION
)
source
.
setLoggingEnabled
(
true
)
//
source.setLoggingEnabled(true)
source
.
setWriteAheadLoggingEnabled
(
true
)
//
source.setWriteAheadLoggingEnabled(true)
source
.
setTableCreationMode
(
TableCreationMode
.
DROP_CREATE
)
source
.
setTableCreationMode
(
TableCreationMode
.
DROP_CREATE
)
val
store
=
KotlinEntityDataStore
<
Persistable
>(
source
.
configuration
)
val
store
=
KotlinEntityDataStore
<
Persistable
>(
source
.
configuration
)
Timber
.
d
(
"Kotlin store %s"
,
source
)
Timber
.
d
(
"Kotlin store %s"
,
source
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/subscriptionUseCase.kt
View file @
f697ad78
...
@@ -81,9 +81,9 @@ class SubscriptionUseCase @Inject constructor(
...
@@ -81,9 +81,9 @@ class SubscriptionUseCase @Inject constructor(
fun
getSubscriptions
(
topic
:
SubscriptionTopic
):
Observable
<
SubscriptionModel
>
=
fun
getSubscriptions
(
topic
:
SubscriptionTopic
):
Observable
<
SubscriptionModel
>
=
auth
.
currentUser
()
auth
.
currentUser
()
.
map
{
user
->
.
map
{
user
->
Timber
.
w
(
"user is : $user"
)
var
sub
=
user
.
subscriptions
var
sub
=
user
.
subscriptions
?.
firstOrNull
{
it
.
topic
==
topic
.
topicName
&&
it
.
number
==
topic
.
topicId
}
?.
firstOrNull
{
it
.
topic
==
topic
.
topicName
&&
it
.
number
==
topic
.
topicId
}
Timber
.
d
(
"fetched topic: $sub"
)
if
(
sub
==
null
)
{
if
(
sub
==
null
)
{
sub
=
SubscriptionEntity
()
sub
=
SubscriptionEntity
()
sub
.
setOwner
(
user
)
sub
.
setOwner
(
user
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
f697ad78
...
@@ -71,6 +71,9 @@ class AlbumsScreenController :
...
@@ -71,6 +71,9 @@ class AlbumsScreenController :
@BindView
(
R
.
id
.
bubble_slider
)
@BindView
(
R
.
id
.
bubble_slider
)
lateinit
var
bubble
:
BubbleSlider
lateinit
var
bubble
:
BubbleSlider
@BindView
(
R
.
id
.
switch1
)
lateinit
var
albumSubscription
:
SwitchMaterial
//
//
// private val photosBackgroundTarget = object : com.squareup.picasso.Target {
// private val photosBackgroundTarget = object : com.squareup.picasso.Target {
...
@@ -135,7 +138,7 @@ class AlbumsScreenController :
...
@@ -135,7 +138,7 @@ class AlbumsScreenController :
override
fun
onSubscription
():
Observable
<
Boolean
>
=
override
fun
onSubscription
():
Observable
<
Boolean
>
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
albumSubscription
.
checkedChanges
()
.
checkedChanges
()
.
skip
(
1
)
//skip init switcher check state
.
skip
(
1
)
//skip init switcher check state
.
filter
{
.
filter
{
...
@@ -146,6 +149,7 @@ class AlbumsScreenController :
...
@@ -146,6 +149,7 @@ class AlbumsScreenController :
.
doOnNext
{
}
.
doOnNext
{
}
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
share
()
...
@@ -178,8 +182,8 @@ class AlbumsScreenController :
...
@@ -178,8 +182,8 @@ class AlbumsScreenController :
private
var
silentCheck
=
false
private
var
silentCheck
=
false
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionStatus
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionStatus
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
val
sw
=
albumSubscription
Timber
.
d
()
Timber
.
d
(
""
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
{
silentCheck
=
true
silentCheck
=
true
...
@@ -188,7 +192,7 @@ class AlbumsScreenController :
...
@@ -188,7 +192,7 @@ class AlbumsScreenController :
}
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionError
)
{
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionError
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
val
sw
=
albumSubscription
if
(
sw
.
isChecked
!=
viewState
.
subState
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
{
silentCheck
=
true
silentCheck
=
true
...
@@ -268,7 +272,7 @@ class AlbumsScreenController :
...
@@ -268,7 +272,7 @@ class AlbumsScreenController :
}
}
}
}
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
val
sw
=
albumSubscription
if
(
sw
.
isChecked
!=
viewState
.
restore
.
sub
?.
state
)
if
(
sw
.
isChecked
!=
viewState
.
restore
.
sub
?.
state
)
{
{
silentCheck
=
true
silentCheck
=
true
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
f697ad78
...
@@ -35,6 +35,13 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -35,6 +35,13 @@ class AlbumsScreenPresenter @Inject constructor(
.
doOnNext
{
restoreModel
.
albumList
=
it
}
.
doOnNext
{
restoreModel
.
albumList
=
it
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
)
}
private
fun
fetchSubscription
(
albumId
:
Int
):
Observable
<
AlbumsScreenViewState
>
=
interactor
.
getSubscriptions
(
currentAlbumTopic
(
albumId
))
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
AlbumsScreenViewState
>
{
AlbumsScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
// .startWith(Observable.just<AlbumsScreenViewState>(AlbumsScreenViewState.Idle()))
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
val
onSubChecked
=
intent
(
AlbumsScreen
::
onSubscription
)
val
onSubChecked
=
intent
(
AlbumsScreen
::
onSubscription
)
...
@@ -51,10 +58,6 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -51,10 +58,6 @@ class AlbumsScreenPresenter @Inject constructor(
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
.
onErrorReturn
{
AlbumsScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
val
fetchSubscription
=
interactor
.
getSubscriptions
(
currentAlbumTopic
)
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
AlbumsScreenViewState
>
{
AlbumsScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
// .startWith(Observable.just<AlbumsScreenViewState>(AlbumsScreenViewState.Idle()))
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
filter
{
!
it
.
isNullOrEmpty
()
}
.
filter
{
!
it
.
isNullOrEmpty
()
}
...
@@ -63,19 +66,19 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -63,19 +66,19 @@ class AlbumsScreenPresenter @Inject constructor(
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
headerItemSelected
=
val
headerItemSelected
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
Observable
.
mergeDelayError
(
arrayListOf
(
intent
(
AlbumsScreen
::
onAlbumSelected
)
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
doOnNext
{
restoreModel
.
currentIndex
=
it
.
albumId
}
.
doOnNext
{
restoreModel
.
currentIndex
=
it
.
albumId
}
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
requestAlbum
(
model
.
albumId
)
requestAlbum
(
model
.
albumId
)
.
startWith
(
Observable
.
just
<
AlbumsScreenViewState
>(
AlbumsScreenViewState
.
HeaderAlbumChoosed
(
item
=
model
))
.
startWith
(
Observable
.
just
<
AlbumsScreenViewState
>(
AlbumsScreenViewState
.
HeaderAlbumChoosed
(
item
=
model
))
)
)
}
,
fetchSubscription
))
}
val
fetchHeaderSubscription
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
.
map
{
it
.
albumId
}
.
doOnNext
{
selectedIndex
=
it
;
restoreModel
.
currentIndex
=
it
}
.
switchMap
{
fetchSubscription
(
it
)
}
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
val
photoSelected
=
intent
(
AlbumsScreen
::
onPhotoSelected
)
...
@@ -88,7 +91,8 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -88,7 +91,8 @@ class AlbumsScreenPresenter @Inject constructor(
fetchSelected
,
fetchSelected
,
headerItemSelected
,
headerItemSelected
,
photoSelected
,
photoSelected
,
fetchSubscription
,
fetchSubscription
(
selectedIndex
),
fetchHeaderSubscription
,
onSubChecked
onSubChecked
)
)
)
)
...
@@ -104,13 +108,16 @@ class AlbumsScreenPresenter @Inject constructor(
...
@@ -104,13 +108,16 @@ class AlbumsScreenPresenter @Inject constructor(
restoreStateObservable
.
accept
(
AlbumsScreenViewState
.
RestoreView
(
restoreModel
))
restoreStateObservable
.
accept
(
AlbumsScreenViewState
.
RestoreView
(
restoreModel
))
}
}
private
val
currentAlbumTopic
=
when
(
selectedIndex
){
private
fun
currentAlbumTopic
(
albumId
:
Int
):
SubscriptionTopic
{
9
->
SubscriptionTopic
.
Progress_1
()
val
z
=
when
(
albumId
){
10
->
SubscriptionTopic
.
Progress_2
()
9
->
SubscriptionTopic
.
Progress_2
()
10
->
SubscriptionTopic
.
Progress_1
()
11
->
SubscriptionTopic
.
Progress_3
()
11
->
SubscriptionTopic
.
Progress_3
()
106
->
SubscriptionTopic
.
Progress_kindergarden
()
106
->
SubscriptionTopic
.
Progress_kindergarden
()
else
->
error
(
"unknown parent album type!"
)
else
->
error
(
"unknown parent album type!"
)
}
}
return
z
}
}
}
data class
RestoreModel
(
var
albumList
:
List
<
AlbumSortedModel
>
data class
RestoreModel
(
var
albumList
:
List
<
AlbumSortedModel
>
...
...
app/src/main/res/layout/albums_screen.xml
View file @
f697ad78
...
@@ -69,6 +69,7 @@
...
@@ -69,6 +69,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"16dp"
android:layout_marginEnd=
"16dp"
android:baselineAligned=
"false"
android:baselineAligned=
"false"
android:gravity=
"center_vertical|end"
/>
android:gravity=
"center_vertical|end"
/>
...
...
app/src/main/res/layout/bell_switcher_with_text_viewholder.xml
View file @
f697ad78
...
@@ -10,9 +10,11 @@
...
@@ -10,9 +10,11 @@
android:id=
"@+id/bellSwitcherTitle"
android:id=
"@+id/bellSwitcherTitle"
style=
"@style/Common_Text.Default"
style=
"@style/Common_Text.Default"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:gravity=
"start|center_vertical"
android:gravity=
"start|center_vertical"
android:includeFontPadding=
"false"
android:text=
"блабла"
/>
android:text=
"блабла"
/>
<include
<include
...
...
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