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
d92a390c
Commit
d92a390c
authored
Dec 11, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added titledphotolist converter
parent
94e478fa
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
91 additions
and
25 deletions
+91
-25
AlbumsRepository.kt
...to/visual/roompark/data/data_provider/AlbumsRepository.kt
+28
-0
IApi.kt
...a/com/biganto/visual/roompark/data/repository/api/IApi.kt
+1
-1
IRoomParkMobileApi.kt
...ompark/data/repository/api/retrofit/IRoomParkMobileApi.kt
+1
-1
RetrofitRepository.kt
...ompark/data/repository/api/retrofit/RetrofitRepository.kt
+1
-1
response.kt
...ual/roompark/data/repository/api/retrofit/raw/response.kt
+2
-1
SupportTypes.kt
...isual/roompark/data/repository/db/requrey/SupportTypes.kt
+3
-1
ImageAlbum.kt
...l/roompark/data/repository/db/requrey/model/ImageAlbum.kt
+2
-0
TitledPhotoListConverter.java
...repository/db/requrey/utils/TitledPhotoListConverter.java
+21
-4
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+1
-0
DevProgressContract.kt
...to/visual/roompark/domain/contract/DevProgressContract.kt
+2
-6
albums.kt
...n/java/com/biganto/visual/roompark/domain/model/albums.kt
+11
-0
albumsUseCase.kt
.../biganto/visual/roompark/domain/use_case/albumsUseCase.kt
+3
-0
ScreenController.kt
...l/roompark/presentation/screen/albums/ScreenController.kt
+3
-3
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+10
-5
ScreenViewState.kt
...al/roompark/presentation/screen/albums/ScreenViewState.kt
+2
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AlbumsRepository.kt
View file @
d92a390c
...
...
@@ -22,6 +22,10 @@ class AlbumsContractModule @Inject constructor(
private
val
db
:
IDb
):
DevProgressContract
{
override
fun
getAlbumPreviews
(
albumId
:
Int
):
Observable
<
List
<
AlbumPhotoPreviewModel
>>
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
getProgressCards
():
Observable
<
List
<
AlbumPreviewModel
>>
=
fetchTopLevelAlbums
()
override
fun
getProgressAlbumList
(
albumId
:
Int
):
Observable
<
List
<
AlbumPreviewModel
>>
=
...
...
@@ -111,5 +115,29 @@ class AlbumsContractModule @Inject constructor(
private
fun
fetchWebCams
():
Observable
<
WebCamListModel
>
=
fetchWebCamsApi
//endregion
//region concrete Albums
private
fun
fetchAlbumPhotosApi
(
albumId
:
Int
)
=
api
.
getPhotos
(
albumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
map
{
it
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumsPhotosDb
(
albumId
:
Int
)
=
db
.
getChildAlbums
(
albumId
)
.
toList
()
.
toObservable
()
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
AlbumPreviewModel
>>
=
Observable
.
mergeDelayError
(
arrayListOf
(
fetchAlbumPhotosApi
(
albumId
),
fetchAlbumsPhotosDb
(
albumId
))
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
//endregion concrete Albums
}
app/src/main/java/com/biganto/visual/roompark/data/repository/api/IApi.kt
View file @
d92a390c
...
...
@@ -29,7 +29,7 @@ interface IRoomParkApi {
fun
getFavorites
(
userToken
:
String
):
Observable
<
List
<
EstateRaw
>>
fun
getFeeds
():
Observable
<
List
<
FeedRaw
>>
fun
getArticle
(
id
:
Int
):
Observable
<
ArticleRaw
>
fun
getPhotos
(
parentId
:
Int
):
Observable
<
List
<
NewsPhoto
Raw
>>
fun
getPhotos
(
parentId
:
Int
):
Observable
<
List
<
GalleryImage
Raw
>>
fun
getEstatePlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanTypeRaw
>>
fun
getDirectPlan
(
estateId
:
Int
,
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/IRoomParkMobileApi.kt
View file @
d92a390c
...
...
@@ -241,7 +241,7 @@ interface IRoomParkMobileApi{
@Query
(
CLIENT_VERSION_PARAM
)
clientVersion
:
String
=
DEFAULT_CLIENT_VERSION
,
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
PHOTOS_ALBUMD_ID_PARAM
)
id
:
Int
):
Observable
<
Response
<
List
<
NewsPhoto
Raw
>>>
):
Observable
<
Response
<
List
<
GalleryImage
Raw
>>>
@GET
(
"$API_URL$GET_PLAN_TYPES_METHOD$DELIMITER"
)
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/RetrofitRepository.kt
View file @
d92a390c
...
...
@@ -85,7 +85,7 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
.
subscribeOn
(
Schedulers
.
io
())
.
compose
(
RetrofitResponseValidation
())
override
fun
getPhotos
(
parentId
:
Int
):
Observable
<
List
<
NewsPhoto
Raw
>>
=
override
fun
getPhotos
(
parentId
:
Int
):
Observable
<
List
<
GalleryImage
Raw
>>
=
api
.
getPhotos
(
id
=
parentId
)
.
subscribeOn
(
Schedulers
.
io
())
.
compose
(
RetrofitResponseValidation
())
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/raw/response.kt
View file @
d92a390c
...
...
@@ -115,7 +115,8 @@ data class ImageAlbumRaw(
val
title
:
String
,
val
sort
:
Int
,
val
date
:
Date
,
val
parent_id
:
Int
val
parent_id
:
Int
,
val
preview
:
String
)
data class
GalleryImageRaw
(
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/SupportTypes.kt
View file @
d92a390c
...
...
@@ -29,7 +29,7 @@ class RevisionString(private val value:String, private val revision:String?){
@Serializable
class
TitledPhoto
(
val
title
:
String
,
val
url
:
String
){
data
class
TitledPhoto
(
val
title
:
String
,
val
url
:
String
){
companion
object
{
private
const
val
delimiter
=
'ø'
...
...
@@ -39,6 +39,8 @@ class TitledPhoto(val title:String, val url:String){
title
=
str
.
substringBefore
(
delimiter
),
url
=
str
.
substringAfter
(
delimiter
)
)
fun
delimeterString
()
=
"$title$delimeter$url"
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/ImageAlbum.kt
View file @
d92a390c
...
...
@@ -20,4 +20,6 @@ interface ImageAlbum : Persistable {
val
sort
:
Int
@get
:
Convert
(
IsoDateConverter
::
class
)
val
published
:
Date
val
preview
:
String
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/utils/TitledPhotoListConverter.java
View file @
d92a390c
...
...
@@ -15,6 +15,8 @@ import timber.log.Timber;
public
class
TitledPhotoListConverter
implements
Converter
<
List
<
TitledPhoto
>,
String
>
{
private
static
final
String
stringDelimeter
=
"♀°♀"
;
@SuppressWarnings
(
"unchecked"
)
@Override
public
Class
<
List
<
TitledPhoto
>>
getMappedType
()
{
...
...
@@ -33,19 +35,34 @@ public class TitledPhotoListConverter implements Converter<List<TitledPhoto>, St
@Override
public
String
convertToPersisted
(
List
<
TitledPhoto
>
value
)
{
return
value
==
null
?
null
:
null
;
//Json.Companion.stringify(TitledPhoto(),value)
if
(
value
==
null
)
{
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
();
int
index
=
0
;
for
(
TitledPhoto
str:
value
)
{
if
(
index
>
0
)
{
sb
.
append
(
stringDelimeter
);
}
sb
.
append
(
str
.
delimeterString
());
index
++;
}
return
sb
.
toString
();
}
@Override
public
List
<
TitledPhoto
>
convertToMapped
(
Class
<?
extends
List
<
TitledPhoto
>>
type
,
String
value
)
{
try
{
return
value
==
null
?
null
:
null
;
//new TitledPhoto(value);
ArrayList
<
TitledPhoto
>
list
=
new
ArrayList
<>();
if
(
value
!=
null
&&
!
value
.
isEmpty
())
for
(
String
s
:
value
.
split
(
stringDelimeter
))
list
.
add
(
new
TitledPhoto
(
s
));
return
list
;
}
catch
(
Exception
e
){
Timber
.
e
(
"Wrong stored data format! {%s}"
,
value
);
return
new
ArrayList
<
TitledPhoto
>(
1
);
//TitledPhoto("","")
);
return
new
ArrayList
<
TitledPhoto
>(
0
);
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
d92a390c
...
...
@@ -74,6 +74,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
entity
.
setTitle
(
raw
.
title
)
entity
.
setPublished
(
raw
.
date
)
entity
.
setSort
(
raw
.
sort
)
entity
.
setPreview
(
raw
.
preview
)
return
entity
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DevProgressContract.kt
View file @
d92a390c
package
com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.domain.model.PhotoModel
import
com.biganto.visual.roompark.domain.model.WebCamListModel
import
com.biganto.visual.roompark.domain.model.WebCamModel
import
io.reactivex.rxjava3.core.Observable
import
io.reactivex.rxjava3.core.Single
import
com.biganto.visual.roompark.domain.model.*
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
...
...
@@ -15,6 +10,7 @@ interface DevProgressContract{
fun
getProgressCards
():
io
.
reactivex
.
Observable
<
List
<
AlbumPreviewModel
>>
fun
getProgressAlbumList
(
albumId
:
Int
):
io
.
reactivex
.
Observable
<
List
<
AlbumPreviewModel
>>
fun
getAlbumPreviews
(
albumId
:
Int
):
io
.
reactivex
.
Observable
<
List
<
AlbumPhotoPreviewModel
>>
fun
getAlbumPhoto
(
photoId
:
Int
):
io
.
reactivex
.
Observable
<
PhotoModel
>
fun
getWebCamsList
():
io
.
reactivex
.
Observable
<
WebCamListModel
>
fun
getWebCamStream
(
camId
:
Int
):
io
.
reactivex
.
Observable
<
WebCamModel
>
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/albums.kt
View file @
d92a390c
...
...
@@ -24,6 +24,17 @@ data class AlbumPhotoPreviewModel(
val
isRead
:
Boolean
)
data class
AlbumSortedModel
(
val
title
:
Date
,
val
items
:
List
<
AlbumPhotoPreviewModel
>
)
fun
List
<
AlbumPhotoPreviewModel
>.
sortedByPublished
()
=
this
.
asSequence
().
groupBy
{
it
.
published
}.
map
{
map
->
AlbumSortedModel
(
map
.
key
,
map
.
value
)
}.
sortedByDescending
{
it
.
title
}
data class
PhotoListModel
(
val
items
:
List
<
PhotoModel
>)
data class
PhotoModel
(
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/albumsUseCase.kt
View file @
d92a390c
...
...
@@ -16,6 +16,9 @@ class AlbumsUseCase @Inject constructor(
fun
getChildAlbum
(
parentAlbumId
:
Int
)
=
contract
.
getProgressAlbumList
(
parentAlbumId
)
fun
getPhotos
(
parentAlbumId
:
Int
)
=
contract
.
getProgressAlbumList
(
parentAlbumId
)
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenController.kt
View file @
d92a390c
...
...
@@ -31,7 +31,7 @@ class AlbumsScreenController :
constructor
(
args
:
Bundle
):
super
(
args
)
constructor
(
id
:
Int
)
:
super
(
bundleOf
(
SELECTED_
CA
M_INDEX_KEY
to
id
))
constructor
(
id
:
Int
)
:
super
(
bundleOf
(
SELECTED_
ALBU
M_INDEX_KEY
to
id
))
@BindView
(
R
.
id
.
webCamPlayerView
)
lateinit
var
playerView
:
PlayerView
...
...
@@ -61,7 +61,7 @@ class AlbumsScreenController :
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
,
args
.
getInt
(
SELECTED_
CA
M_INDEX_KEY
))
,
args
.
getInt
(
SELECTED_
ALBU
M_INDEX_KEY
))
.
inject
(
this
)
// @Inject
...
...
@@ -95,6 +95,6 @@ class AlbumsScreenController :
}
override
fun
getLayoutId
():
Int
=
R
.
layout
.
prog
override
fun
getLayoutId
():
Int
=
R
.
layout
.
albums_screen
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
d92a390c
...
...
@@ -2,7 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.albums
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.AlbumssInteractor
import
com.biganto.visual.roompark.presentation.screen.web_cam.SELECTED_
CA
M_INDEX_KEY
import
com.biganto.visual.roompark.presentation.screen.web_cam.SELECTED_
ALBU
M_INDEX_KEY
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.schedulers.Schedulers
...
...
@@ -16,7 +16,7 @@ import javax.inject.Named
class
AlbumsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
AlbumssInteractor
,
@Named
(
SELECTED_
CAM_INDEX_KEY
)
private
var
selectedCam
Index
:
Int
,
@Named
(
SELECTED_
ALBUM_INDEX_KEY
)
private
var
selected
Index
:
Int
)
:
BigantoBasePresenter
<
AlbumsScreen
,
AlbumsScreenViewState
>()
{
...
...
@@ -25,10 +25,15 @@ class AlbumsScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
.
map
{
it
.
s
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
}
val
state
=
restoreStateObservable
.
mergeWith
(
interactor
.
fetchCams
()
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
.
items
.
toList
(),
selectedCamIndex
)}
)
.
mergeWith
(
fetchParents
)
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
subscribeViewState
(
state
.
cast
(
AlbumsScreenViewState
::
class
.
java
),
AlbumsScreen
::
render
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenViewState.kt
View file @
d92a390c
package
com.biganto.visual.roompark.presentation.screen.albums
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.AlbumPhotoPreviewModel
import
com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.domain.model.AlbumSortedModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
/**
...
...
@@ -13,7 +13,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
sealed
class
AlbumsScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
AlbumsScreenViewState
()
class
AlbumsListLoaded
(
val
list
:
List
<
AlbumPreviewModel
>,
val
selectedCamIndex
:
Int
)
:
AlbumsScreenViewState
()
class
AlbumsSelected
(
val
list
:
List
<
Album
PhotoPreview
Model
>)
:
AlbumsScreenViewState
()
class
AlbumsSelected
(
val
list
:
List
<
Album
Sorted
Model
>)
:
AlbumsScreenViewState
()
class
PhotoSelected
(
val
photoId
:
Int
)
:
AlbumsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
AlbumsScreenViewState
()
}
\ No newline at end of file
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