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
6f081dd0
Commit
6f081dd0
authored
Nov 28, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pagination request index
parent
12e9333a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
11 deletions
+28
-11
FeedsRepository.kt
...nto/visual/roompark/data/data_provider/FeedsRepository.kt
+9
-3
UserSession.kt
.../visual/roompark/data/service/user_session/UserSession.kt
+3
-3
feeds.kt
...in/java/com/biganto/visual/roompark/domain/model/feeds.kt
+7
-1
ScreenController.kt
...al/roompark/presentation/screen/feeds/ScreenController.kt
+1
-0
ScreenPresenter.kt
...ual/roompark/presentation/screen/feeds/ScreenPresenter.kt
+1
-0
Adapter.kt
...ual/roompark/presentation/screen/settings/util/Adapter.kt
+7
-4
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FeedsRepository.kt
View file @
6f081dd0
...
...
@@ -47,16 +47,20 @@ class FeedsContractModule @Inject constructor(
private
fun
fetchArticlessApi
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
List
<
ArticleEntity
>>?
{
val
feed
=
db
.
getFeed
(
feedId
)
?
.
firstOrNull
()
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
())
Timber
.
d
(
"page index: "
+
"${startIndex.toDouble()/pageSize.toDouble()} -- -"
+
"${floor(startIndex.toDouble()/pageSize.toDouble()).toInt()+1}"
)
return
api
.
getArticlesPage
(
feed
.
alias
,
pageSize
,
floor
(
startIndex
.
toDouble
()/
pageSize
.
toDouble
()).
toInt
()+
1
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
it
.
items
}
.
map
{
fromRaw
(
it
,
feedId
)
}
.
doOnNext
{
Timber
.
d
(
"raw enitites $it"
)
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
}
...
...
@@ -64,13 +68,15 @@ class FeedsContractModule @Inject constructor(
private
fun
fetchArticlesDb
(
feedId
:
Int
,
pageSize
:
Int
,
startIndex
:
Int
):
Observable
<
MutableList
<
ArticleEntity
>>?
{
val
feed
=
db
.
getFeed
(
feedId
)
?.
firstOrNull
()
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
)
.
toList
()
.
toObservable
()
.
doOnNext
{
Timber
.
d
(
"db items: ${it.size}"
)
}
.
subscribeOn
(
Schedulers
.
io
())
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/user_session/UserSession.kt
View file @
6f081dd0
...
...
@@ -33,9 +33,9 @@ class UserSessionService @Inject constructor(
local
.
recentUserObs
()
.
doOnNext
{
Timber
.
w
(
"got new user $it"
)
}
.
flatMap
{
db
.
userObservableResult
(
it
.
toInt
())
?
.
doOnNext
{
Timber
.
w
(
"obs db user $it"
)
}
?
.
flatMap
{
reactiveResult
->
reactiveResult
.
observable
()
?
.
doOnNext
{
Timber
.
w
(
"flatmapUser db user $it"
)
}
}
.
doOnNext
{
Timber
.
w
(
"obs db user $it"
)
}
.
flatMap
{
reactiveResult
->
reactiveResult
.
observable
()
.
doOnNext
{
Timber
.
w
(
"flatmapUser db user $it"
)
}
}
}
.
doOnNext
{
Timber
.
w
(
"subscribe user $it"
)
}
.
subscribe
{
_token
=
it
.
authToken
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/feeds.kt
View file @
6f081dd0
...
...
@@ -20,7 +20,13 @@ data class ArticlePreviewModel(
val
announce
:
String
,
val
previewUrl
:
String
,
val
isRead
:
Boolean
)
){
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
other
is
ArticlePreviewModel
)
return
this
.
articleId
==
other
.
articleId
return
super
.
equals
(
other
)
}
}
data class
ArticlesPreviewModel
(
val
parentFeedId
:
Int
,
val
articles
:
List
<
ArticlePreviewModel
>)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenController.kt
View file @
6f081dd0
...
...
@@ -181,6 +181,7 @@ class FeedsScreenController :
}
private
fun
render
(
viewState
:
FeedsScreenViewState
.
ArticlesScrollPage
){
Timber
.
d
(
"got items: ${viewState.items.size}"
)
(
feedsRecyclerView
.
adapter
as
ArticlesPreviewAdapter
).
addItems
(
viewState
.
items
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feeds/ScreenPresenter.kt
View file @
6f081dd0
...
...
@@ -77,6 +77,7 @@ class FeedsScreenPresenter @Inject constructor(
.
flatMap
{
interactor
.
fetchArticles
(
it
.
first
.
feedId
,
FEED_PREVIEW_PAGE_SIZE
,
it
.
second
)
}
.
map
<
FeedsScreenViewState
>
{
restoreModel
.
articles
=
it
.
articles
Timber
.
d
(
"arrived list: ${it.articles.size}"
)
FeedsScreenViewState
.
ArticlesScrollPage
(
it
.
articles
.
toList
())
}
.
onErrorReturn
(
::
parseError
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/util/Adapter.kt
View file @
6f081dd0
...
...
@@ -34,17 +34,20 @@ abstract class CommonRecyclerAdapter<VH:CommonViewHolder<M>,M:Any> : RecyclerVie
private
var
list
:
MutableList
<
M
>
=
mutableListOf
()
fun
setItems
(
list
:
List
<
M
>){
fun
setItems
(
items
:
List
<
M
>){
this
.
list
.
clear
()
this
.
list
.
addAll
(
list
)
this
.
list
.
addAll
(
items
)
notifyDataSetChanged
()
}
fun
addItems
(
items
:
List
<
M
>){
this
.
list
.
addAll
(
list
)
notifyItemRangeInserted
(
list
.
size
-
items
.
size
,
items
.
size
)
items
.
asSequence
().
filter
{
!
list
.
contains
(
it
)
}.
toList
().
let
{
uniqueItems
->
this
.
list
.
addAll
(
uniqueItems
)
notifyItemRangeInserted
(
list
.
size
-
uniqueItems
.
size
,
uniqueItems
.
size
)
}
}
protected
abstract
val
vhKlazz
:
KClass
<
VH
>
@LayoutRes
...
...
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