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
3c99913b
Commit
3c99913b
authored
Mar 27, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
on sub chagned for article list
parent
30f6e216
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
1 deletion
+26
-1
articles.kt
...com/biganto/visual/roompark/domain/interactor/articles.kt
+8
-0
ScreenContract.kt
.../roompark/presentation/screen/feed_list/ScreenContract.kt
+1
-0
ScreenController.kt
...oompark/presentation/screen/feed_list/ScreenController.kt
+9
-0
ScreenPresenter.kt
...roompark/presentation/screen/feed_list/ScreenPresenter.kt
+8
-0
Adapter.kt
...al/roompark/presentation/screen/feed_list/util/Adapter.kt
+0
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/domain/interactor/articles.kt
View file @
3c99913b
package
com.biganto.visual.roompark.domain.interactor
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionTopic
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.FeedUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
com.biganto.visual.roompark.domain.use_case.SubscriptionUseCase
import
io.reactivex.Completable
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -23,6 +25,12 @@ class ArticlesInteractor @Inject constructor(
...
@@ -23,6 +25,12 @@ class ArticlesInteractor @Inject constructor(
fun
getSubscriptions
(
feed
:
String
)
=
fun
getSubscriptions
(
feed
:
String
)
=
subUc
.
getSubscriptions
(
feedSubType
(
feed
))
subUc
.
getSubscriptions
(
feedSubType
(
feed
))
fun
switchSubscription
(
model
:
SubscriptionModel
,
newState
:
Boolean
):
Completable
=
when
(
newState
){
true
->
subUc
.
subscribeTopic
(
model
.
id
,
model
.
topic
)
false
->
subUc
.
unSubscribeTopic
(
model
.
id
,
model
.
topic
)
}.
ignoreElements
()
private
fun
feedSubType
(
feed
:
String
)
=
private
fun
feedSubType
(
feed
:
String
)
=
when
(
feed
){
when
(
feed
){
"news"
->
SubscriptionTopic
.
News
()
"news"
->
SubscriptionTopic
.
News
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenContract.kt
View file @
3c99913b
...
@@ -9,5 +9,6 @@ import io.reactivex.Observable
...
@@ -9,5 +9,6 @@ import io.reactivex.Observable
interface
ArticlesScreen
:
BigantoBaseContract
<
ArticlesScreenViewState
>
{
interface
ArticlesScreen
:
BigantoBaseContract
<
ArticlesScreenViewState
>
{
fun
requsetsNewArticles
():
Observable
<
Int
>
fun
requsetsNewArticles
():
Observable
<
Int
>
fun
feedSubscription
():
Observable
<
Boolean
>
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenController.kt
View file @
3c99913b
...
@@ -20,6 +20,7 @@ import com.bluelinelabs.conductor.RouterTransaction
...
@@ -20,6 +20,7 @@ import com.bluelinelabs.conductor.RouterTransaction
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.switchmaterial.SwitchMaterial
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.recyclerview.scrollStateChanges
import
com.jakewharton.rxbinding3.recyclerview.scrollStateChanges
import
com.jakewharton.rxbinding3.widget.checkedChanges
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
timber.log.Timber
...
@@ -54,6 +55,13 @@ class ArticlesScreenController :
...
@@ -54,6 +55,13 @@ class ArticlesScreenController :
.
debounce
(
120L
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
120L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
feedSubscription
():
Observable
<
Boolean
>
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
checkedChanges
()
.
debounce
(
600L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
getComponent
()
getComponent
()
}
}
...
@@ -143,6 +151,7 @@ class ArticlesScreenController :
...
@@ -143,6 +151,7 @@ class ArticlesScreenController :
}
}
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionStatus
)
{
private
fun
render
(
viewState
:
ArticlesScreenViewState
.
SubscriptionStatus
)
{
Timber
.
d
(
"got state: ${viewState.subState}"
)
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
toolBar
.
headerToolbar
.
findViewById
<
SwitchMaterial
>(
R
.
id
.
switch1
).
isChecked
=
viewState
.
subState
viewState
.
subState
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenPresenter.kt
View file @
3c99913b
...
@@ -37,6 +37,13 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -37,6 +37,13 @@ class ArticlesScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
override
fun
bindIntents
()
{
Timber
.
d
(
"feedId : $feedId"
)
Timber
.
d
(
"feedId : $feedId"
)
val
onSubChecked
=
intent
(
ArticlesScreen
::
feedSubscription
)
.
flatMap
{
newState
->
interactor
.
switchSubscription
(
restoreModel
.
sub
!!
,
newState
)
.
andThen
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
SubscriptionStatus
(
newState
)))
}
val
prefetchCards
=
interactor
.
fetchArticles
(
feedId
)
val
prefetchCards
=
interactor
.
fetchArticles
(
feedId
)
.
map
<
ArticlesScreenViewState
>
{
ArticlesScreenViewState
.
ArticlesLoaded
(
it
.
articles
)
}
.
map
<
ArticlesScreenViewState
>
{
ArticlesScreenViewState
.
ArticlesLoaded
(
it
.
articles
)
}
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
.
startWith
(
Observable
.
just
<
ArticlesScreenViewState
>(
ArticlesScreenViewState
.
Idle
()))
...
@@ -63,6 +70,7 @@ class ArticlesScreenPresenter @Inject constructor(
...
@@ -63,6 +70,7 @@ class ArticlesScreenPresenter @Inject constructor(
.
mergeWith
(
prefetchCards
)
.
mergeWith
(
prefetchCards
)
.
mergeWith
(
getNewArticlesPage
)
.
mergeWith
(
getNewArticlesPage
)
.
mergeWith
(
fetchSubscription
)
.
mergeWith
(
fetchSubscription
)
.
mergeWith
(
onSubChecked
)
.
doOnError
{
Timber
.
e
(
it
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/util/Adapter.kt
View file @
3c99913b
...
@@ -40,7 +40,6 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
...
@@ -40,7 +40,6 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
override
fun
onViewBound
(
model
:
ArticlePreviewModel
)
{
override
fun
onViewBound
(
model
:
ArticlePreviewModel
)
{
Timber
.
d
(
"readeed?: ${model.isRead} of ${model.title}"
)
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleDate
.
text
=
dateFormatter
.
format
(
model
.
published
)
articleTitle
.
text
=
model
.
title
articleTitle
.
text
=
model
.
title
articleIsRead
.
setGone
(
model
.
isRead
)
articleIsRead
.
setGone
(
model
.
isRead
)
...
...
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