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
Hide 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{
Timber
.
d
(
"Kotlin store creating.."
)
val
source
=
DatabaseSource
(
context
,
Models
.
DEFAULT
,
"BigantoPerfect"
,
DATABASE_VERSION
)
source
.
setLoggingEnabled
(
true
)
source
.
setWriteAheadLoggingEnabled
(
true
)
//
source.setLoggingEnabled(true)
//
source.setWriteAheadLoggingEnabled(true)
source
.
setTableCreationMode
(
TableCreationMode
.
DROP_CREATE
)
val
store
=
KotlinEntityDataStore
<
Persistable
>(
source
.
configuration
)
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(
fun
getSubscriptions
(
topic
:
SubscriptionTopic
):
Observable
<
SubscriptionModel
>
=
auth
.
currentUser
()
.
map
{
user
->
Timber
.
w
(
"user is : $user"
)
var
sub
=
user
.
subscriptions
?.
firstOrNull
{
it
.
topic
==
topic
.
topicName
&&
it
.
number
==
topic
.
topicId
}
Timber
.
d
(
"fetched topic: $sub"
)
if
(
sub
==
null
)
{
sub
=
SubscriptionEntity
()
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 :
@BindView
(
R
.
id
.
bubble_slider
)
lateinit
var
bubble
:
BubbleSlider
@BindView
(
R
.
id
.
switch1
)
lateinit
var
albumSubscription
:
SwitchMaterial
//
// private val photosBackgroundTarget = object : com.squareup.picasso.Target {
...
...
@@ -135,7 +138,7 @@ class AlbumsScreenController :
override
fun
onSubscription
():
Observable
<
Boolean
>
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
albumSubscription
.
checkedChanges
()
.
skip
(
1
)
//skip init switcher check state
.
filter
{
...
...
@@ -146,6 +149,7 @@ class AlbumsScreenController :
.
doOnNext
{
}
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
share
()
...
...
@@ -178,8 +182,8 @@ class AlbumsScreenController :
private
var
silentCheck
=
false
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionStatus
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
Timber
.
d
()
val
sw
=
albumSubscription
Timber
.
d
(
""
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
silentCheck
=
true
...
...
@@ -188,7 +192,7 @@ class AlbumsScreenController :
}
private
fun
render
(
viewState
:
AlbumsScreenViewState
.
SubscriptionError
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
val
sw
=
albumSubscription
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
silentCheck
=
true
...
...
@@ -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
)
{
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(
.
doOnNext
{
restoreModel
.
albumList
=
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
()
{
val
onSubChecked
=
intent
(
AlbumsScreen
::
onSubscription
)
...
...
@@ -51,10 +58,6 @@ class AlbumsScreenPresenter @Inject constructor(
.
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
()
.
filter
{
!
it
.
isNullOrEmpty
()
}
...
...
@@ -63,19 +66,19 @@ class AlbumsScreenPresenter @Inject constructor(
val
fetchSelected
=
requestAlbum
(
selectedIndex
)
val
headerItemSelected
=
Observable
.
mergeDelayError
(
arrayListOf
(
intent
(
AlbumsScreen
::
onAlbumSelected
)
val
headerItemSelected
=
intent
(
AlbumsScreen
::
onAlbumSelected
)
.
doOnNext
{
selectedIndex
=
it
.
albumId
}
.
doOnNext
{
restoreModel
.
currentIndex
=
it
.
albumId
}
.
flatMap
<
AlbumsScreenViewState
>
{
model
->
requestAlbum
(
model
.
albumId
)
.
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
)
...
...
@@ -88,7 +91,8 @@ class AlbumsScreenPresenter @Inject constructor(
fetchSelected
,
headerItemSelected
,
photoSelected
,
fetchSubscription
,
fetchSubscription
(
selectedIndex
),
fetchHeaderSubscription
,
onSubChecked
)
)
...
...
@@ -104,12 +108,15 @@ class AlbumsScreenPresenter @Inject constructor(
restoreStateObservable
.
accept
(
AlbumsScreenViewState
.
RestoreView
(
restoreModel
))
}
private
val
currentAlbumTopic
=
when
(
selectedIndex
){
9
->
SubscriptionTopic
.
Progress_1
()
10
->
SubscriptionTopic
.
Progress_2
()
11
->
SubscriptionTopic
.
Progress_3
()
106
->
SubscriptionTopic
.
Progress_kindergarden
()
else
->
error
(
"unknown parent album type!"
)
private
fun
currentAlbumTopic
(
albumId
:
Int
):
SubscriptionTopic
{
val
z
=
when
(
albumId
){
9
->
SubscriptionTopic
.
Progress_2
()
10
->
SubscriptionTopic
.
Progress_1
()
11
->
SubscriptionTopic
.
Progress_3
()
106
->
SubscriptionTopic
.
Progress_kindergarden
()
else
->
error
(
"unknown parent album type!"
)
}
return
z
}
}
...
...
app/src/main/res/layout/albums_screen.xml
View file @
f697ad78
...
...
@@ -69,6 +69,7 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"16dp"
android:baselineAligned=
"false"
android:gravity=
"center_vertical|end"
/>
...
...
app/src/main/res/layout/bell_switcher_with_text_viewholder.xml
View file @
f697ad78
...
...
@@ -10,9 +10,11 @@
android:id=
"@+id/bellSwitcherTitle"
style=
"@style/Common_Text.Default"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:layout_weight=
"1"
android:gravity=
"start|center_vertical"
android:includeFontPadding=
"false"
android:text=
"блабла"
/>
<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