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
6c9a5789
Commit
6c9a5789
authored
Apr 17, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sizes fetch
parent
3214a4f8
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
97 additions
and
52 deletions
+97
-52
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+3
-1
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+2
-6
ToursRepository.kt
...nto/visual/roompark/data/data_provider/ToursRepository.kt
+11
-7
BigantoRetrofitRepository.kt
.../data/repository/api/biganto/BigantoRetrofitRepository.kt
+3
-3
IBigantoMobileApi.kt
...roompark/data/repository/api/biganto/IBigantoMobileApi.kt
+2
-2
RetrofitModule.kt
...oompark/data/repository/api/retrofit/di/RetrofitModule.kt
+1
-1
IDb.kt
...ava/com/biganto/visual/roompark/data/repository/db/IDb.kt
+1
-0
RequeryRepository.kt
.../roompark/data/repository/db/requrey/RequeryRepository.kt
+11
-0
raw2entity.kt
...anto/visual/roompark/data/repository/mapper/raw2entity.kt
+5
-5
TourDownloadService.kt
...ual/roompark/data/service/download/TourDownloadService.kt
+4
-9
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+2
-0
toures.kt
...ava/com/biganto/visual/roompark/domain/use_case/toures.kt
+33
-11
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+9
-0
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+5
-1
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+1
-0
settings_screen.xml
app/src/main/res/layout/settings_screen.xml
+2
-6
strings.xml
app/src/main/res/values/strings.xml
+2
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
6c9a5789
...
...
@@ -34,7 +34,9 @@
<activity
android:name=
".player.BigantoPlayerActivity"
android:screenOrientation=
"fullSensor"
android:configChanges=
"mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
android:largeHeap=
"true"
android:hardwareAccelerated=
"true"
android:process=
":UnityKillsMe"
>
</activity>
android:hardwareAccelerated=
"true"
android:process=
":UnityKillsMe"
>
</activity>
<service
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
6c9a5789
...
...
@@ -210,13 +210,9 @@ class EstateRepository @Inject constructor(
.
flatMap
{
user
->
api
.
getDeals
(
TEST_DEAL_TOKEN
)
//api.getDeals(user.authToken)
.
doOnError
(
Timber
::
e
)
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
doOnNext
{
it
.
forEach
{
deal
->
deal
.
user
=
user
}
}
.
map
{
List
(
it
.
size
){
index
->
fromRaw
(
it
[
index
],
user
)}
}
.
doOnNext
(
db
::
blockingUpsert
)
.
doOnNext
{
db
.
refreshUser
(
user
)
}
}
private
val
getDealsDb
:
Observable
<
List
<
DealEntity
>>
=
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/ToursRepository.kt
View file @
6c9a5789
...
...
@@ -30,13 +30,17 @@ class ToursRepository @Inject constructor(
override
fun
deleteToursDbInfo
():
Completable
=
Completable
.
merge
(
arrayListOf
(
db
.
dropTourFileJuncTable
(),
db
.
dropFileTable
(),
db
.
dropTourTable
()
))
.
doOnComplete
{
Timber
.
w
(
"Completed --"
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
Completable
.
merge
(
arrayListOf
(
db
.
dropTourFileJuncTable
(),
db
.
dropFileTable
(),
db
.
dropTourTable
(),
db
.
refreshEstatesWithTours
()
)
)
// .concatWith { }
.
doOnComplete
{
Timber
.
w
(
"Completed --"
)
}
.
doOnError
{
Timber
.
e
(
it
)
}
}
app/src/main/java/com/biganto/visual/roompark/data/repository/api/biganto/BigantoRetrofitRepository.kt
View file @
6c9a5789
...
...
@@ -56,7 +56,7 @@ class BigantoRetrofitRepository @Inject constructor(@Named("bigantoApi") retrof
override
fun
getTourFilesSizes
(
ids
:
List
<
String
>,
resolution
:
String
)
:
Observable
<
List
<
TourFilesSimpleDataRaw
>>
=
api
.
getTourFilesSize
(
ids
=
ids
,
resolution
=
resolution
)
.
getTourFilesSize
(
ids
=
ids
.
joinToString
(
separator
=
","
)
,
resolution
=
resolution
)
.
compose
(
RetrofitResponseValidation
())
.
doOnError
{
e
(
it
)
}
.
subscribeOn
(
Schedulers
.
io
())
...
...
@@ -70,7 +70,7 @@ class BigantoRetrofitRepository @Inject constructor(@Named("bigantoApi") retrof
override
fun
getOfferTours
(
multiTourIds
:
List
<
Int
>):
Observable
<
List
<
TourPreviewRaw
>>
=
api
.
getOfferTours
(
offerId
=
multiTourIds
)
.
getOfferTours
(
offerId
=
multiTourIds
.
joinToString
(
separator
=
","
)
)
.
compose
(
RetrofitResponseValidation
())
.
map
{
it
.
values
.
flatten
()
}
.
doOnError
{
e
(
it
)
}
...
...
@@ -78,7 +78,7 @@ class BigantoRetrofitRepository @Inject constructor(@Named("bigantoApi") retrof
override
fun
getOfferTours
(
multiTourId
:
Int
):
Observable
<
List
<
TourPreviewRaw
>>
=
api
.
getOfferTours
(
offerId
=
arrayListOf
(
multiTourId
))
.
getOfferTours
(
offerId
=
multiTourId
.
toString
(
))
.
compose
(
RetrofitResponseValidation
())
.
map
{
it
[
multiTourId
.
toString
()]
?.
toList
()
?:
error
(
"No tours avaliable"
)}
.
doOnError
{
e
(
it
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/biganto/IBigantoMobileApi.kt
View file @
6c9a5789
...
...
@@ -136,7 +136,7 @@ interface IBigantoMobileApi {
@Query
(
CLIENT_VERSION_PARAM
)
clientVersion
:
String
=
DEFAULT_CLIENT_VERSION
,
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
LANG_PARAM
)
languageCode
:
String
=
Locale
.
getDefault
().
language
,
@Query
(
GET_TOURS_FILES_ID
)
ids
:
List
<
String
>
,
@Query
(
GET_TOURS_FILES_ID
)
ids
:
String
,
@Query
(
GET_TOURS_FILES_RESOLUTION
)
resolution
:
String
):
Observable
<
Response
<
List
<
TourFilesSimpleDataRaw
>>>
...
...
@@ -156,7 +156,7 @@ interface IBigantoMobileApi {
@Query
(
CLIENT_VERSION_PARAM
)
clientVersion
:
String
=
DEFAULT_CLIENT_VERSION
,
@Query
(
API_VERSION_PARAM
)
apiVersion
:
String
=
DEFAULT_API_VERSION
,
@Query
(
LANG_PARAM
)
languageCode
:
String
=
Locale
.
getDefault
().
language
,
@Query
(
OFFER_GET_TOURS_ID
)
offerId
:
List
<
Int
>
@Query
(
OFFER_GET_TOURS_ID
)
offerId
:
String
):
Observable
<
Response
<
Map
<
String
,
List
<
TourPreviewRaw
>>>>
@Streaming
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/di/RetrofitModule.kt
View file @
6c9a5789
...
...
@@ -36,7 +36,7 @@ private const val TIMEOUT_SECONDS=120L
private
const
val
WRITE_SECONDS
=
120L
private
const
val
READ_SECONDS
=
120L
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
BODY
val
INTERCEPT_LOG_LEVEL
=
HttpLoggingInterceptor
.
Level
.
HEADERS
@Module
class
RetrofitModule
{
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/db/IDb.kt
View file @
6c9a5789
...
...
@@ -74,4 +74,5 @@ interface IDb {
fun
dropTourTable
():
Completable
fun
refreshUser
(
userEntity
:
UserEntity
):
Observable
<
UserEntity
>
fun
refreshEntities
(
entities
:
List
<
Persistable
>):
Observable
<
Iterable
<
Persistable
>>
fun
refreshEstatesWithTours
():
Completable
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/data/repository/db/requrey/RequeryRepository.kt
View file @
6c9a5789
...
...
@@ -17,6 +17,7 @@ import io.reactivex.rxkotlin.toCompletable
import
io.reactivex.schedulers.Schedulers
import
io.requery.Persistable
import
io.requery.android.sqlite.DatabaseSource
import
io.requery.kotlin.notNull
import
io.requery.reactivex.KotlinReactiveEntityStore
import
io.requery.reactivex.ReactiveResult
import
io.requery.sql.KotlinEntityDataStore
...
...
@@ -56,6 +57,16 @@ class RequeryRepository @Inject constructor(
override
fun
refreshUser
(
userEntity
:
UserEntity
):
Observable
<
UserEntity
>
=
store
.
refresh
(
userEntity
).
toObservable
()
override
fun
refreshEstatesWithTours
():
Completable
=
store
.
select
(
EstateEntity
::
class
)
.
where
(
EstateEntity
::
multitourId
.
notNull
())
.
get
()
.
observable
()
.
toList
()
.
toObservable
()
.
doOnNext
{
Timber
.
d
(
"bgg ${it.size}"
)
}
.
flatMapCompletable
{
store
.
refresh
(
it
).
ignoreElement
()}
override
fun
refreshEntities
(
entities
:
List
<
Persistable
>):
Observable
<
Iterable
<
Persistable
>>
=
store
.
refresh
(
entities
).
toObservable
()
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/mapper/raw2entity.kt
View file @
6c9a5789
...
...
@@ -113,11 +113,11 @@ fun fromRaw(raw:DealRaw):DealEntity {
}
fun
fromRaw
(
raw
:
DealRaw
,
user
:
UserEntity
):
DealEntity
{
val
entity
=
fromRaw
(
raw
)
entity
.
user
=
user
return
entity
}
fun
fromRaw
(
raw
:
DealRaw
,
user
:
UserEntity
):
DealEntity
=
fromRaw
(
raw
).
apply
{
this
.
user
=
user
this
.
estate
.
user
=
user
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/service/download/TourDownloadService.kt
View file @
6c9a5789
...
...
@@ -181,10 +181,8 @@ class DownloadManagerService @Inject constructor(
var
stop
:
Boolean
=
false
sink
.
use
{
while
(!
stop
&&
{
read
=
source
.
read
(
buffer
,
step
.
toLong
());
read
}()
!=
-
1L
)
{
model
.
tempDownloadedSize
+=
read
if
((
System
.
currentTimeMillis
()
-
timer
)
>
READ_SYNC_MILLS
||
source
.
exhausted
())
{
timer
=
System
.
currentTimeMillis
()
model
.
fileDownloadedSize
+=
model
.
tempDownloadedSize
model
.
tempDownloadedSize
+=
read
model
.
fileDownloadedSize
+=
read
if
(
model
.
tempOverallFileSize
==
0L
)
...
...
@@ -193,12 +191,7 @@ class DownloadManagerService @Inject constructor(
model
.
isDownloaded
=
(
source
.
exhausted
()
&&
(
model
.
fileDownloadedSize
==
model
.
tempOverallFileSize
||
model
.
tempOverallFileSize
==
0L
))
model
.
tempTourTotalDiff
=
0
model
.
tempDownloadedSize
=
0
}
}
}
...
...
@@ -286,6 +279,7 @@ class DownloadManagerService @Inject constructor(
totalSize
+=
file
.
totalSize
entity
}
Timber
.
w
(
"fffff $downloadedSize $totalSize"
)
setDownloadInfo
(
raw
.
id
.
toString
()
...
...
@@ -343,6 +337,7 @@ class DownloadManagerService @Inject constructor(
.
observeOn
(
Schedulers
.
computation
())
// .doOnNext{Timber.d("7 ${it}")}
.
flatMap
{
model
->
Timber
.
d
(
" model __ ${model}"
)
setDownloadInfo
(
model
.
tourId
,
totalSizedDiffSize
=
model
.
tempTourTotalDiff
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
6c9a5789
...
...
@@ -31,6 +31,8 @@ class SettingsInteractor @Inject constructor(
private
val
toursUc
:
TourPreviewsUseCase
){
fun
fetchToursSizes
()
=
toursUc
.
fetchToursSizes
()
private
fun
startDownloadService
()
{
val
i
=
Intent
(
activity
,
DownloadManagerService
::
class
.
java
)
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/toures.kt
View file @
6c9a5789
...
...
@@ -183,7 +183,7 @@ class TourPreviewsUseCase @Inject constructor(
?:
arrayListOf
()
)
fun
fetchToursSizes
()
=
fun
fetchToursSizes
()
:
Observable
<
Long
>
=
auth
.
currentUser
()
.
map
(
::
getUserEstates
)
.
map
{
it
.
filter
{
estates
->
estates
.
multitourId
!=
null
}.
toList
()
}
...
...
@@ -193,36 +193,58 @@ class TourPreviewsUseCase @Inject constructor(
if
(
it
.
tours
.
isNullOrEmpty
())
toursOffersToLoad
.
add
(
it
.
multitourId
!!
)
}
Timber
.
d
(
" targer estates : "
+
"${estates.map { it.tours?.size }} "
)
Timber
.
d
(
" targer toursOffersToLoad : $toursOffersToLoad "
)
Pair
(
estates
,
toursOffersToLoad
)
}
.
flatMap
{
pair
->
if
(!
pair
.
second
.
isEmpty
())
return
@flatMap
Observable
.
fromIterable
(
pair
.
second
)
.
flatMap
{
if
(
pair
.
second
.
isNotEmpty
())
{
val
loadedIds
=
mutableListOf
<
String
>()
return
@flatMap
Observable
.
merge
(
pair
.
second
.
map
{
fetchTourOffer
(
it
,
pair
.
first
.
first
{
estete
->
estete
.
multitourId
==
it
}.
id
)
).
doOnError
{
Timber
.
e
(
it
)
}
.
doOnNext
{
tours
->
loadedIds
.
addAll
(
tours
.
map
{
t
->
t
.
tour_id
})
}
}
).
takeLast
(
1
)
.
doOnNext
{
db
.
refreshEntities
(
pair
.
first
)
}
.
map
{
pair
.
first
}
else
return
@flatMap
Observable
.
just
(
pair
.
first
)
.
map
{
Pair
(
pair
.
first
,
loadedIds
)}
}
else
return
@flatMap
Observable
.
just
(
Pair
(
pair
.
first
,
null
))
}
.
flatMap
{
estates
->
.
doOnNext
{
Timber
.
d
(
" HERER "
)
}
.
flatMap
{
pair
->
val
estates
=
pair
.
first
for
(
estate
in
estates
)
{
Timber
.
d
(
" targer estates : ${estate.user} "
)
}
val
r
=
(
estates
.
first
().
user
as
UserEntity
).
targetResolution
var
knownSize
=
estates
.
flatMap
{
Timber
.
d
(
" targer R : $r "
)
var
knownSize
=
estates
.
flatMap
{
it
.
tours
?.
map
{
t
->
t
as
TourPreviewEntity
}
?.
asIterable
()
?:
arrayListOf
()
}.
filter
{
t
->
t
.
overallSize
>
0L
}
.
onEach
{
Timber
.
d
(
"it.overallSize - it.downloadedSize "
+
"${it.overallSize}/${it.downloadedSize}"
)
}
.
sumByLong
{
it
.
overallSize
-
it
.
downloadedSize
}
Timber
.
d
(
" targer knownSize : $knownSize "
)
val
toursToLoadSize
=
estates
.
flatMap
{
it
.
tours
?.
map
{
t
->
t
as
TourPreviewEntity
}
?.
asIterable
()
?:
arrayListOf
()
}.
filter
{
t
->
t
.
overallSize
<
1L
}
if
(
toursToLoadSize
.
isNullOrEmpty
())
return
@flatMap
Observable
.
just
(
knownSize
)
Timber
.
d
(
" targer toursToLoadSize : $toursToLoadSize "
)
val
listIds
=
toursToLoadSize
.
map
{
it
.
id
}.
toMutableList
()
pair
.
second
?.
let
{
listIds
.
addAll
(
it
)}
Timber
.
d
(
" targer estates : ${listIds} "
)
if
(
listIds
.
isNullOrEmpty
())
return
@flatMap
Observable
.
just
(
knownSize
)
else
return
@flatMap
api
.
getTourFilesSizes
(
toursToLoadSize
.
map
{
it
.
id
}
,
r
.
toString
()
listIds
,
r
.
toString
()
)
.
flatMapIterable
{
it
}
.
flatMap
{
rawSize
->
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
6c9a5789
...
...
@@ -150,6 +150,7 @@ class SettingsScreenController :
is
SettingsScreenViewState
.
LoadSubscriptions
->
render
(
viewState
)
is
SettingsScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
SettingsScreenViewState
.
SubscriptionError
->
render
(
viewState
)
is
SettingsScreenViewState
.
OnSizePrefetch
->
render
(
viewState
)
}
}
...
...
@@ -161,6 +162,14 @@ class SettingsScreenController :
clearCacheButton
.
setGone
(
false
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnSizePrefetch
)
{
toursDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
viewState
.
size
.
bytesToSize
()
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
LoadSubscriptions
){
(
pushRecycler
.
adapter
as
PushListAdapter
).
setItems
(
viewState
.
list
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
6c9a5789
...
...
@@ -38,6 +38,9 @@ class SettingsScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
val
fetchToursSize
=
interactor
.
fetchToursSizes
()
.
map
{
SettingsScreenViewState
.
OnSizePrefetch
(
it
)
}
val
onDownloadTours
=
intent
(
SettingsScreen
::
downloadAllTours
)
.
flatMap
{
interactor
.
startToursDownloading
()
.
andThen
(
Observable
.
just
(
SettingsScreenViewState
.
Idle
()))
...
...
@@ -120,7 +123,8 @@ class SettingsScreenPresenter @Inject constructor(
fetchSubscriptions
,
fetchCache
,
onSubChecked
,
onDownloadTours
onDownloadTours
,
fetchToursSize
)
)
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenViewState.kt
View file @
6c9a5789
...
...
@@ -18,6 +18,7 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
class
SomeError
(
val
exception
:
ExceptionString
)
:
SettingsScreenViewState
()
class
SignOut
()
:
SettingsScreenViewState
()
class
OnCacheDeleting
(
val
progress
:
Float
)
:
SettingsScreenViewState
()
class
OnSizePrefetch
(
val
size
:
Long
)
:
SettingsScreenViewState
()
class
LoadSubscriptions
(
val
list
:
List
<
TitledSubscriptionModel
>)
:
SettingsScreenViewState
()
class
LoadCachInfo
(
val
list
:
List
<
CachedDataModel
>)
:
SettingsScreenViewState
()
class
SubscriptionStatus
(
val
subId
:
Int
,
val
subState
:
Boolean
)
:
SettingsScreenViewState
()
...
...
app/src/main/res/layout/settings_screen.xml
View file @
6c9a5789
...
...
@@ -56,9 +56,7 @@
android:layout_marginEnd=
"32dp"
android:layout_weight=
"1"
android:gravity=
"start|center_vertical"
android:text=
"Скачать карточки моих
квартир из избранного
и сделок (4 MB)"
/>
android:text=
"@string/download_all_plan_types_settings_with_sizes"
/>
<ImageView
android:id=
"@+id/downloadFlatCardsIcon"
...
...
@@ -89,9 +87,7 @@
android:layout_marginEnd=
"32dp"
android:layout_weight=
"1"
android:gravity=
"start|center_vertical"
android:text=
"Скачать виртуальные туры
моих квартир из избранного
и сделок (477 MB)"
/>
android:text=
"@string/download_all_tours_settings_with_size"
/>
<ImageView
android:id=
"@+id/downloadToursIcon"
...
...
app/src/main/res/values/strings.xml
View file @
6c9a5789
...
...
@@ -121,5 +121,7 @@
<string
name=
"game_view_content_description"
/>
<string
name=
"download_all_tours_settings_with_size"
>
Скачать виртуальные туры моих квартир из избранного и сделок (%s)
</string>
<string
name=
"download_all_plan_types_settings_with_sizes"
>
Скачать карточки моих квартир из избранного и сделок (%s)
</string>
</resources>
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