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
bba046fb
Commit
bba046fb
authored
Nov 22, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
albums junctions
parent
b18b3d12
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
178 additions
and
38 deletions
+178
-38
AlbumsRepository.kt
...to/visual/roompark/data/data_provider/AlbumsRepository.kt
+87
-0
FeedsRepository.kt
...nto/visual/roompark/data/data_provider/FeedsRepository.kt
+2
-1
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+6
-5
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+20
-5
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+16
-5
DevProgressContract.kt
...to/visual/roompark/domain/contract/DevProgressContract.kt
+5
-5
albums.kt
...n/java/com/biganto/visual/roompark/domain/model/albums.kt
+13
-1
ScreenContract.kt
...sual/roompark/presentation/screen/feeds/ScreenContract.kt
+1
-0
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+20
-14
ScreenPresenter.kt
...ual/roompark/presentation/screen/feeds/ScreenPresenter.kt
+6
-0
ScreenViewState.kt
...ual/roompark/presentation/screen/feeds/ScreenViewState.kt
+2
-0
feeds_block_view.xml
app/src/main/res/layout/feeds_block_view.xml
+0
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AlbumsRepository.kt
0 → 100644
View file @
bba046fb
package
com.biganto.visual.roompark.data.data_provider
import
com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumJunctionEntity
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.DevProgressContract
import
com.biganto.visual.roompark.domain.model.*
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
*/
//@Singleton
class
AlbumsContractModule
@Inject
constructor
(
private
val
api
:
IRoomParkApi
,
private
val
db
:
IDb
):
DevProgressContract
{
override
fun
getProgressCards
():
Observable
<
List
<
AlbumPreviewModel
>>
=
fetchTopLevelAlbums
()
override
fun
getProgressAlbumList
(
albumId
:
Int
):
Observable
<
List
<
AlbumPreviewModel
>>
=
fetchTopLevelAlbums
()
override
fun
getAlbumPhoto
(
photoId
:
Int
):
Observable
<
PhotoModel
>
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
getWebCamsList
():
Observable
<
WebCamListModel
>
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
getWebCamStream
(
camId
:
Int
):
Observable
<
WebCamModel
>
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
init
{
Timber
.
d
(
"Devs Repository Created"
)
}
private
val
fetchTopLevelAlbumsApi
=
api
.
getAlbums
()
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
private
val
fetchTopLevelAlbumsDb
=
db
.
getTopLevelAlbums
()
.
toList
()
.
toObservable
()
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchTopLevelAlbums
():
Observable
<
List
<
AlbumPreviewModel
>>
=
Observable
.
mergeDelayError
(
arrayListOf
(
fetchTopLevelAlbumsApi
,
fetchTopLevelAlbumsDb
)
).
take
(
1
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
private
fun
fetchAlbums
(
parentAlbumId
:
Int
)
=
api
.
getAlbums
(
parentAlbumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
{
it
.
asSequence
().
map
{
album
->
if
(
db
.
checkIfExistsAlbumJunction
(
album
.
id
,
parentAlbumId
)
!=
null
)
{
return
@map
null
}
val
entity
=
ImageAlbumJunctionEntity
()
entity
.
setAlbumId
(
album
.
id
)
entity
.
setParentId
(
parentAlbumId
)
entity
}.
filterNotNull
().
toList
().
also
{
junctions
->
db
.
blockingUpsert
(
junctions
)
}
}
.
subscribeOn
(
Schedulers
.
io
())
}
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FeedsRepository.kt
View file @
bba046fb
...
@@ -4,6 +4,7 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
...
@@ -4,6 +4,7 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.FeedsContract
import
com.biganto.visual.roompark.domain.contract.FeedsContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import
com.biganto.visual.roompark.domain.model.ArticlePreviewModel
...
@@ -82,7 +83,7 @@ class FeedsContractModule @Inject constructor(
...
@@ -82,7 +83,7 @@ class FeedsContractModule @Inject constructor(
private
fun
fetchFeedsApi
()
=
private
fun
fetchFeedsApi
()
=
api
.
getFeeds
()
api
.
getFeeds
()
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
(
::
fromRaw
)
.
map
{
fromRawList
(
it
,
::
fromRaw
)}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
bba046fb
package
com.biganto.visual.roompark.data.repository.db
package
com.biganto.visual.roompark.data.repository.db
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.*
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FeedEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.Single
import
io.reactivex.Single
import
io.requery.Persistable
import
io.requery.Persistable
...
@@ -18,7 +16,10 @@ interface IDb {
...
@@ -18,7 +16,10 @@ interface IDb {
fun
fetchFeeds
():
Observable
<
FeedEntity
>
fun
fetchFeeds
():
Observable
<
FeedEntity
>
fun
fetchUser
(
uuid
:
Int
):
Observable
<
UserEntity
>
fun
fetchUser
(
uuid
:
Int
):
Observable
<
UserEntity
>
fun
<
T
:
List
<
Persistable
>
>
blockingUpsert
(
entity
:
T
)
fun
<
T
:
List
<
Persistable
>
>
blockingUpsert
(
entity
:
T
)
fun
userObservableResult
(
uuid
:
Int
):
Observable
<
ReactiveResult
<
UserEntity
>>
?
fun
userObservableResult
(
uuid
:
Int
):
Observable
<
ReactiveResult
<
UserEntity
>>
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
ArticleEntity
>
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
ArticleEntity
>
fun
getFeed
(
feedId
:
Int
):
ReactiveResult
<
FeedEntity
>?
fun
getFeed
(
feedId
:
Int
):
ReactiveResult
<
FeedEntity
>
fun
getTopLevelAlbums
():
Observable
<
ImageAlbumEntity
>
fun
getChildAlbums
(
parentId
:
Int
):
Observable
<
ImageAlbumEntity
>
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
):
ImageAlbumJunctionEntity
?
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
bba046fb
...
@@ -2,10 +2,7 @@ package com.biganto.visual.roompark.data.repository.db.requrey
...
@@ -2,10 +2,7 @@ package com.biganto.visual.roompark.data.repository.db.requrey
import
android.content.Context
import
android.content.Context
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.*
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FeedEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.Models
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
import
com.biganto.visual.roompark.di.dagger.DATABASE_VERSION
import
dagger.Module
import
dagger.Module
import
dagger.Provides
import
dagger.Provides
...
@@ -66,10 +63,21 @@ class RequeryRepository @Inject constructor(
...
@@ -66,10 +63,21 @@ class RequeryRepository @Inject constructor(
override
fun
fetchFeeds
():
Observable
<
FeedEntity
>
=
override
fun
fetchFeeds
():
Observable
<
FeedEntity
>
=
fetchAll
<
FeedEntity
>().
get
().
observable
()
fetchAll
<
FeedEntity
>().
get
().
observable
()
override
fun
getFeed
(
feedId
:
Int
):
ReactiveResult
<
FeedEntity
>
?
=
override
fun
getFeed
(
feedId
:
Int
):
ReactiveResult
<
FeedEntity
>
=
fetchAll
<
FeedEntity
>().
where
(
FeedEntity
.
ID
.
eq
(
feedId
))
fetchAll
<
FeedEntity
>().
where
(
FeedEntity
.
ID
.
eq
(
feedId
))
.
get
()
.
get
()
override
fun
getTopLevelAlbums
():
Observable
<
ImageAlbumEntity
>
=
fetchAll
<
ImageAlbumEntity
>()
.
get
().
observable
()
override
fun
getChildAlbums
(
parentId
:
Int
):
Observable
<
ImageAlbumEntity
>
=
store
.
select
(
ImageAlbumEntity
::
class
)
.
join
(
ImageAlbumJunctionEntity
::
class
)
.
on
(
ImageAlbumJunctionEntity
.
ALBUM_ID
.
eq
(
ImageAlbumEntity
.
ID
))
.
where
(
ImageAlbumJunctionEntity
.
PARENT_ID
.
eq
(
parentId
))
.
get
().
observable
()
override
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
override
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
ArticleEntity
>
=
:
Observable
<
ArticleEntity
>
=
fetchAll
<
ArticleEntity
>()
fetchAll
<
ArticleEntity
>()
...
@@ -79,6 +87,13 @@ class RequeryRepository @Inject constructor(
...
@@ -79,6 +87,13 @@ class RequeryRepository @Inject constructor(
.
offset
(
startIndex
)
.
offset
(
startIndex
)
.
get
().
observable
()
.
get
().
observable
()
override
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
)
=
fetchAll
<
ImageAlbumJunctionEntity
>()
.
where
(
ImageAlbumJunctionEntity
.
ALBUM_ID
.
eq
(
albumId
))
.
and
(
ImageAlbumJunctionEntity
.
PARENT_ID
.
eq
(
parentAlbumId
))
.
get
()
.
firstOrNull
()
override
fun
fetchUser
(
uuid
:
Int
):
Observable
<
UserEntity
>
=
override
fun
fetchUser
(
uuid
:
Int
):
Observable
<
UserEntity
>
=
fetchAll
<
UserEntity
>().
where
(
UserEntity
.
UUID
.
eq
(
uuid
)).
get
().
observable
()
fetchAll
<
UserEntity
>().
where
(
UserEntity
.
UUID
.
eq
(
uuid
)).
get
().
observable
()
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
bba046fb
package
com.biganto.visual.roompark.data.repository.mapper
package
com.biganto.visual.roompark.data.repository.mapper
import
android.content.res.Resources
import
android.content.res.Resources
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.ArticleRaw
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.*
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.AuthRaw
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.FeedRaw
import
com.biganto.visual.roompark.data.repository.api.retrofit.raw.NewsArticleRaw
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FeedEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.FeedEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import
kotlin.math.max
import
kotlin.math.max
...
@@ -62,7 +60,20 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
...
@@ -62,7 +60,20 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
return
entity
return
entity
}
}
fun
fromRaw
(
raw
:
List
<
FeedRaw
>):
List
<
FeedEntity
>
=
List
(
raw
.
size
)
{
index
->
fromRaw
(
raw
[
index
])
}
fun
fromRaw
(
raw
:
ImageAlbumRaw
)
:
ImageAlbumEntity
{
val
entity
=
ImageAlbumEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setPublished
(
raw
.
date
)
entity
.
setSort
(
raw
.
sort
)
return
entity
}
//fun fromRaw(raw: List<FeedRaw>):List<FeedEntity> = List(raw.size) { index-> fromRaw(raw[index]) }
fun
<
E
,
M
>
fromRawList
(
raw
:
List
<
E
>,
block
:(
E
)->
M
):
List
<
M
>
=
List
(
raw
.
size
)
{
index
->
block
(
raw
[
index
])
}
fun
fromRaw
(
raw
:
List
<
NewsArticleRaw
>,
feedId
:
Int
):
List
<
ArticleEntity
>
=
fun
fromRaw
(
raw
:
List
<
NewsArticleRaw
>,
feedId
:
Int
):
List
<
ArticleEntity
>
=
List
(
raw
.
size
)
{
index
->
fromRaw
(
raw
[
index
],
feedId
)
}
List
(
raw
.
size
)
{
index
->
fromRaw
(
raw
[
index
],
feedId
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DevProgressContract.kt
View file @
bba046fb
...
@@ -13,9 +13,9 @@ import io.reactivex.rxjava3.core.Single
...
@@ -13,9 +13,9 @@ import io.reactivex.rxjava3.core.Single
interface
DevProgressContract
{
interface
DevProgressContract
{
fun
getProgressCards
():
Sing
le
<
List
<
AlbumPreviewModel
>>
fun
getProgressCards
():
io
.
reactivex
.
Observab
le
<
List
<
AlbumPreviewModel
>>
fun
getProgressAlbumList
(
albumId
:
Int
):
Observable
<
List
<
AlbumPreviewModel
>>
fun
getProgressAlbumList
(
albumId
:
Int
):
io
.
reactivex
.
Observable
<
List
<
AlbumPreviewModel
>>
fun
getAlbumPhoto
(
photoId
:
Int
):
Observable
<
PhotoModel
>
fun
getAlbumPhoto
(
photoId
:
Int
):
io
.
reactivex
.
Observable
<
PhotoModel
>
fun
getWebCamsList
():
Sing
le
<
WebCamListModel
>
fun
getWebCamsList
():
io
.
reactivex
.
Observab
le
<
WebCamListModel
>
fun
getWebCamStream
(
camId
:
Int
):
Sing
le
<
WebCamModel
>
fun
getWebCamStream
(
camId
:
Int
):
io
.
reactivex
.
Observab
le
<
WebCamModel
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/model/albums.kt
View file @
bba046fb
package
com.biganto.visual.roompark.domain.model
package
com.biganto.visual.roompark.domain.model
import
com.biganto.visual.roompark.data.repository.db.requrey.model.ImageAlbumEntity
import
java.util.*
import
java.util.*
/**
/**
...
@@ -32,4 +33,15 @@ data class PhotoResolutionModel(
...
@@ -32,4 +33,15 @@ data class PhotoResolutionModel(
val
url
:
String
,
val
url
:
String
,
val
resWidth
:
Int
,
val
resWidth
:
Int
,
val
resHeight
:
Int
val
resHeight
:
Int
)
)
\ No newline at end of file
fun
fromEntity
(
entity
:
ImageAlbumEntity
):
AlbumPreviewModel
=
AlbumPreviewModel
(
albumId
=
entity
.
id
,
parentId
=
-
1
,
published
=
entity
.
published
,
title
=
entity
.
title
,
previewUrl
=
""
,
// SHOULD BE FIRST AVALIABLE IMAGE FROM ALBUM PHOTOS
isRead
=
false
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenContract.kt
View file @
bba046fb
...
@@ -11,6 +11,7 @@ import io.reactivex.Observable
...
@@ -11,6 +11,7 @@ import io.reactivex.Observable
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
fun
feedsTabSelected
():
Observable
<
Int
>
fun
feedsTabSelected
():
Observable
<
Int
>
fun
requsetsNewArticles
():
Observable
<
Pair
<
FeedModel
,
Int
>>
fun
requsetsNewArticles
():
Observable
<
Pair
<
FeedModel
,
Int
>>
fun
onAllFeedArticles
():
Observable
<
FeedModel
>
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
bba046fb
package
com.biganto.visual.roompark.presentation.screen.feeds
package
com.biganto.visual.roompark.presentation.screen.feeds
import
android.annotation.SuppressLint
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
...
@@ -70,6 +69,10 @@ class FeedsScreenController :
...
@@ -70,6 +69,10 @@ class FeedsScreenController :
@BindView
(
R
.
id
.
feedsBlock
)
@BindView
(
R
.
id
.
feedsBlock
)
lateinit
var
feedsBlockView
:
ViewGroup
lateinit
var
feedsBlockView
:
ViewGroup
@BindView
(
R
.
id
.
to_feed_articles
)
lateinit
var
allFeedArticles
:
MaterialTextView
override
fun
requsetsNewArticles
()
=
override
fun
requsetsNewArticles
()
=
feedsRecyclerView
.
scrollStateChanges
()
feedsRecyclerView
.
scrollStateChanges
()
...
@@ -109,21 +112,16 @@ class FeedsScreenController :
...
@@ -109,21 +112,16 @@ class FeedsScreenController :
@Inject
@Inject
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
override
lateinit
var
injectedPresenter
:
FeedsScreenPresenter
override
fun
onAllFeedArticles
():
Observable
<
FeedModel
>
=
allFeedArticles
.
clicks
()
.
map
{
feedsTabs
.
getTabAt
(
feedsTabs
.
selectedTabPosition
)}
.
map
{
storedFeedsList
[
it
.
position
]
}
override
fun
onViewBound
(
v
:
View
)
{
override
fun
onViewBound
(
v
:
View
)
{
toolBar
.
hideAll
()
toolBar
.
hideAll
()
bindRecycler
()
bindRecycler
()
feedsBlockView
.
findViewById
<
MaterialTextView
>(
R
.
id
.
to_feed_articles
).
clicks
()
.
map
{
feedsTabs
.
getTabAt
(
feedsTabs
.
selectedTabPosition
)}
.
map
{
it
.
tag
as
?
Int
}
.
subscribe
{
it
?.
let
{
router
.
pushController
(
RouterTransaction
.
with
(
ArticlesScreenController
(
it
))
.
popChangeHandler
(
FadeChangeHandler
())
.
pushChangeHandler
(
FadeChangeHandler
())
)
}
}
}
}
override
fun
render
(
viewState
:
FeedsScreenViewState
)
{
override
fun
render
(
viewState
:
FeedsScreenViewState
)
{
...
@@ -137,6 +135,7 @@ class FeedsScreenController :
...
@@ -137,6 +135,7 @@ class FeedsScreenController :
is
FeedsScreenViewState
.
CamsList
->
render
(
viewState
)
is
FeedsScreenViewState
.
CamsList
->
render
(
viewState
)
is
FeedsScreenViewState
.
GetFeedArticlesPreview
->
render
(
viewState
)
is
FeedsScreenViewState
.
GetFeedArticlesPreview
->
render
(
viewState
)
is
FeedsScreenViewState
.
RestoreView
->
render
(
viewState
)
is
FeedsScreenViewState
.
RestoreView
->
render
(
viewState
)
is
FeedsScreenViewState
.
ToArticlesScreen
->
render
(
viewState
)
is
FeedsScreenViewState
.
SomeError
->
render
(
viewState
)
is
FeedsScreenViewState
.
SomeError
->
render
(
viewState
)
}
}
}
}
...
@@ -145,12 +144,19 @@ class FeedsScreenController :
...
@@ -145,12 +144,19 @@ class FeedsScreenController :
}
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
ToArticlesScreen
)
{
router
.
pushController
(
RouterTransaction
.
with
(
ArticlesScreenController
(
viewState
.
feedId
))
.
popChangeHandler
(
FadeChangeHandler
())
.
pushChangeHandler
(
FadeChangeHandler
())
)
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
FeedsScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
private
fun
allFeedName
(
feedId
:
Int
)
=
if
(
feedId
==
1
)
"НОВОСТИ"
else
"БЛОГИ"
private
fun
allFeedName
(
feedId
:
Int
)
=
if
(
feedId
==
1
)
"НОВОСТИ"
else
"БЛОГИ"
@SuppressLint
(
"SetTextI18n"
)
private
fun
render
(
viewState
:
FeedsScreenViewState
.
FeedsPages
){
private
fun
render
(
viewState
:
FeedsScreenViewState
.
FeedsPages
){
feedsTabs
.
removeAllTabs
()
feedsTabs
.
removeAllTabs
()
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenPresenter.kt
View file @
bba046fb
...
@@ -63,6 +63,11 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -63,6 +63,11 @@ class FeedsScreenPresenter @Inject constructor(
FeedsScreenViewState
.
GetFeedArticlesPreview
(
it
.
articles
.
toList
())
FeedsScreenViewState
.
GetFeedArticlesPreview
(
it
.
articles
.
toList
())
}
}
val
switchToAllArtiles
=
intent
(
FeedsScreen
::
onAllFeedArticles
)
.
map
{
FeedsScreenViewState
.
ToArticlesScreen
(
it
.
feedId
)
}
val
getNewArticlesPage
=
intent
(
FeedsScreen
::
requsetsNewArticles
)
val
getNewArticlesPage
=
intent
(
FeedsScreen
::
requsetsNewArticles
)
.
flatMap
{
interactor
.
fetchArticles
(
it
.
first
.
feedId
,
FEED_PREVIEW_PAGE_SIZE
,
it
.
second
)
}
.
flatMap
{
interactor
.
fetchArticles
(
it
.
first
.
feedId
,
FEED_PREVIEW_PAGE_SIZE
,
it
.
second
)
}
.
map
{
.
map
{
...
@@ -76,6 +81,7 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -76,6 +81,7 @@ class FeedsScreenPresenter @Inject constructor(
.
mergeWith
(
fetchAlbums
)
.
mergeWith
(
fetchAlbums
)
.
mergeWith
(
fetchCams
)
.
mergeWith
(
fetchCams
)
.
mergeWith
(
getNewArticlesPage
)
.
mergeWith
(
getNewArticlesPage
)
.
mergeWith
(
switchToAllArtiles
)
.
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 @
bba046fb
...
@@ -24,6 +24,8 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
...
@@ -24,6 +24,8 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
class
RestoreView
(
val
restore
:
RestoreModel
)
:
FeedsScreenViewState
()
class
RestoreView
(
val
restore
:
RestoreModel
)
:
FeedsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FeedsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FeedsScreenViewState
()
class
ToArticlesScreen
(
val
feedId
:
Int
)
:
FeedsScreenViewState
()
}
}
data class
RestoreModel
(
data class
RestoreModel
(
...
...
app/src/main/res/layout/feeds_block_view.xml
View file @
bba046fb
...
@@ -25,8 +25,6 @@
...
@@ -25,8 +25,6 @@
android:id=
"@+id/feedsRecyclerView"
android:id=
"@+id/feedsRecyclerView"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:layout_marginTop=
"16dp"
android:layout_marginBottom=
"8dp"
app:layout_constraintBottom_toTopOf=
"@+id/feeds_divider"
app:layout_constraintBottom_toTopOf=
"@+id/feeds_divider"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"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