Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
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
3c89dac9
Commit
3c89dac9
authored
Dec 03, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actualize feeds repository
parent
65538f6a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
40 deletions
+39
-40
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
RetrofitRepository.kt
...ompark/data/repository/api/retrofit/RetrofitRepository.kt
+10
-1
FeedsContract.kt
.../biganto/visual/roompark/domain/contract/FeedsContract.kt
+3
-2
feeds.kt
...in/java/com/biganto/visual/roompark/domain/model/feeds.kt
+2
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FeedsRepository.kt
View file @
3c89dac9
...
@@ -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 @
3c89dac9
...
@@ -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/RetrofitRepository.kt
View file @
3c89dac9
...
@@ -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/domain/contract/FeedsContract.kt
View file @
3c89dac9
...
@@ -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/model/feeds.kt
View file @
3c89dac9
...
@@ -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
(
...
@@ -58,7 +58,7 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
...
@@ -58,7 +58,7 @@ 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
(
parentFeedId
=
parentId
,
parentFeedId
=
parentId
,
articles
=
fromEntity
(
entity
,
::
fromEntity
)
articles
=
fromEntity
(
entity
,
::
fromEntity
)
...
...
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