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
0c8af564
Commit
0c8af564
authored
Mar 30, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix subscription status ui check
parent
0f60e406
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
14 deletions
+59
-14
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+5
-0
ScreenPresenter.kt
...l/roompark/presentation/screen/article/ScreenPresenter.kt
+2
-0
ScreenController.kt
...oompark/presentation/screen/feed_list/ScreenController.kt
+36
-4
ScreenPresenter.kt
...roompark/presentation/screen/feed_list/ScreenPresenter.kt
+13
-10
ScreenViewState.kt
...roompark/presentation/screen/feed_list/ScreenViewState.kt
+1
-0
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
0c8af564
...
@@ -118,6 +118,7 @@ class ArticleScreenController :
...
@@ -118,6 +118,7 @@ class ArticleScreenController :
when
(
viewState
){
when
(
viewState
){
is
ArticleScreenViewState
.
Idle
->
render
(
viewState
)
is
ArticleScreenViewState
.
Idle
->
render
(
viewState
)
is
ArticleScreenViewState
.
ArticleLoaded
->
render
(
viewState
)
is
ArticleScreenViewState
.
ArticleLoaded
->
render
(
viewState
)
is
ArticleScreenViewState
.
SomeError
->
render
(
viewState
)
}
}
}
}
...
@@ -125,6 +126,10 @@ class ArticleScreenController :
...
@@ -125,6 +126,10 @@ class ArticleScreenController :
}
}
private
fun
render
(
viewState
:
ArticleScreenViewState
.
SomeError
)
{
showError
(
viewState
.
error
)
}
private
fun
render
(
viewState
:
ArticleScreenViewState
.
ArticleLoaded
)
{
private
fun
render
(
viewState
:
ArticleScreenViewState
.
ArticleLoaded
)
{
title
.
text
=
viewState
.
item
.
title
title
.
text
=
viewState
.
item
.
title
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenPresenter.kt
View file @
0c8af564
...
@@ -20,6 +20,7 @@ class ArticleScreenPresenter @Inject constructor(
...
@@ -20,6 +20,7 @@ class ArticleScreenPresenter @Inject constructor(
@Named
(
ARTICLE_SCREEN_ARTICLEID
)
private
val
selectedArticleId
:
Int
@Named
(
ARTICLE_SCREEN_ARTICLEID
)
private
val
selectedArticleId
:
Int
)
)
:
BigantoBasePresenter
<
ArticleScreen
,
ArticleScreenViewState
>()
{
:
BigantoBasePresenter
<
ArticleScreen
,
ArticleScreenViewState
>()
{
override
fun
defaultErrorViewStateHandler
()
=
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
ArticleScreenViewState
.
SomeError
(
e
)}
{
e
:
ExceptionString
->
ArticleScreenViewState
.
SomeError
(
e
)}
...
@@ -37,6 +38,7 @@ class ArticleScreenPresenter @Inject constructor(
...
@@ -37,6 +38,7 @@ class ArticleScreenPresenter @Inject constructor(
.
mergeWith
(
prefetchCards
)
.
mergeWith
(
prefetchCards
)
.
mergeWith
(
setRead
)
.
mergeWith
(
setRead
)
.
doOnError
{
Timber
.
e
(
it
)}
.
doOnError
{
Timber
.
e
(
it
)}
.
onErrorReturn
(
::
parseError
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenController.kt
View file @
0c8af564
...
@@ -15,6 +15,7 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
...
@@ -15,6 +15,7 @@ import com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.presentation.screen.article.ArticleScreenController
import
com.biganto.visual.roompark.presentation.screen.article.ArticleScreenController
import
com.biganto.visual.roompark.presentation.screen.feed_list.util.ArticlesAdapter
import
com.biganto.visual.roompark.presentation.screen.feed_list.util.ArticlesAdapter
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.switchmaterial.SwitchMaterial
...
@@ -56,10 +57,23 @@ class ArticlesScreenController :
...
@@ -56,10 +57,23 @@ class ArticlesScreenController :
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
feedSubscription
():
Observable
<
Boolean
>
=
override
fun
feedSubscription
():
Observable
<
Boolean
>
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
checkedChanges
()
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
.
checkedChanges
()
.
filter
{
Timber
.
d
(
"silentCheck: $silentCheck"
)
if
(!
silentCheck
)
return
@filter
!
silentCheck
else
silentCheck
=
false
silentCheck
}
.
doOnNext
{
}
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
var
silentCheck
=
true
set
(
value
)
{
Timber
.
d
(
"silent value: old: $field new $value"
)
field
=
value
}
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
...
@@ -136,6 +150,7 @@ class ArticlesScreenController :
...
@@ -136,6 +150,7 @@ class ArticlesScreenController :
is
ArticlesScreenViewState
.
RestoreView
->
render
(
viewState
)
is
ArticlesScreenViewState
.
RestoreView
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SomeError
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SomeError
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
ArticlesScreenViewState
.
SubscriptionError
->
render
(
viewState
)
}
}
}
}
...
@@ -151,11 +166,28 @@ class ArticlesScreenController :
...
@@ -151,11 +166,28 @@ class ArticlesScreenController :
}
}
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionStatus
)
{
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionStatus
)
{
Timber
.
d
(
"got state: ${viewState.subState}"
)
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
if
(
sw
.
isChecked
!=
viewState
.
subState
)
viewState
.
subState
{
silentCheck
=
true
sw
.
isChecked
!=
sw
.
isChecked
}
}
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionError
)
{
val
sw
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
)
if
(
sw
.
isChecked
!=
viewState
.
subState
)
{
silentCheck
=
true
}
}
sw
.
isChecked
=
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
:
ArticlesScreenViewState
.
ArticlesScrollPage
){
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
ArticlesScrollPage
){
Timber
.
d
(
"got items: ${viewState.items.size}"
)
Timber
.
d
(
"got items: ${viewState.items.size}"
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenPresenter.kt
View file @
0c8af564
...
@@ -38,11 +38,12 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -38,11 +38,12 @@ class ArticlesScreenPresenter @Inject constructor(
Timber
.
d
(
"feedId : $feedId"
)
Timber
.
d
(
"feedId : $feedId"
)
val
onSubChecked
=
intent
(
ArticlesScreen
::
feedSubscription
)
val
onSubChecked
=
intent
(
ArticlesScreen
::
feedSubscription
)
.
skip
(
1
)
//
.skip(1)
.
filter
{
restoreModel
.
sub
!=
null
}
.
filter
{
restoreModel
.
sub
!=
null
}
.
flatMap
{
newState
->
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
SubscriptionStatus
(
newState
)))
.
andThen
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
SubscriptionStatus
(
newState
)))
.
onErrorReturn
{
ArticlesScreenViewState
.
SubscriptionError
(!
newState
)
}
}
}
...
@@ -51,7 +52,8 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -51,7 +52,8 @@ class ArticlesScreenPresenter @Inject constructor(
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
val
getNewArticlesPage
=
intent
(
ArticlesScreen
::
requsetsNewArticles
)
val
getNewArticlesPage
=
intent
(
ArticlesScreen
::
requsetsNewArticles
)
.
flatMap
{
interactor
.
fetchArticlesPage
(
feedId
,
FEED_PAGE_SIZE
,
it
)
}
.
flatMap
{
interactor
.
fetchArticlesPage
(
feedId
,
FEED_PAGE_SIZE
,
it
)
.
map
<
ArticlesScreenViewState
>
{
articlePage
->
.
map
<
ArticlesScreenViewState
>
{
articlePage
->
articlePage
.
articles
articlePage
.
articles
.
asSequence
()
.
asSequence
()
...
@@ -61,6 +63,7 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -61,6 +63,7 @@ class ArticlesScreenPresenter @Inject constructor(
ArticlesScreenViewState
.
ArticlesScrollPage
(
articlePage
.
articles
.
toList
())
ArticlesScreenViewState
.
ArticlesScrollPage
(
articlePage
.
articles
.
toList
())
}
}
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
}
val
fetchSubscription
=
interactor
.
getSubscriptions
(
feedId
)
val
fetchSubscription
=
interactor
.
getSubscriptions
(
feedId
)
.
doOnNext
{
Timber
.
w
(
"got smthng: $it"
)
}
.
doOnNext
{
Timber
.
w
(
"got smthng: $it"
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenViewState.kt
View file @
0c8af564
...
@@ -17,6 +17,7 @@ sealed class ArticlesScreenViewState : BigantoBaseViewState() {
...
@@ -17,6 +17,7 @@ sealed class ArticlesScreenViewState : BigantoBaseViewState() {
class
ArticlesScrollPage
(
val
items
:
List
<
ArticlePreviewModel
>)
:
ArticlesScreenViewState
()
class
ArticlesScrollPage
(
val
items
:
List
<
ArticlePreviewModel
>)
:
ArticlesScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
ArticlesScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
ArticlesScreenViewState
()
class
SubscriptionStatus
(
val
subState
:
Boolean
)
:
ArticlesScreenViewState
()
class
SubscriptionStatus
(
val
subState
:
Boolean
)
:
ArticlesScreenViewState
()
class
SubscriptionError
(
val
subState
:
Boolean
)
:
ArticlesScreenViewState
()
}
}
...
...
app/src/main/res/values/strings.xml
View file @
0c8af564
...
@@ -92,6 +92,8 @@
...
@@ -92,6 +92,8 @@
<string
name=
"tour_not_allowed"
>
Запуск туров пока недоступен!
</string>
<string
name=
"tour_not_allowed"
>
Запуск туров пока недоступен!
</string>
<string
name=
"content_description_close"
>
Close
</string>
<string
name=
"content_description_close"
>
Close
</string>
<string
name=
"share_house_photo"
>
Поделиться изображением
</string>
<string
name=
"share_house_photo"
>
Поделиться изображением
</string>
<string
name=
"unsubscribe_error_message"
>
При попытке отписаться произошла ошибка!
</string>
<string
name=
"subscribe_error_message"
>
Ошибка! Подписаться не удалось!
</string>
<!--endregion-->
<!--endregion-->
</resources>
</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