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
4d0a9bdf
Commit
4d0a9bdf
authored
Dec 03, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/api_update' into develop
parents
7fcc5468
0990432a
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
120 additions
and
118 deletions
+120
-118
FeedsRepository.kt
...nto/visual/roompark/data/data_provider/FeedsRepository.kt
+22
-34
IApi.kt
...a/com/biganto/visual/roompark/data/repository/api/IApi.kt
+2
-1
IRoomParkMobileApi.kt
...ompark/data/repository/api/retrofit/IRoomParkMobileApi.kt
+18
-1
RetrofitRepository.kt
...ompark/data/repository/api/retrofit/RetrofitRepository.kt
+10
-1
response.kt
...ual/roompark/data/repository/api/retrofit/raw/response.kt
+14
-1
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+0
-1
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+1
-5
Article.kt
...sual/roompark/data/repository/db/requrey/model/Article.kt
+1
-1
Feed.kt
.../visual/roompark/data/repository/db/requrey/model/Feed.kt
+1
-3
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+8
-25
ContextModule.kt
...va/com/biganto/visual/roompark/di/dagger/ContextModule.kt
+1
-1
DataModule.kt
.../java/com/biganto/visual/roompark/di/dagger/DataModule.kt
+0
-3
FeedsContract.kt
.../biganto/visual/roompark/domain/contract/FeedsContract.kt
+3
-2
articles.kt
...com/biganto/visual/roompark/domain/interactor/articles.kt
+5
-5
feeds.kt
...va/com/biganto/visual/roompark/domain/interactor/feeds.kt
+11
-10
feeds.kt
...in/java/com/biganto/visual/roompark/domain/model/feeds.kt
+4
-5
feedUseCase.kt
...om/biganto/visual/roompark/domain/use_case/feedUseCase.kt
+4
-4
ScreenController.kt
...oompark/presentation/screen/feed_list/ScreenController.kt
+3
-3
ScreenDI.kt
...visual/roompark/presentation/screen/feed_list/ScreenDI.kt
+1
-1
ScreenPresenter.kt
...roompark/presentation/screen/feed_list/ScreenPresenter.kt
+1
-1
ScreenContract.kt
...sual/roompark/presentation/screen/feeds/ScreenContract.kt
+1
-1
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+6
-6
ScreenPresenter.kt
...ual/roompark/presentation/screen/feeds/ScreenPresenter.kt
+2
-2
ScreenViewState.kt
...ual/roompark/presentation/screen/feeds/ScreenViewState.kt
+1
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FeedsRepository.kt
View file @
4d0a9bdf
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntit
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.data.repository.db.requrey.model.ArticleEntit
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.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.model.ArticleModel
import
com.biganto.visual.roompark.domain.model.ArticleModel
import
com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import
com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import
com.biganto.visual.roompark.domain.model.FeedModel
import
com.biganto.visual.roompark.domain.model.FeedModel
...
@@ -31,11 +30,11 @@ class FeedsContractModule @Inject constructor(
...
@@ -31,11 +30,11 @@ class FeedsContractModule @Inject constructor(
override
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
=
override
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
=
fetchAllFeeds
().
doOnError
(
::
e
)
fetchAllFeeds
().
doOnError
(
::
e
)
override
fun
fetchFeedObservable
(
id
:
Int
):
Observable
<
ArticlesPreviewModel
>
=
override
fun
fetchFeedObservable
(
feedAlias
:
String
):
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
id
)
fetchArticles
(
feedAlias
)
override
fun
fetchFeedObservable
(
id
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
)
override
fun
fetchFeedObservable
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
id
,
pageSize
,
startIndex
)
:
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
feedAlias
,
pageSize
,
startIndex
)
override
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
=
override
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
=
fetchArticle
(
id
)
fetchArticle
(
id
)
...
@@ -45,44 +44,36 @@ class FeedsContractModule @Inject constructor(
...
@@ -45,44 +44,36 @@ class FeedsContractModule @Inject constructor(
}
}
private
fun
fetchArticlessApi
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
List
<
ArticleEntity
>>?
{
private
fun
fetchArticlessApi
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
val
feed
=
db
.
getFeed
(
feedId
).
firstOrNull
()
:
Observable
<
List
<
ArticleEntity
>>?
=
api
.
getArticlesPage
(
if
(
feed
==
null
)
{
feedAlias
e
(
"Unknown feedId: $feedId - cann't resolve feed_alias!"
)
,
pageSize
throw
CustomApiException
.
UnknownCustomApiException
(-
1
,
null
,
"Unknown Feed!"
)
,
floor
(
startIndex
.
toDouble
()/
pageSize
.
toDouble
()).
toInt
()+
1
}
)
else
{
return
api
.
getArticlesPage
(
feed
.
alias
,
pageSize
,
floor
(
startIndex
.
toDouble
()/
pageSize
.
toDouble
()).
toInt
()+
1
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
it
.
items
}
.
map
{
it
.
items
}
.
map
{
fromRaw
(
it
,
feed
Id
)
}
.
map
{
fromRaw
(
it
,
feed
Alias
)
}
.
doOnNext
{
Timber
.
d
(
"raw enitites $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw enitites $it"
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
}
}
private
fun
fetchArticlesDb
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
MutableList
<
ArticleEntity
>>?
{
val
feed
=
db
.
getFeed
(
feedId
).
firstOrNull
()
private
fun
fetchArticlesDb
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
Timber
.
d
(
"db startindex: $startIndex"
)
:
Observable
<
MutableList
<
ArticleEntity
>>?
=
if
(
feed
==
null
)
{
db
.
fetchArticles
(
feedAlias
,
pageSize
,
startIndex
)
e
(
"Unknown feedId: $feedId - cann't resolve feed_alias!"
)
throw
CustomApiException
.
UnknownCustomApiException
(-
1
,
null
,
"Unknown Feed!"
)
}
else
return
db
.
fetchArticles
(
feed
.
alias
,
pageSize
,
startIndex
)
.
toList
()
.
toList
()
.
toObservable
()
.
toObservable
()
.
doOnNext
{
Timber
.
d
(
"db items: ${it.size}"
)
}
.
doOnNext
{
Timber
.
d
(
"db items: ${it.size}"
)
}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
}
private
fun
fetchArticles
(
feedId
:
Int
,
pageSize
:
Int
=
10
,
startIndex
:
Int
=
0
):
Observable
<
ArticlesPreviewModel
>
=
private
fun
fetchArticles
(
feedAlias
:
String
,
pageSize
:
Int
=
10
,
startIndex
:
Int
=
0
)
:
Observable
<
ArticlesPreviewModel
>
=
Observable
.
mergeDelayError
(
Observable
.
mergeDelayError
(
arrayListOf
(
fetchArticlessApi
(
feedId
,
pageSize
,
startIndex
),
fetchArticlesDb
(
feedId
,
pageSize
,
startIndex
))
arrayListOf
(
fetchArticlessApi
(
feedAlias
,
pageSize
).
map
{
fromEntity
(
feedId
,
it
)
}
,
startIndex
),
fetchArticlesDb
(
feedAlias
,
pageSize
,
startIndex
)
)
).
map
{
fromEntity
(
feedAlias
,
it
)
}
private
val
fetchFeedsApi
=
private
val
fetchFeedsApi
=
...
@@ -106,10 +97,7 @@ class FeedsContractModule @Inject constructor(
...
@@ -106,10 +97,7 @@ class FeedsContractModule @Inject constructor(
private
fun
fetchArticleApi
(
id
:
Int
)
=
private
fun
fetchArticleApi
(
id
:
Int
)
=
api
.
getArticle
(
id
)
api
.
getArticle
(
id
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
flatMap
{
article
->
.
map
(
::
fromRaw
)
db
.
getFeed
(
article
.
feed_alias
).
observable
()
.
map
{
fromRaw
(
article
,
it
.
id
)
}
}
.
flatMap
{
article
->
.
flatMap
{
article
->
db
.
getArticle
(
article
.
id
).
observable
()
db
.
getArticle
(
article
.
id
).
observable
()
.
map
{
articleEntity
->
.
map
{
articleEntity
->
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/IApi.kt
View file @
4d0a9bdf
...
@@ -40,12 +40,13 @@ interface IRoomParkApi {
...
@@ -40,12 +40,13 @@ interface IRoomParkApi {
showElectric
:
Boolean
showElectric
:
Boolean
):
Observable
<
String
>
):
Observable
<
String
>
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
List
<
PlanRaw
>
>
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
Int
>
fun
getArticlesPage
(
feedName
:
String
,
fun
getArticlesPage
(
feedName
:
String
,
pageSize
:
Int
=
DEFAULT_ARTICLE_PAGE_SIZE
,
pageSize
:
Int
=
DEFAULT_ARTICLE_PAGE_SIZE
,
page
:
Int
):
Observable
<
ArticlesListPaginationRaw
>
page
:
Int
):
Observable
<
ArticlesListPaginationRaw
>
fun
getAlbums
(
parentId
:
Int
?
=
null
):
Observable
<
List
<
ImageAlbumRaw
>>
fun
getAlbums
(
parentId
:
Int
?
=
null
):
Observable
<
List
<
ImageAlbumRaw
>>
fun
getEstate
(
building
:
Int
,
flat
:
Int
):
Observable
<
EstateRaw
>
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/IRoomParkMobileApi.kt
View file @
4d0a9bdf
...
@@ -127,6 +127,13 @@ interface IRoomParkMobileApi{
...
@@ -127,6 +127,13 @@ interface IRoomParkMobileApi{
//endregion
//endregion
//region Get Estate
const
val
GET_ESTATE_ID
=
"estates.getEstate"
const
val
ESTATE_BUILDING_NUMBER_PARAM
=
"building "
const
val
ESTATE_FLAT_NUMBER_PARAM
=
"number "
//endregion
}
}
...
@@ -248,6 +255,7 @@ interface IRoomParkMobileApi{
...
@@ -248,6 +255,7 @@ interface IRoomParkMobileApi{
):
Observable
<
Response
<
String
>>
):
Observable
<
Response
<
String
>>
@Deprecated
(
"change to estates.getEstate method as more common"
)
@GET
(
"$API_URL$GET_MULTITOUR_ID$DELIMITER"
)
@GET
(
"$API_URL$GET_MULTITOUR_ID$DELIMITER"
)
fun
getMultiTourId
(
fun
getMultiTourId
(
@Query
(
CLIENT_TYPE_PARAM
)
clientType
:
String
=
DEFAULT_CLIENT_TYPE
,
@Query
(
CLIENT_TYPE_PARAM
)
clientType
:
String
=
DEFAULT_CLIENT_TYPE
,
...
@@ -255,7 +263,16 @@ interface IRoomParkMobileApi{
...
@@ -255,7 +263,16 @@ interface IRoomParkMobileApi{
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
MULTITOUR_BUILDING_NUMBER_PARAM
)
building
:
Int
,
@Query
(
MULTITOUR_BUILDING_NUMBER_PARAM
)
building
:
Int
,
@Query
(
MULTITOUR_FLAT_NUMBER_PARAM
)
flatNumber
:
Int
@Query
(
MULTITOUR_FLAT_NUMBER_PARAM
)
flatNumber
:
Int
):
Observable
<
Response
<
List
<
PlanRaw
>>>
):
Observable
<
Response
<
Int
>>
@GET
(
"$API_URL$GET_ESTATE_ID$DELIMITER"
)
fun
getEstate
(
@Query
(
CLIENT_TYPE_PARAM
)
clientType
:
String
=
DEFAULT_CLIENT_TYPE
,
@Query
(
CLIENT_VERSION_PARAM
)
clientVersion
:
String
=
DEFAULT_CLIENT_VERSION
,
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
ESTATE_BUILDING_NUMBER_PARAM
)
building
:
Int
,
@Query
(
ESTATE_FLAT_NUMBER_PARAM
)
flatNumber
:
Int
):
Observable
<
Response
<
EstateRaw
>>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/RetrofitRepository.kt
View file @
4d0a9bdf
...
@@ -107,13 +107,22 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
...
@@ -107,13 +107,22 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
)
)
.
compose
(
RetrofitResponseValidation
())
.
compose
(
RetrofitResponseValidation
())
override
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
List
<
PlanRaw
>>
=
@Deprecated
(
"hidden by states.getEstate method"
)
override
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
Int
>
=
api
.
getMultiTourId
(
api
.
getMultiTourId
(
building
=
building
,
building
=
building
,
flatNumber
=
flat
flatNumber
=
flat
)
)
.
compose
(
RetrofitResponseValidation
())
.
compose
(
RetrofitResponseValidation
())
override
fun
getEstate
(
building
:
Int
,
flat
:
Int
):
Observable
<
EstateRaw
>
=
api
.
getEstate
(
building
=
building
,
flatNumber
=
flat
)
.
compose
(
RetrofitResponseValidation
())
}
}
enum
class
PlanTypeCatalog
(
val
planId
:
Int
,
val
planName
:
String
){
enum
class
PlanTypeCatalog
(
val
planId
:
Int
,
val
planName
:
String
){
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/raw/response.kt
View file @
4d0a9bdf
...
@@ -74,7 +74,6 @@ data class EstateRoomRaw(
...
@@ -74,7 +74,6 @@ data class EstateRoomRaw(
)
)
data class
FeedRaw
(
data class
FeedRaw
(
val
id
:
Int
,
val
alias
:
String
,
val
alias
:
String
,
val
title
:
String
val
title
:
String
)
)
...
@@ -99,6 +98,8 @@ data class ArticleRaw(
...
@@ -99,6 +98,8 @@ data class ArticleRaw(
val
id
:
Int
,
val
id
:
Int
,
val
published
:
Date
,
val
published
:
Date
,
val
title
:
String
,
val
title
:
String
,
val
announce
:
String
,
val
preview
:
String
?,
val
body
:
String
,
val
body
:
String
,
val
feed_alias
:
String
,
val
feed_alias
:
String
,
val
photo
:
List
<
NewsPhotoRaw
>?
val
photo
:
List
<
NewsPhotoRaw
>?
...
@@ -156,4 +157,16 @@ data class AppVersionRaw(
...
@@ -156,4 +157,16 @@ data class AppVersionRaw(
val
message
:
String
?,
val
message
:
String
?,
val
critical
:
Boolean
,
val
critical
:
Boolean
,
val
errors
:
List
<
ErrorRaw
>?
val
errors
:
List
<
ErrorRaw
>?
)
data class
WebCamRaw
(
val
id
:
Int
,
val
title
:
String
,
val
Streams
:
List
<
StreamRaw
>
)
data class
StreamRaw
(
val
res_name
:
String
,
val
hls
:
String
,
val
rtmp
:
String
)
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
4d0a9bdf
...
@@ -18,7 +18,6 @@ interface IDb {
...
@@ -18,7 +18,6 @@ interface IDb {
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
getTopLevelAlbums
():
Observable
<
ImageAlbumEntity
>
fun
getTopLevelAlbums
():
Observable
<
ImageAlbumEntity
>
fun
getChildAlbums
(
parentId
:
Int
):
Observable
<
ImageAlbumEntity
>
fun
getChildAlbums
(
parentId
:
Int
):
Observable
<
ImageAlbumEntity
>
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
):
ImageAlbumJunctionEntity
?
fun
checkIfExistsAlbumJunction
(
albumId
:
Int
,
parentAlbumId
:
Int
):
ImageAlbumJunctionEntity
?
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
4d0a9bdf
...
@@ -63,10 +63,6 @@ class RequeryRepository @Inject constructor(
...
@@ -63,10 +63,6 @@ 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
>
=
fetchAll
<
FeedEntity
>().
where
(
FeedEntity
.
ID
.
eq
(
feedId
))
.
get
()
override
fun
getFeed
(
feedAlias
:
String
):
ReactiveResult
<
FeedEntity
>
=
override
fun
getFeed
(
feedAlias
:
String
):
ReactiveResult
<
FeedEntity
>
=
fetchAll
<
FeedEntity
>().
where
(
FeedEntity
.
ALIAS
.
eq
(
feedAlias
))
fetchAll
<
FeedEntity
>().
where
(
FeedEntity
.
ALIAS
.
eq
(
feedAlias
))
.
get
()
.
get
()
...
@@ -89,7 +85,7 @@ class RequeryRepository @Inject constructor(
...
@@ -89,7 +85,7 @@ class RequeryRepository @Inject constructor(
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
>()
.
where
(
ArticleEntity
.
FEED_ID
.
eq
(
1
))
.
where
(
ArticleEntity
.
FEED_ID
.
eq
(
feedAlias
))
.
orderBy
(
ArticleEntity
.
PUBLISHED
.
desc
())
.
orderBy
(
ArticleEntity
.
PUBLISHED
.
desc
())
.
limit
(
pageSize
)
.
limit
(
pageSize
)
.
offset
(
startIndex
)
.
offset
(
startIndex
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/Article.kt
View file @
4d0a9bdf
...
@@ -22,7 +22,7 @@ interface Article : Persistable {
...
@@ -22,7 +22,7 @@ interface Article : Persistable {
val
preview
:
String
?
val
preview
:
String
?
@get
:
Nullable
@get
:
Nullable
val
body
:
String
?
val
body
:
String
?
@get
:
ForeignKey
(
references
=
Feed
::
class
,
referencedColumn
=
"
id
"
)
@get
:
ForeignKey
(
references
=
Feed
::
class
,
referencedColumn
=
"
alias
"
)
@get
:
ManyToOne
(
cascade
=
[
CascadeAction
.
NONE
])
@get
:
ManyToOne
(
cascade
=
[
CascadeAction
.
NONE
])
val
feed
:
Feed
?
val
feed
:
Feed
?
@get
:
Convert
(
TitledPhotoListConverter
::
class
)
@get
:
Convert
(
TitledPhotoListConverter
::
class
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/Feed.kt
View file @
4d0a9bdf
...
@@ -9,11 +9,9 @@ import io.requery.*
...
@@ -9,11 +9,9 @@ import io.requery.*
@Entity
@Entity
interface
Feed
:
Persistable
{
interface
Feed
:
Persistable
{
@get
:
Key
@get
:
Key
val
id
:
Int
val
title
:
String
val
alias
:
String
val
alias
:
String
val
title
:
String
@get
:
JunctionTable
(
name
=
"FeedArticlesRule"
)
@get
:
JunctionTable
(
name
=
"FeedArticlesRule"
)
@get
:
OneToMany
(
cascade
=
[
CascadeAction
.
DELETE
])
@get
:
OneToMany
(
cascade
=
[
CascadeAction
.
DELETE
])
val
articles
:
Set
<
Article
>?
val
articles
:
Set
<
Article
>?
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
4d0a9bdf
...
@@ -27,7 +27,6 @@ fun fromRaw(raw: AuthRaw) : UserEntity {
...
@@ -27,7 +27,6 @@ fun fromRaw(raw: AuthRaw) : UserEntity {
fun
fromRaw
(
raw
:
FeedRaw
)
:
FeedEntity
{
fun
fromRaw
(
raw
:
FeedRaw
)
:
FeedEntity
{
val
entity
=
FeedEntity
()
val
entity
=
FeedEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setAlias
(
raw
.
alias
)
entity
.
setAlias
(
raw
.
alias
)
return
entity
return
entity
...
@@ -36,9 +35,12 @@ fun fromRaw(raw:FeedRaw) : FeedEntity {
...
@@ -36,9 +35,12 @@ fun fromRaw(raw:FeedRaw) : FeedEntity {
fun
fromRaw
(
raw
:
ArticleRaw
)
:
ArticleEntity
{
fun
fromRaw
(
raw
:
ArticleRaw
)
:
ArticleEntity
{
val
entity
=
ArticleEntity
()
val
entity
=
ArticleEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setId
(
raw
.
id
)
entity
.
setPublished
(
raw
.
published
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setBody
(
raw
.
body
)
entity
.
setBody
(
raw
.
body
)
entity
.
setPreview
(
raw
.
feed_alias
)
entity
.
setAnnounce
(
raw
.
announce
)
entity
.
setPreview
(
raw
.
preview
)
raw
.
photo
?.
let
{
entity
.
photo
=
fromRawList
(
it
,
::
fromRaw
)}
val
feed
=
FeedEntity
()
val
feed
=
FeedEntity
()
feed
.
setAlias
(
raw
.
feed_alias
)
feed
.
setAlias
(
raw
.
feed_alias
)
entity
.
setFeed
(
feed
)
entity
.
setFeed
(
feed
)
...
@@ -47,7 +49,7 @@ fun fromRaw(raw:ArticleRaw) : ArticleEntity {
...
@@ -47,7 +49,7 @@ fun fromRaw(raw:ArticleRaw) : ArticleEntity {
}
}
fun
fromRaw
(
raw
:
NewsArticleRaw
,
feed
Id
:
Int
):
ArticleEntity
{
fun
fromRaw
(
raw
:
NewsArticleRaw
,
feed
Alias
:
String
):
ArticleEntity
{
val
entity
=
ArticleEntity
()
val
entity
=
ArticleEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setId
(
raw
.
id
)
entity
.
setPreview
(
raw
.
preview
)
entity
.
setPreview
(
raw
.
preview
)
...
@@ -55,31 +57,12 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
...
@@ -55,31 +57,12 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
entity
.
setPublished
(
raw
.
published
)
entity
.
setPublished
(
raw
.
published
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setTitle
(
raw
.
title
)
val
feed
=
FeedEntity
()
val
feed
=
FeedEntity
()
feed
.
setId
(
feedId
)
feed
.
setAlias
(
feedAlias
)
// feed.setAlias(feedAlias)
entity
.
setFeed
(
feed
)
entity
.
setFeed
(
feed
)
return
entity
return
entity
}
}
fun
fromRaw
(
raw
:
ArticleRaw
,
feedId
:
Int
):
ArticleEntity
{
val
entity
=
ArticleEntity
()
entity
.
setId
(
raw
.
id
)
entity
.
setPublished
(
raw
.
published
)
entity
.
setTitle
(
raw
.
title
)
entity
.
setBody
(
raw
.
body
)
raw
.
photo
?.
let
{
entity
.
photo
=
fromRawList
(
it
,
::
fromRaw
)
}
val
feed
=
FeedEntity
()
feed
.
setId
(
feedId
)
// feed.setAlias(raw.feed_alias)
entity
.
setFeed
(
feed
)
return
entity
}
fun
fromRaw
(
raw
:
NewsPhotoRaw
):
TitledPhoto
{
fun
fromRaw
(
raw
:
NewsPhotoRaw
):
TitledPhoto
{
return
TitledPhoto
(
raw
.
title
,
raw
.
url
)
return
TitledPhoto
(
raw
.
title
,
raw
.
url
)
}
}
...
@@ -99,7 +82,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
...
@@ -99,7 +82,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
fun
<
E
,
M
>
fromRawList
(
raw
:
List
<
E
>,
block
:(
E
)->
M
):
List
<
M
>
=
List
(
raw
.
size
)
{
index
->
block
(
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
>,
feed
Id
:
Int
):
List
<
ArticleEntity
>
=
fun
fromRaw
(
raw
:
List
<
NewsArticleRaw
>,
feed
Alias
:
String
):
List
<
ArticleEntity
>
=
List
(
raw
.
size
)
{
index
->
fromRaw
(
raw
[
index
],
feed
Id
)
}
List
(
raw
.
size
)
{
index
->
fromRaw
(
raw
[
index
],
feed
Alias
)
}
val
calcTargetResolution
=
max
(
display
.
widthPixels
,
display
.
heightPixels
)
val
calcTargetResolution
=
max
(
display
.
widthPixels
,
display
.
heightPixels
)
app/src/main/java/com/biganto/visual/roompark/di/dagger/ContextModule.kt
View file @
4d0a9bdf
...
@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
...
@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
const
val
FILES_CACHE_LIMIT_SIZE
=
10000
const
val
FILES_CACHE_LIMIT_SIZE
=
10000
const
val
FILES_CACHE_LIMIT_SECONDS_INACTIVE
=
60L
const
val
FILES_CACHE_LIMIT_SECONDS_INACTIVE
=
60L
const
val
DATABASE_VERSION
=
7
const
val
DATABASE_VERSION
=
8
@Module
@Module
abstract
class
AppModule
{
abstract
class
AppModule
{
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/DataModule.kt
View file @
4d0a9bdf
...
@@ -26,15 +26,12 @@ interface DataComponent{
...
@@ -26,15 +26,12 @@ interface DataComponent{
@Module
(
includes
=
[
DataModule
::
class
,
RetrofitModule
::
class
,
DbModule
::
class
,
LocalStorage
::
class
])
@Module
(
includes
=
[
DataModule
::
class
,
RetrofitModule
::
class
,
DbModule
::
class
,
LocalStorage
::
class
])
abstract
class
ContractRepositoryModule
{
abstract
class
ContractRepositoryModule
{
@Singleton
@Binds
@Binds
abstract
fun
provideAuth
(
contract
:
AuthContractModule
):
AuthContract
abstract
fun
provideAuth
(
contract
:
AuthContractModule
):
AuthContract
@Singleton
@Binds
@Binds
abstract
fun
provideFeedsContract
(
impl
:
FeedsContractModule
):
FeedsContract
abstract
fun
provideFeedsContract
(
impl
:
FeedsContractModule
):
FeedsContract
@Singleton
@Binds
@Binds
abstract
fun
provideDevProgressContract
(
impl
:
AlbumsContractModule
):
DevProgressContract
abstract
fun
provideDevProgressContract
(
impl
:
AlbumsContractModule
):
DevProgressContract
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/FeedsContract.kt
View file @
4d0a9bdf
...
@@ -13,10 +13,11 @@ interface FeedsContract{
...
@@ -13,10 +13,11 @@ interface FeedsContract{
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
fun
fetchFeedObservable
(
id
:
Int
):
Observable
<
ArticlesPreviewModel
>
fun
fetchFeedObservable
(
fun
fetchFeedObservable
(
id
:
Int
,
feedAlias
:
String
,
pageSize
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
startIndex
:
Int
):
Observable
<
ArticlesPreviewModel
>
):
Observable
<
ArticlesPreviewModel
>
fun
fetchFeedObservable
(
feedAlias
:
String
):
Observable
<
ArticlesPreviewModel
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/articles.kt
View file @
4d0a9bdf
...
@@ -11,11 +11,11 @@ import javax.inject.Inject
...
@@ -11,11 +11,11 @@ import javax.inject.Inject
class
ArticlesInteractor
@Inject
constructor
(
class
ArticlesInteractor
@Inject
constructor
(
)
{
)
{
fun
fetchArticles
(
feed
Id
:
Int
):
Single
<
ArticlesPreviewModel
>
=
Single
.
just
(
fun
fetchArticles
(
feed
Alias
:
String
):
Single
<
ArticlesPreviewModel
>
=
Single
.
just
(
when
(
feed
Id
)
{
when
(
feed
Alias
)
{
1
->
FeedsInteractor
.
testNewsArticles
"news"
->
FeedsInteractor
.
testNewsArticles
2
->
FeedsInteractor
.
testBlogsArticles
"blog"
->
FeedsInteractor
.
testBlogsArticles
3
->
FeedsInteractor
.
testDevArticles
"constructors_blog"
->
FeedsInteractor
.
testDevArticles
else
->
error
(
"unknown feedId"
)
else
->
error
(
"unknown feedId"
)
}
}
)
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/feeds.kt
View file @
4d0a9bdf
...
@@ -20,8 +20,8 @@ class FeedsInteractor @Inject constructor(
...
@@ -20,8 +20,8 @@ class FeedsInteractor @Inject constructor(
feedsUseCase
.
getFeeds
().
map
{
FeedsHeaderModel
(
it
)}
feedsUseCase
.
getFeeds
().
map
{
FeedsHeaderModel
(
it
)}
//Single.just(testFeeds)
//Single.just(testFeeds)
fun
fetchArticles
(
feed
Id
:
Int
):
Observable
<
ArticlesPreviewModel
>
=
fun
fetchArticles
(
feed
Alias
:
String
):
Observable
<
ArticlesPreviewModel
>
=
feedsUseCase
.
getArticles
(
feed
Id
)
feedsUseCase
.
getArticles
(
feed
Alias
)
// Single.just(
// Single.just(
// when (feedId) {
// when (feedId) {
// 1 -> testNewsArticles
// 1 -> testNewsArticles
...
@@ -30,8 +30,8 @@ class FeedsInteractor @Inject constructor(
...
@@ -30,8 +30,8 @@ class FeedsInteractor @Inject constructor(
// else -> error("unknown feedId")
// else -> error("unknown feedId")
// }
// }
// )
// )
fun
fetchArticles
(
feed
Id
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
ArticlesPreviewModel
>
=
fun
fetchArticles
(
feed
Alias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
ArticlesPreviewModel
>
=
feedsUseCase
.
fetchArticlesPage
(
feed
Id
,
pageSize
,
startIndex
)
feedsUseCase
.
fetchArticlesPage
(
feed
Alias
,
pageSize
,
startIndex
)
fun
fetchAlbums
():
Observable
<
List
<
AlbumPreviewModel
>>
=
albumsUseCase
.
getProgressAlbums
()
fun
fetchAlbums
():
Observable
<
List
<
AlbumPreviewModel
>>
=
albumsUseCase
.
getProgressAlbums
()
...
@@ -50,14 +50,15 @@ class FeedsInteractor @Inject constructor(
...
@@ -50,14 +50,15 @@ class FeedsInteractor @Inject constructor(
val
testFeeds
=
FeedsHeaderModel
(
val
testFeeds
=
FeedsHeaderModel
(
listOf
(
listOf
(
FeedModel
(
1
,
"НОВОСТИ"
),
FeedModel
(
FeedModel
(
2
,
"БЛОГИ"
),
"news"
,
"НОВОСТИ"
),
FeedModel
(
2
,
"БЛОГ СТРОИТЕЛЬСТВА"
)
FeedModel
(
"news"
,
"БЛОГИ"
),
FeedModel
(
"news"
,
"БЛОГ СТРОИТЕЛЬСТВА"
)
)
)
)
)
val
testNewsArticles
=
ArticlesPreviewModel
(
val
testNewsArticles
=
ArticlesPreviewModel
(
1
,
"news"
,
listOf
(
listOf
(
ArticlePreviewModel
(
ArticlePreviewModel
(
1
1
...
@@ -87,7 +88,7 @@ class FeedsInteractor @Inject constructor(
...
@@ -87,7 +88,7 @@ class FeedsInteractor @Inject constructor(
)
)
val
testBlogsArticles
=
ArticlesPreviewModel
(
val
testBlogsArticles
=
ArticlesPreviewModel
(
2
,
"news"
,
listOf
(
listOf
(
ArticlePreviewModel
(
ArticlePreviewModel
(
1
1
...
@@ -117,7 +118,7 @@ class FeedsInteractor @Inject constructor(
...
@@ -117,7 +118,7 @@ class FeedsInteractor @Inject constructor(
)
)
val
testDevArticles
=
ArticlesPreviewModel
(
val
testDevArticles
=
ArticlesPreviewModel
(
3
,
"news"
,
listOf
(
listOf
(
ArticlePreviewModel
(
ArticlePreviewModel
(
1
1
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/feeds.kt
View file @
4d0a9bdf
...
@@ -11,7 +11,7 @@ import java.util.*
...
@@ -11,7 +11,7 @@ import java.util.*
const
val
DEFAULT_ROOM_PARK_PREVIEW
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/15-fe1886.jpeg"
const
val
DEFAULT_ROOM_PARK_PREVIEW
=
"https://room-park.ru/assets/news_articles/preview/00/00/00/15-fe1886.jpeg"
data class
FeedModel
(
val
feedId
:
Int
,
val
title
:
String
,
val
alias
:
String
?
=
null
)
data class
FeedModel
(
val
title
:
String
,
val
alias
:
String
)
data class
FeedsHeaderModel
(
val
feeds
:
List
<
FeedModel
>)
data class
FeedsHeaderModel
(
val
feeds
:
List
<
FeedModel
>)
...
@@ -30,7 +30,7 @@ data class ArticlePreviewModel(
...
@@ -30,7 +30,7 @@ data class ArticlePreviewModel(
}
}
}
}
data class
ArticlesPreviewModel
(
val
parentFeed
Id
:
Int
,
val
articles
:
List
<
ArticlePreviewModel
>)
data class
ArticlesPreviewModel
(
val
parentFeed
Alias
:
String
,
val
articles
:
List
<
ArticlePreviewModel
>)
data class
ArticleModel
(
data class
ArticleModel
(
...
@@ -44,7 +44,6 @@ data class ArticleModel(
...
@@ -44,7 +44,6 @@ data class ArticleModel(
)
)
fun
fromEntity
(
entity
:
FeedEntity
):
FeedModel
=
FeedModel
(
fun
fromEntity
(
entity
:
FeedEntity
):
FeedModel
=
FeedModel
(
feedId
=
entity
.
id
,
title
=
entity
.
title
,
title
=
entity
.
title
,
alias
=
entity
.
alias
alias
=
entity
.
alias
)
)
...
@@ -58,9 +57,9 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
...
@@ -58,9 +57,9 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
isRead
=
false
isRead
=
false
)
)
fun
fromEntity
(
parentId
:
Int
,
entity
:
List
<
ArticleEntity
>):
ArticlesPreviewModel
=
fun
fromEntity
(
parentId
:
String
,
entity
:
List
<
ArticleEntity
>):
ArticlesPreviewModel
=
ArticlesPreviewModel
(
ArticlesPreviewModel
(
parentFeed
Id
=
parentId
,
parentFeed
Alias
=
parentId
,
articles
=
fromEntity
(
entity
,
::
fromEntity
)
articles
=
fromEntity
(
entity
,
::
fromEntity
)
)
)
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/feedUseCase.kt
View file @
4d0a9bdf
...
@@ -12,11 +12,11 @@ class FeedUseCase @Inject constructor(
...
@@ -12,11 +12,11 @@ class FeedUseCase @Inject constructor(
){
){
fun
getFeeds
()
=
contract
.
fetchFeeds
()
fun
getFeeds
()
=
contract
.
fetchFeeds
()
fun
getArticles
(
feed
Id
:
Int
)
=
fun
getArticles
(
feed
Alias
:
String
)
=
contract
.
fetchFeedObservable
(
feed
Id
)
contract
.
fetchFeedObservable
(
feed
Alias
)
fun
fetchArticlesPage
(
feed
Id
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
)
=
fun
fetchArticlesPage
(
feed
Alias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
=
contract
.
fetchFeedObservable
(
feed
Id
,
pageSize
,
startIndex
)
contract
.
fetchFeedObservable
(
feed
Alias
,
pageSize
,
startIndex
)
fun
getArticle
(
articleId
:
Int
)
=
fun
getArticle
(
articleId
:
Int
)
=
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenController.kt
View file @
4d0a9bdf
...
@@ -21,7 +21,7 @@ import javax.inject.Inject
...
@@ -21,7 +21,7 @@ import javax.inject.Inject
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
private
const
val
FEED_ID
=
"DIRECT_FEED_ID_KEY"
const
val
FEED_ALIAS
=
"DIRECT_FEED_ID_KEY"
class
ArticlesScreenController
:
class
ArticlesScreenController
:
BigantoBaseController
<
ArticlesScreenViewState
BigantoBaseController
<
ArticlesScreenViewState
...
@@ -32,7 +32,7 @@ class ArticlesScreenController :
...
@@ -32,7 +32,7 @@ class ArticlesScreenController :
constructor
()
constructor
()
constructor
(
feed
Id
:
Int
):
super
(
bundleOf
(
FEED_ID
to
feedId
))
constructor
(
feed
Alias
:
String
):
super
(
bundleOf
(
FEED_ALIAS
to
feedAlias
))
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
getComponent
()
getComponent
()
...
@@ -102,7 +102,7 @@ class ArticlesScreenController :
...
@@ -102,7 +102,7 @@ class ArticlesScreenController :
}
}
private
fun
getComponent
()
=
DaggerArticlesScreenComponent
.
factory
()
private
fun
getComponent
()
=
DaggerArticlesScreenComponent
.
factory
()
.
create
(
args
.
get
Int
(
FEED_ID
)
.
create
(
args
.
get
String
(
FEED_ALIAS
)
!!
,
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
,
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
.
inject
(
this
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenDI.kt
View file @
4d0a9bdf
...
@@ -20,7 +20,7 @@ interface ArticlesScreenComponent {
...
@@ -20,7 +20,7 @@ interface ArticlesScreenComponent {
@Component
.
Factory
@Component
.
Factory
interface
Factory
{
interface
Factory
{
fun
create
(
fun
create
(
@BindsInstance
@Named
(
"FEED_ID_INT"
)
feed
:
Int
@BindsInstance
@Named
(
FEED_ALIAS
)
feed
:
String
,
appComponent
:
AppComponent
,
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
,
@BindsInstance
activity
:
RoomParkMainActivity
):
ArticlesScreenComponent
):
ArticlesScreenComponent
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/ScreenPresenter.kt
View file @
4d0a9bdf
...
@@ -15,7 +15,7 @@ import javax.inject.Named
...
@@ -15,7 +15,7 @@ import javax.inject.Named
class
ArticlesScreenPresenter
@Inject
constructor
(
class
ArticlesScreenPresenter
@Inject
constructor
(
@Named
(
"FEED_ID_INT"
)
private
val
feedId
:
Int
,
@Named
(
FEED_ALIAS
)
private
val
feedId
:
String
,
private
val
interactor
:
ArticlesInteractor
private
val
interactor
:
ArticlesInteractor
)
)
:
BigantoBasePresenter
<
ArticlesScreen
,
ArticlesScreenViewState
>()
{
:
BigantoBasePresenter
<
ArticlesScreen
,
ArticlesScreenViewState
>()
{
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenContract.kt
View file @
4d0a9bdf
...
@@ -12,7 +12,7 @@ import io.reactivex.Observable
...
@@ -12,7 +12,7 @@ import io.reactivex.Observable
*/
*/
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
interface
FeedsScreen
:
BigantoBaseContract
<
FeedsScreenViewState
>
{
fun
feedsTabSelected
():
Observable
<
Int
>
fun
feedsTabSelected
():
Observable
<
String
>
fun
requsetsNewArticles
():
Observable
<
Pair
<
FeedModel
,
Int
>>
fun
requsetsNewArticles
():
Observable
<
Pair
<
FeedModel
,
Int
>>
fun
onAllFeedArticles
():
Observable
<
FeedModel
>
fun
onAllFeedArticles
():
Observable
<
FeedModel
>
fun
onCameraSelected
():
Observable
<
WebCamModel
>
fun
onCameraSelected
():
Observable
<
WebCamModel
>
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
4d0a9bdf
...
@@ -60,11 +60,11 @@ class FeedsScreenController :
...
@@ -60,11 +60,11 @@ class FeedsScreenController :
.
debounce
(
120L
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
120L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
feedsTabSelected
():
Observable
<
Int
>
override
fun
feedsTabSelected
():
Observable
<
String
>
=
feedsTabs
.
selections
()
=
feedsTabs
.
selections
()
.
debounce
(
200L
,
TimeUnit
.
MILLISECONDS
)
.
debounce
(
200L
,
TimeUnit
.
MILLISECONDS
)
.
map
{
it
.
position
}
.
map
{
it
.
position
}
.
map
{
storedFeedsList
[
it
].
feedId
}
.
map
{
storedFeedsList
[
it
].
alias
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doOnNext
{
allFeedArticles
.
text
=
"ВСЕ ${allFeedName(it)} →"
}
.
doOnNext
{
allFeedArticles
.
text
=
"ВСЕ ${allFeedName(it)} →"
}
...
@@ -170,7 +170,7 @@ class FeedsScreenController :
...
@@ -170,7 +170,7 @@ class FeedsScreenController :
private
fun
render
(
viewState
:
FeedsScreenViewState
.
ToArticlesScreen
)
{
private
fun
render
(
viewState
:
FeedsScreenViewState
.
ToArticlesScreen
)
{
router
.
pushController
(
router
.
pushController
(
RouterTransaction
.
with
(
ArticlesScreenController
(
viewState
.
feed
Id
))
RouterTransaction
.
with
(
ArticlesScreenController
(
viewState
.
feed
Alias
))
.
popChangeHandler
(
FadeChangeHandler
())
.
popChangeHandler
(
FadeChangeHandler
())
.
pushChangeHandler
(
FadeChangeHandler
())
.
pushChangeHandler
(
FadeChangeHandler
())
)
)
...
@@ -201,7 +201,7 @@ class FeedsScreenController :
...
@@ -201,7 +201,7 @@ class FeedsScreenController :
private
fun
render
(
viewState
:
FeedsScreenViewState
.
SomeError
)
=
private
fun
render
(
viewState
:
FeedsScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
private
fun
allFeedName
(
feed
Id
:
Int
)
=
if
(
feedId
==
1
)
"НОВОСТИ"
else
"БЛОГИ"
private
fun
allFeedName
(
feed
Alias
:
String
)
=
if
(
feedAlias
==
"news"
)
"НОВОСТИ"
else
"БЛОГИ"
private
fun
render
(
viewState
:
FeedsScreenViewState
.
FeedsPages
){
private
fun
render
(
viewState
:
FeedsScreenViewState
.
FeedsPages
){
feedsTabs
.
removeAllTabs
()
feedsTabs
.
removeAllTabs
()
...
@@ -209,7 +209,7 @@ class FeedsScreenController :
...
@@ -209,7 +209,7 @@ class FeedsScreenController :
viewState
.
items
.
forEach
{
feed
->
viewState
.
items
.
forEach
{
feed
->
val
tab
=
feedsTabs
.
newTab
()
val
tab
=
feedsTabs
.
newTab
()
.
setCustomView
(
R
.
layout
.
feeds_tab_view
)
.
setCustomView
(
R
.
layout
.
feeds_tab_view
)
.
setTag
(
feed
.
feedId
)
.
setTag
(
feed
.
alias
)
tab
.
customView
tab
.
customView
?.
let
{
?.
let
{
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_title
)
?.
text
=
feed
.
title
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_title
)
?.
text
=
feed
.
title
...
@@ -250,7 +250,7 @@ class FeedsScreenController :
...
@@ -250,7 +250,7 @@ class FeedsScreenController :
viewState
.
restore
.
feeds
.
forEach
{
feed
->
viewState
.
restore
.
feeds
.
forEach
{
feed
->
val
tab
=
feedsTabs
.
newTab
()
val
tab
=
feedsTabs
.
newTab
()
.
setCustomView
(
R
.
layout
.
feeds_tab_view
)
.
setCustomView
(
R
.
layout
.
feeds_tab_view
)
.
setTag
(
feed
.
feedId
)
.
setTag
(
feed
.
alias
)
tab
.
customView
tab
.
customView
?.
let
{
?.
let
{
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_title
)
?.
text
=
feed
.
title
it
.
findViewById
<
TextView
>(
R
.
id
.
tab_title
)
?.
text
=
feed
.
title
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenPresenter.kt
View file @
4d0a9bdf
...
@@ -70,7 +70,7 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -70,7 +70,7 @@ class FeedsScreenPresenter @Inject constructor(
val
switchToAllArtiles
=
intent
(
FeedsScreen
::
onAllFeedArticles
)
val
switchToAllArtiles
=
intent
(
FeedsScreen
::
onAllFeedArticles
)
.
map
<
FeedsScreenViewState
>
{
.
map
<
FeedsScreenViewState
>
{
FeedsScreenViewState
.
ToArticlesScreen
(
it
.
feedId
)
FeedsScreenViewState
.
ToArticlesScreen
(
it
.
alias
)
}
}
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
...
@@ -91,7 +91,7 @@ class FeedsScreenPresenter @Inject constructor(
...
@@ -91,7 +91,7 @@ class FeedsScreenPresenter @Inject constructor(
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
.
alias
,
FEED_PREVIEW_PAGE_SIZE
,
it
.
second
)
}
.
map
<
FeedsScreenViewState
>
{
.
map
<
FeedsScreenViewState
>
{
restoreModel
.
articles
=
it
.
articles
restoreModel
.
articles
=
it
.
articles
Timber
.
d
(
"arrived list: ${it.articles.size}"
)
Timber
.
d
(
"arrived list: ${it.articles.size}"
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenViewState.kt
View file @
4d0a9bdf
...
@@ -25,7 +25,7 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
...
@@ -25,7 +25,7 @@ sealed class FeedsScreenViewState : BigantoBaseViewState() {
class
SomeError
(
val
exception
:
ExceptionString
)
:
FeedsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FeedsScreenViewState
()
class
ToArticlesScreen
(
val
feed
Id
:
Int
)
:
FeedsScreenViewState
()
class
ToArticlesScreen
(
val
feed
Alias
:
String
)
:
FeedsScreenViewState
()
class
ToArticle
(
val
articleId
:
Int
)
:
FeedsScreenViewState
()
class
ToArticle
(
val
articleId
:
Int
)
:
FeedsScreenViewState
()
...
...
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