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
2a134b93
Commit
2a134b93
authored
Mar 26, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sub state to view
parent
ac3cacd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
14 deletions
+31
-14
RoomParkMainActivity.kt
.../com/biganto/visual/roompark/base/RoomParkMainActivity.kt
+1
-1
articles.kt
...com/biganto/visual/roompark/domain/interactor/articles.kt
+1
-1
ScreenController.kt
...oompark/presentation/screen/feed_list/ScreenController.kt
+8
-0
ScreenPresenter.kt
...roompark/presentation/screen/feed_list/ScreenPresenter.kt
+16
-9
ScreenViewState.kt
...roompark/presentation/screen/feed_list/ScreenViewState.kt
+4
-1
switch_toolbar.xml
app/src/main/res/layout/switch_toolbar.xml
+1
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/base/RoomParkMainActivity.kt
View file @
2a134b93
...
...
@@ -105,7 +105,7 @@ class RoomParkMainActivity(
headerToolbarBack
.
text
=
it
.
backTitle
?:
""
headerToolbar
.
toolbar_title
.
text
=
it
.
title
?:
""
headerToolbar
.
include13
.
setGone
(!(
it
.
switcher
?:
false
))
headerToolbar
.
subsciption_switcher
.
setGone
(!(
it
.
switcher
?:
false
))
}
status
?.
let
{
statusToolbar
.
status_icon
.
setGone
(
it
.
state
==
null
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/articles.kt
View file @
2a134b93
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
import
com.biganto.visual.roompark.domain.use_case.FeedUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionTopic
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
javax.inject.Inject
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenController.kt
View file @
2a134b93
...
...
@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.feed_list.util.ArticlesAd
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.recyclerview.scrollStateChanges
import
io.reactivex.Observable
...
...
@@ -70,6 +71,7 @@ class ArticlesScreenController :
lateinit
var
emptyListNotice
:
MaterialTextView
private
fun
setToolbar
()
{
articlesRecyclerView
.
isNestedScrollingEnabled
=
false
...
...
@@ -125,6 +127,7 @@ class ArticlesScreenController :
is
ArticlesScreenViewState
.
ArticlesScrollPage
->
render
(
viewState
)
is
ArticlesScreenViewState
.
RestoreView
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SomeError
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
}
}
...
...
@@ -139,6 +142,11 @@ class ArticlesScreenController :
progressBar
.
setGone
(
true
)
}
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionStatus
)
{
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
viewState
.
subState
}
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
ArticlesScrollPage
){
Timber
.
d
(
"got items: ${viewState.items.size}"
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenPresenter.kt
View file @
2a134b93
...
...
@@ -23,7 +23,7 @@ class ArticlesScreenPresenter @Inject constructor(
)
:
BigantoBasePresenter
<
ArticlesScreen
,
ArticlesScreenViewState
>()
{
private
val
restoreModel
=
RestoreModel
(
mutableListOf
())
private
val
restoreModel
=
RestoreModel
(
mutableListOf
()
,
null
)
override
fun
detachView
()
{
super
.
detachView
()
...
...
@@ -32,31 +32,38 @@ class ArticlesScreenPresenter @Inject constructor(
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
ArticlesScreenViewState
.
SomeError
(
e
)
}
{
e
:
ExceptionString
->
ArticlesScreenViewState
.
SomeError
(
e
)
}
override
fun
bindIntents
()
{
Timber
.
d
(
"feedId : $feedId"
)
val
prefetchCards
=
interactor
.
fetchArticles
(
feedId
)
.
map
<
ArticlesScreenViewState
>{
ArticlesScreenViewState
.
ArticlesLoaded
(
it
.
articles
)
}
.
map
<
ArticlesScreenViewState
>
{
ArticlesScreenViewState
.
ArticlesLoaded
(
it
.
articles
)
}
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
val
getNewArticlesPage
=
intent
(
ArticlesScreen
::
requsetsNewArticles
)
.
flatMap
{
interactor
.
fetchArticlesPage
(
feedId
,
FEED_PAGE_SIZE
,
it
)
}
.
map
<
ArticlesScreenViewState
>
{
articlePage
->
val
getNewArticlesPage
=
intent
(
ArticlesScreen
::
requsetsNewArticles
)
.
flatMap
{
interactor
.
fetchArticlesPage
(
feedId
,
FEED_PAGE_SIZE
,
it
)
}
.
map
<
ArticlesScreenViewState
>
{
articlePage
->
articlePage
.
articles
.
asSequence
()
.
filter
{
!
restoreModel
.
articles
.
contains
(
it
)
}
.
toList
()
.
let
{
uniqueItems
->
restoreModel
.
articles
.
addAll
(
uniqueItems
)
}
.
let
{
uniqueItems
->
restoreModel
.
articles
.
addAll
(
uniqueItems
)
}
ArticlesScreenViewState
.
ArticlesScrollPage
(
articlePage
.
articles
.
toList
())
}
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
val
fetchSubscription
=
interactor
.
getSubscriptions
(
feedId
)
.
doAfterNext
{
restoreModel
.
sub
=
it
}
.
map
<
ArticlesScreenViewState
>
{
ArticlesScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
val
state
=
restoreStateObservable
.
mergeWith
(
prefetchCards
)
.
mergeWith
(
getNewArticlesPage
)
.
doOnError
{
Timber
.
e
(
it
)}
.
mergeWith
(
fetchSubscription
)
.
doOnError
{
Timber
.
e
(
it
)
}
.
onErrorReturn
(
::
parseError
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenViewState.kt
View file @
2a134b93
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.feed_list
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
/**
...
...
@@ -15,9 +16,11 @@ sealed class ArticlesScreenViewState : BigantoBaseViewState() {
class
SomeError
(
val
exception
:
ExceptionString
)
:
ArticlesScreenViewState
()
class
ArticlesScrollPage
(
val
items
:
List
<
ArticlePreviewModel
>)
:
ArticlesScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
ArticlesScreenViewState
()
class
SubscriptionStatus
(
val
subState
:
Boolean
)
:
ArticlesScreenViewState
()
}
data class
RestoreModel
(
var
articles
:
MutableList
<
ArticlePreviewModel
>
var
articles
:
MutableList
<
ArticlePreviewModel
>,
var
sub
:
SubscriptionModel
?
)
\ No newline at end of file
app/src/main/res/layout/switch_toolbar.xml
View file @
2a134b93
...
...
@@ -35,13 +35,12 @@
android:includeFontPadding=
"true"
android:textAlignment=
"gravity"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toStartOf=
"@+id/
include13
"
app:layout_constraintEnd_toStartOf=
"@+id/
subsciption_switcher
"
app:layout_constraintHorizontal_bias=
"0.0"
app:layout_constraintStart_toEndOf=
"@id/back_button_chevron"
app:layout_constraintTop_toTopOf=
"parent"
/>
<include
android:id=
"@+id/include13"
layout=
"@layout/bell_switch_view"
android:layout_width=
"wrap_content"
...
...
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