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
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
Show 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
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.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.ArticleModel
import
com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import
com.biganto.visual.roompark.domain.model.FeedModel
...
...
@@ -31,11 +30,11 @@ class FeedsContractModule @Inject constructor(
override
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
=
fetchAllFeeds
().
doOnError
(
::
e
)
override
fun
fetchFeedObservable
(
id
:
Int
):
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
id
)
override
fun
fetchFeedObservable
(
feedAlias
:
String
):
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
feedAlias
)
override
fun
fetchFeedObservable
(
id
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
id
,
pageSize
,
startIndex
)
override
fun
fetchFeedObservable
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
ArticlesPreviewModel
>
=
fetchArticles
(
feedAlias
,
pageSize
,
startIndex
)
override
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
=
fetchArticle
(
id
)
...
...
@@ -45,44 +44,36 @@ class FeedsContractModule @Inject constructor(
}
private
fun
fetchArticlessApi
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
List
<
ArticleEntity
>>?
{
val
feed
=
db
.
getFeed
(
feedId
).
firstOrNull
()
if
(
feed
==
null
)
{
e
(
"Unknown feedId: $feedId - cann't resolve feed_alias!"
)
throw
CustomApiException
.
UnknownCustomApiException
(-
1
,
null
,
"Unknown Feed!"
)
}
else
{
return
api
.
getArticlesPage
(
feed
.
alias
,
pageSize
,
floor
(
startIndex
.
toDouble
()/
pageSize
.
toDouble
()).
toInt
()+
1
)
private
fun
fetchArticlessApi
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
List
<
ArticleEntity
>>?
=
api
.
getArticlesPage
(
feedAlias
,
pageSize
,
floor
(
startIndex
.
toDouble
()/
pageSize
.
toDouble
()).
toInt
()+
1
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
it
.
items
}
.
map
{
fromRaw
(
it
,
feed
Id
)
}
.
map
{
fromRaw
(
it
,
feed
Alias
)
}
.
doOnNext
{
Timber
.
d
(
"raw enitites $it"
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
}
}
private
fun
fetchArticlesDb
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
MutableList
<
ArticleEntity
>>?
{
val
feed
=
db
.
getFeed
(
feedId
).
firstOrNull
()
Timber
.
d
(
"db startindex: $startIndex"
)
if
(
feed
==
null
)
{
e
(
"Unknown feedId: $feedId - cann't resolve feed_alias!"
)
throw
CustomApiException
.
UnknownCustomApiException
(-
1
,
null
,
"Unknown Feed!"
)
}
else
return
db
.
fetchArticles
(
feed
.
alias
,
pageSize
,
startIndex
)
private
fun
fetchArticlesDb
(
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
)
:
Observable
<
MutableList
<
ArticleEntity
>>?
=
db
.
fetchArticles
(
feedAlias
,
pageSize
,
startIndex
)
.
toList
()
.
toObservable
()
.
doOnNext
{
Timber
.
d
(
"db items: ${it.size}"
)
}
.
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
(
arrayListOf
(
fetchArticlessApi
(
feedId
,
pageSize
,
startIndex
),
fetchArticlesDb
(
feedId
,
pageSize
,
startIndex
))
).
map
{
fromEntity
(
feedId
,
it
)
}
arrayListOf
(
fetchArticlessApi
(
feedAlias
,
pageSize
,
startIndex
),
fetchArticlesDb
(
feedAlias
,
pageSize
,
startIndex
)
)
).
map
{
fromEntity
(
feedAlias
,
it
)
}
private
val
fetchFeedsApi
=
...
...
@@ -106,10 +97,7 @@ class FeedsContractModule @Inject constructor(
private
fun
fetchArticleApi
(
id
:
Int
)
=
api
.
getArticle
(
id
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
flatMap
{
article
->
db
.
getFeed
(
article
.
feed_alias
).
observable
()
.
map
{
fromRaw
(
article
,
it
.
id
)
}
}
.
map
(
::
fromRaw
)
.
flatMap
{
article
->
db
.
getArticle
(
article
.
id
).
observable
()
.
map
{
articleEntity
->
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/IApi.kt
View file @
3c89dac9
...
...
@@ -40,12 +40,13 @@ interface IRoomParkApi {
showElectric
:
Boolean
):
Observable
<
String
>
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
List
<
PlanRaw
>
>
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
Int
>
fun
getArticlesPage
(
feedName
:
String
,
pageSize
:
Int
=
DEFAULT_ARTICLE_PAGE_SIZE
,
page
:
Int
):
Observable
<
ArticlesListPaginationRaw
>
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
)
.
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
(
building
=
building
,
flatNumber
=
flat
)
.
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
){
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/FeedsContract.kt
View file @
3c89dac9
...
...
@@ -13,10 +13,11 @@ interface FeedsContract{
fun
fetchFeeds
():
Observable
<
List
<
FeedModel
>>
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleModel
>
fun
fetchFeedObservable
(
id
:
Int
):
Observable
<
ArticlesPreviewModel
>
fun
fetchFeedObservable
(
id
:
Int
,
feedAlias
:
String
,
pageSize
:
Int
,
startIndex
:
Int
):
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(
}
}
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
(
...
...
@@ -58,7 +58,7 @@ fun fromEntity(entity: ArticleEntity):ArticlePreviewModel = ArticlePreviewModel(
isRead
=
false
)
fun
fromEntity
(
parentId
:
Int
,
entity
:
List
<
ArticleEntity
>):
ArticlesPreviewModel
=
fun
fromEntity
(
parentId
:
String
,
entity
:
List
<
ArticleEntity
>):
ArticlesPreviewModel
=
ArticlesPreviewModel
(
parentFeedId
=
parentId
,
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