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
8ec0d81b
Commit
8ec0d81b
authored
Dec 11, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added photos model
parent
d92a390c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
136 additions
and
14 deletions
+136
-14
AlbumsRepository.kt
...to/visual/roompark/data/data_provider/AlbumsRepository.kt
+6
-4
SupportTypes.kt
...isual/roompark/data/repository/db/requrey/SupportTypes.kt
+18
-3
GalleryPhoto.kt
...roompark/data/repository/db/requrey/model/GalleryPhoto.kt
+26
-0
PhotoResolutionsConverter.java
...epository/db/requrey/utils/PhotoResolutionsConverter.java
+69
-0
TitledPhotoListConverter.java
...repository/db/requrey/utils/TitledPhotoListConverter.java
+1
-1
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+13
-0
albums.kt
...a/com/biganto/visual/roompark/domain/interactor/albums.kt
+0
-3
ScreenPresenter.kt
...al/roompark/presentation/screen/albums/ScreenPresenter.kt
+3
-3
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/AlbumsRepository.kt
View file @
8ec0d81b
...
...
@@ -121,18 +121,20 @@ class AlbumsContractModule @Inject constructor(
private
fun
fetchAlbumPhotosApi
(
albumId
:
Int
)
=
api
.
getPhotos
(
albumId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
map
{
it
}
.
doOnNext
(
db
::
blockingUpsert
)
.
map
{
arrayListOf
<
AlbumPhotoPreviewModel
>()
}
// .map{ fromRawList(it,::fromRaw) }
// .map { it }
// .doOnNext(db::blockingUpsert)
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumsPhotosDb
(
albumId
:
Int
)
=
db
.
getChildAlbums
(
albumId
)
.
toList
()
.
toObservable
()
.
map
{
arrayListOf
<
AlbumPhotoPreviewModel
>()
}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
AlbumPreviewModel
>>
=
private
fun
fetchAlbumPhotos
(
albumId
:
Int
):
Observable
<
List
<
AlbumP
hotoP
reviewModel
>>
=
Observable
.
mergeDelayError
(
arrayListOf
(
fetchAlbumPhotosApi
(
albumId
),
fetchAlbumsPhotosDb
(
albumId
))
).
map
{
fromEntity
(
it
,
::
fromEntity
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/SupportTypes.kt
View file @
8ec0d81b
...
...
@@ -40,14 +40,29 @@ data class TitledPhoto(val title:String, val url:String){
url
=
str
.
substringAfter
(
delimiter
)
)
fun
delim
eterString
()
=
"$title$delime
ter$url"
fun
delim
iterString
()
=
"$title$delimi
ter$url"
}
@Serializable
data class
ResolutionRaw
(
data class
PhotoResolutions
(
val
res_name
:
String
,
val
url
:
String
,
val
width
:
Int
,
val
height
:
Int
)
)
{
companion
object
{
private
const
val
delimiter1
=
'ø'
private
const
val
delimiter2
=
'Õ'
private
const
val
delimiter3
=
'è'
}
constructor
(
str
:
String
)
:
this
(
res_name
=
str
.
substringBefore
(
delimiter1
),
url
=
str
.
substringAfter
(
delimiter1
).
substringBefore
(
delimiter2
),
width
=
str
.
substringAfter
(
delimiter2
).
substringBefore
(
delimiter3
).
toInt
(),
height
=
str
.
substringAfter
(
delimiter3
).
toInt
()
)
fun
delimiterString
()
=
"$res_name$delimiter1$url$delimiter2$width$delimiter3$height"
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/model/GalleryPhoto.kt
0 → 100644
View file @
8ec0d81b
package
com.biganto.visual.roompark.data.repository.db.requrey.model
import
com.biganto.visual.roompark.data.repository.db.requrey.PhotoResolutions
import
com.biganto.visual.roompark.data.repository.db.requrey.utils.PhotoResolutionsConverter
import
io.requery.Convert
import
io.requery.Entity
import
io.requery.Key
import
io.requery.Persistable
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
*/
@Entity
interface
GalleryPhoto
:
Persistable
{
@get
:
Key
val
id
:
Int
val
title
:
String
val
description
:
String
val
sort
:
Int
val
album_id
:
Int
@get
:
Convert
(
PhotoResolutionsConverter
::
class
)
val
resolutions
:
List
<
PhotoResolutions
>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/utils/PhotoResolutionsConverter.java
0 → 100644
View file @
8ec0d81b
package
com
.
biganto
.
visual
.
roompark
.
data
.
repository
.
db
.
requrey
.
utils
;
import
com.biganto.visual.roompark.data.repository.db.requrey.PhotoResolutions
;
import
java.util.ArrayList
;
import
java.util.List
;
import
io.requery.Converter
;
import
timber.log.Timber
;
/**
* Created by Vladislav Bogdashkin on 04.07.2018.
*/
public
class
PhotoResolutionsConverter
implements
Converter
<
List
<
PhotoResolutions
>,
String
>
{
private
static
final
String
stringDelimeter
=
"♀°♀"
;
@SuppressWarnings
(
"unchecked"
)
@Override
public
Class
<
List
<
PhotoResolutions
>>
getMappedType
()
{
return
(
Class
)
List
.
class
;
}
@Override
public
Class
<
String
>
getPersistedType
()
{
return
String
.
class
;
}
@Override
public
Integer
getPersistedSize
()
{
return
null
;
}
@Override
public
String
convertToPersisted
(
List
<
PhotoResolutions
>
value
)
{
if
(
value
==
null
)
{
return
""
;
}
StringBuilder
sb
=
new
StringBuilder
();
int
index
=
0
;
for
(
PhotoResolutions
str:
value
)
{
if
(
index
>
0
)
{
sb
.
append
(
stringDelimeter
);
}
sb
.
append
(
str
.
delimiterString
());
index
++;
}
return
sb
.
toString
();
}
@Override
public
List
<
PhotoResolutions
>
convertToMapped
(
Class
<?
extends
List
<
PhotoResolutions
>>
type
,
String
value
)
{
try
{
ArrayList
<
PhotoResolutions
>
list
=
new
ArrayList
<>();
if
(
value
!=
null
&&
!
value
.
isEmpty
())
for
(
String
s
:
value
.
split
(
stringDelimeter
))
list
.
add
(
new
PhotoResolutions
(
s
));
return
list
;
}
catch
(
Exception
e
){
Timber
.
e
(
"Wrong stored data format! {%s}"
,
value
);
return
new
ArrayList
<
PhotoResolutions
>(
0
);
}
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/utils/TitledPhotoListConverter.java
View file @
8ec0d81b
...
...
@@ -44,7 +44,7 @@ public class TitledPhotoListConverter implements Converter<List<TitledPhoto>, St
if
(
index
>
0
)
{
sb
.
append
(
stringDelimeter
);
}
sb
.
append
(
str
.
delim
e
terString
());
sb
.
append
(
str
.
delim
i
terString
());
index
++;
}
return
sb
.
toString
();
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
8ec0d81b
...
...
@@ -78,6 +78,19 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
return
entity
}
//fun fromRaw(raw:GalleryImageRaw) : GalleryPhotoEntity {
// val entity = GalleryPhotoEntity()
// entity.setId(raw.id)
// entity.setTitle(raw.title)
// entity.setPublished(raw.date)
// entity.setSort(raw.sort)
// entity.setPreview(raw.preview)
// return entity
//}
//fun fromRaw(raw: List<FeedRaw>):List<FeedEntity> = List(raw.size) { index-> fromRaw(raw[index]) }
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/albums.kt
View file @
8ec0d81b
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.AlbumsListModel
import
com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import
com.biganto.visual.roompark.domain.use_case.CamsUseCase
import
io.reactivex.Observable
import
javax.inject.Inject
/**
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/ScreenPresenter.kt
View file @
8ec0d81b
...
...
@@ -28,9 +28,9 @@ class AlbumsScreenPresenter @Inject constructor(
val
fetchParents
=
interactor
.
fetchHeaderAlbums
()
.
map
{
AlbumsScreenViewState
.
AlbumsListLoaded
(
it
,
selectedIndex
)
}
val
fetchSelected
=
interactor
.
fetchAlbumPhotos
(
selectedIndex
)
.
map
{
it
.
s
}
.
map
{
AlbumsScreenViewState
.
AlbumsSelected
(
it
}
//
val fetchSelected = interactor.fetchAlbumPhotos(selectedIndex)
//
.map { it.s}
//
.map { AlbumsScreenViewState.AlbumsSelected(it}
val
state
=
restoreStateObservable
.
mergeWith
(
fetchParents
)
...
...
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