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
18718e87
Commit
18718e87
authored
Oct 14, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetch articles
parent
4ad06ff2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
3 deletions
+28
-3
build.gradle
app/build.gradle
+1
-0
ScreenContract.kt
...sual/roompark/presentation/screen/feeds/ScreenContract.kt
+2
-0
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+18
-2
ScreenPresenter.kt
...ual/roompark/presentation/screen/feeds/ScreenPresenter.kt
+5
-0
ScreenViewState.kt
...ual/roompark/presentation/screen/feeds/ScreenViewState.kt
+2
-0
feeds_tab_view.xml
app/src/main/res/layout/feeds_tab_view.xml
+0
-1
No files found.
app/build.gradle
View file @
18718e87
...
@@ -117,6 +117,7 @@ dependencies {
...
@@ -117,6 +117,7 @@ dependencies {
//RxBinding
//RxBinding
implementation
"com.jakewharton.rxbinding3:rxbinding:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-recyclerview:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-recyclerview:$rxBindingVersion"
implementation
"com.jakewharton.rxbinding3:rxbinding-material:$rxBindingVersion"
//Tests
//Tests
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenContract.kt
View file @
18718e87
package
com.biganto.visual.roompark.presentation.screen.feeds
package
com.biganto.visual.roompark.presentation.screen.feeds
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
fun
feedsTabSelected
():
Observable
<
Int
>
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
18718e87
...
@@ -7,9 +7,12 @@ import com.biganto.visual.roompark.R
...
@@ -7,9 +7,12 @@ import com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.
presentation.screen.feeds.utils.FeedsPagerAdapter
import
com.biganto.visual.roompark.
domain.model.FeedModel
import
com.google.android.material.tabs.TabLayout
import
com.google.android.material.tabs.TabLayout
import
com.jakewharton.rxbinding3.material.selections
import
io.reactivex.Observable
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -22,6 +25,12 @@ class FeedsScreenController :
...
@@ -22,6 +25,12 @@ class FeedsScreenController :
,
FeedsScreenPresenter
>()
,
FeedsScreenPresenter
>()
,
FeedsScreen
{
,
FeedsScreen
{
override
fun
feedsTabSelected
():
Observable
<
Int
>
=
feedsTabs
.
selections
().
map
{
it
.
position
}
.
debounce
(
200L
,
TimeUnit
.
MILLISECONDS
)
.
map
{
storedFeedsList
[
it
].
feedId
}
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
getComponent
()
getComponent
()
}
}
...
@@ -29,7 +38,8 @@ class FeedsScreenController :
...
@@ -29,7 +38,8 @@ class FeedsScreenController :
@BindView
(
R
.
id
.
feedsTabs
)
@BindView
(
R
.
id
.
feedsTabs
)
lateinit
var
feedsTabs
:
TabLayout
lateinit
var
feedsTabs
:
TabLayout
val
feedsAdapter
=
FeedsPagerAdapter
()
private
var
storedFeedsList
:
List
<
FeedModel
>
=
arrayListOf
()
@Inject
@Inject
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
...
@@ -45,6 +55,7 @@ class FeedsScreenController :
...
@@ -45,6 +55,7 @@ class FeedsScreenController :
when
(
viewState
){
when
(
viewState
){
is
FeedsScreenViewState
.
Idle
->
render
(
viewState
)
is
FeedsScreenViewState
.
Idle
->
render
(
viewState
)
is
FeedsScreenViewState
.
FeedsPages
->
render
(
viewState
)
is
FeedsScreenViewState
.
FeedsPages
->
render
(
viewState
)
is
FeedsScreenViewState
.
GetFeedArticlesPreview
->
render
(
viewState
)
}
}
}
}
...
@@ -68,7 +79,12 @@ class FeedsScreenController :
...
@@ -68,7 +79,12 @@ class FeedsScreenController :
}
}
feedsTabs
.
addTab
(
tab
)
feedsTabs
.
addTab
(
tab
)
}
}
storedFeedsList
=
viewState
.
items
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
GetFeedArticlesPreview
){
snackbar
.
showSnackBar
(
viewState
.
items
.
first
().
announce
)
}
}
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
private
fun
getComponent
()
=
DaggerFeedsScreenComponent
.
factory
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenPresenter.kt
View file @
18718e87
...
@@ -23,8 +23,13 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -23,8 +23,13 @@ class FeedsScreenPresenter @Inject constructor(
val
fetchFeeds
=
interactor
.
fetchTopFeeds
()
val
fetchFeeds
=
interactor
.
fetchTopFeeds
()
.
map
{
FeedsScreenViewState
.
FeedsPages
(
it
.
feeds
.
toList
())
}
.
map
{
FeedsScreenViewState
.
FeedsPages
(
it
.
feeds
.
toList
())
}
val
getFeedArticlesPreview
=
intent
(
FeedsScreen
::
feedsTabSelected
)
.
flatMapSingle
{
interactor
.
fetchArticles
(
it
)
}
.
map
{
FeedsScreenViewState
.
GetFeedArticlesPreview
(
it
.
articles
.
toList
())
}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchFeeds
)
.
mergeWith
(
fetchFeeds
)
.
mergeWith
(
getFeedArticlesPreview
)
.
doOnError
{
Timber
.
e
(
it
)}
.
doOnError
{
Timber
.
e
(
it
)}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenViewState.kt
View file @
18718e87
package
com.biganto.visual.roompark.presentation.screen.feeds
package
com.biganto.visual.roompark.presentation.screen.feeds
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import
com.biganto.visual.roompark.domain.model.FeedModel
import
com.biganto.visual.roompark.domain.model.FeedModel
/**
/**
...
@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.FeedModel
...
@@ -11,4 +12,5 @@ import com.biganto.visual.roompark.domain.model.FeedModel
sealed
class
FeedsScreenViewState
:
BigantoBaseViewState
()
{
sealed
class
FeedsScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
FeedsScreenViewState
()
class
Idle
:
FeedsScreenViewState
()
class
FeedsPages
(
val
items
:
List
<
FeedModel
>)
:
FeedsScreenViewState
()
class
FeedsPages
(
val
items
:
List
<
FeedModel
>)
:
FeedsScreenViewState
()
class
GetFeedArticlesPreview
(
val
items
:
List
<
ArticlePreviewModel
>)
:
FeedsScreenViewState
()
}
}
\ No newline at end of file
app/src/main/res/layout/feeds_tab_view.xml
View file @
18718e87
...
@@ -23,7 +23,6 @@
...
@@ -23,7 +23,6 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignEnd=
"@id/tab_title"
android:layout_alignEnd=
"@id/tab_title"
android:layout_marginStart=
"16dp"
android:layout_marginStart=
"16dp"
android:layout_marginEnd=
"16dp"
android:text=
"@string/feeds_tab_divider"
android:text=
"@string/feeds_tab_divider"
android:textColor=
"@color/colorInvertedNoticeText"
android:textColor=
"@color/colorInvertedNoticeText"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintBottom_toBottomOf=
"parent"
...
...
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