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
9e455842
Commit
9e455842
authored
Apr 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reactor plan types;
add contract and repository; add di for those components
parent
633d6223
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
240 additions
and
125 deletions
+240
-125
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+2
-106
PlanRepository.kt
...anto/visual/roompark/data/data_provider/PlanRepository.kt
+162
-0
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+2
-0
DataModule.kt
.../java/com/biganto/visual/roompark/di/dagger/DataModule.kt
+4
-0
DealContract.kt
...m/biganto/visual/roompark/domain/contract/DealContract.kt
+0
-12
FlatPlanContract.kt
...ganto/visual/roompark/domain/contract/FlatPlanContract.kt
+21
-0
estate.kt
...a/com/biganto/visual/roompark/domain/interactor/estate.kt
+0
-1
estateUseCase.kt
.../biganto/visual/roompark/domain/use_case/estateUseCase.kt
+5
-6
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+35
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+9
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
9e455842
...
@@ -6,15 +6,12 @@ import com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
...
@@ -6,15 +6,12 @@ import com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.DealEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPresetEntity
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Completable
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -31,10 +28,9 @@ const val TEST_DEAL_TOKEN =
...
@@ -31,10 +28,9 @@ const val TEST_DEAL_TOKEN =
"183|PQZi0LmaYswPmFHcLb0pHITkg_7aJNC4x2IIC90kbRKE1GBt2m48tdi-1jb9jo9MYoxCGyvJtDy3ret7_nAoAg=="
"183|PQZi0LmaYswPmFHcLb0pHITkg_7aJNC4x2IIC90kbRKE1GBt2m48tdi-1jb9jo9MYoxCGyvJtDy3ret7_nAoAg=="
class
EstateRepository
@Inject
constructor
(
class
EstateRepository
@Inject
constructor
(
private
val
local
:
ILocalStore
,
local
:
ILocalStore
,
private
val
api
:
IRoomParkApi
,
private
val
api
:
IRoomParkApi
,
private
val
db
:
IDb
,
private
val
db
:
IDb
private
val
file
:
FileModule
):
DealContract
{
):
DealContract
{
...
@@ -96,106 +92,6 @@ class EstateRepository @Inject constructor(
...
@@ -96,106 +92,6 @@ class EstateRepository @Inject constructor(
}
}
private
fun
getPlanTypesApi
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetEntity
>>
=
api
.
getEstatePlanTypes
(
estateId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
map
{
it
.
onEach
{
plan
->
val
e
=
EstateEntity
()
e
.
setId
(
estateId
)
plan
.
estateId
=
e
}.
toList
()
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
override
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
=
Observable
.
mergeDelayError
(
arrayListOf
(
getPlanTypesApi
(
estateId
))
).
map
{
l
->
List
(
l
.
size
)
{
fromEntity
(
l
[
it
])
}
}
private
fun
getPlanApi
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
?:
false
,
sizes
?:
false
,
walls
?:
false
,
electric
?:
false
)
.
map
{
val
sFile
=
getPlanFile
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
)
file
.
saveFileToDisk
(
sFile
,
it
)
sFile
.
path
}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
getPlanFile
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
=
FileModule
.
getDirectory
(
file
.
context
,
FileModule
.
FileDirectory
.
PlanTypeDir
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
))
override
fun
getEmptyPlan
(
estateId
:
Int
,
planId
:
Int
):
Observable
<
String
>
=
Observable
.
mergeDelayError
(
arrayListOf
(
getPlanApi
(
estateId
,
planId
))
)
override
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
=
Observable
.
fromCallable
{
getPlanFile
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
)
}.
switchMap
{
if
(
it
.
exists
())
Observable
.
just
(
it
.
path
)
else
getPlanApi
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
}
// fun getPlanRequestString(estateId: Int
// , planId:Int
// , furniture:Boolean
// , sizes:Boolean
// , walls:Boolean
// , electric:Boolean
// ) = api.getDirectPlan(estateId,planId,furniture,sizes,electric).
private
val
getDealsApi
:
Observable
<
List
<
DealEntity
>>
=
private
val
getDealsApi
:
Observable
<
List
<
DealEntity
>>
=
local
.
recentUser
()
local
.
recentUser
()
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/PlanRepository.kt
0 → 100644
View file @
9e455842
package
com.biganto.visual.roompark.data.data_provider
import
com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import
com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.db.requrey.model.PlanPresetEntity
import
com.biganto.visual.roompark.data.repository.file.FileModule
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.FlatPlanContract
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
io.reactivex.Observable
import
io.reactivex.schedulers.Schedulers
import
timber.log.Timber
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 20.04.2020.
*/
class
PlanRepository
@Inject
constructor
(
private
val
local
:
ILocalStore
,
private
val
api
:
IRoomParkApi
,
private
val
db
:
IDb
,
private
val
file
:
FileModule
)
:
FlatPlanContract
{
private
fun
getPlanTypesApi
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetEntity
>>
=
api
.
getEstatePlanTypes
(
estateId
)
.
doOnNext
{
Timber
.
d
(
"raw0 $it"
)
}
.
map
{
fromRawList
(
it
,
::
fromRaw
)
}
.
map
{
it
.
onEach
{
plan
->
val
e
=
EstateEntity
()
e
.
setId
(
estateId
)
plan
.
estateId
=
e
}.
toList
()
}
.
doOnNext
(
db
::
blockingUpsert
)
.
subscribeOn
(
Schedulers
.
io
())
override
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
=
Observable
.
mergeDelayError
(
arrayListOf
(
getPlanTypesApi
(
estateId
))
).
map
{
l
->
List
(
l
.
size
)
{
fromEntity
(
l
[
it
])
}
}
private
fun
getPlanApi
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
?:
false
,
sizes
?:
false
,
walls
?:
false
,
electric
?:
false
)
.
map
{
val
sFile
=
getPlanFile
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
)
file
.
saveFileToDisk
(
sFile
,
it
)
sFile
.
path
}
.
subscribeOn
(
Schedulers
.
io
())
private
fun
getPlanFile
(
featuresVariant
:
PlanFeaturesVariant
)
=
getPlanFile
(
estateId
=
featuresVariant
.
estateId
,
planId
=
featuresVariant
.
planId
,
furniture
=
featuresVariant
.
furniture
,
sizes
=
featuresVariant
.
sizes
,
walls
=
featuresVariant
.
walls
,
electric
=
featuresVariant
.
electric
)
private
fun
getPlanFile
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
=
FileModule
.
getDirectory
(
file
.
context
,
FileModule
.
FileDirectory
.
PlanTypeDir
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
))
// override fun getEmptyPlan(estateId: Int
// ,planId:Int): Observable<String> =
// Observable.mergeDelayError(
// arrayListOf(getPlanApi(estateId,planId))
// )
override
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
=
Observable
.
fromCallable
{
getPlanFile
(
estateId
=
estateId
,
planId
=
planId
,
furniture
=
furniture
,
walls
=
walls
,
sizes
=
sizes
,
electric
=
electric
)
}.
switchMap
{
if
(
it
.
exists
())
Observable
.
just
(
it
.
path
)
else
getPlanApi
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
}
// fun getPlanRequestString(estateId: Int
// , planId:Int
// , furniture:Boolean
// , sizes:Boolean
// , walls:Boolean
// , electric:Boolean
// ) = api.getDirectPlan(estateId,planId,furniture,sizes,electric).
}
val
PlanPresetModel
.
featuresVariants
:
List
<
PlanFeaturesVariant
>
get
()
{
if
(
this
.
features
.
isNullOrEmpty
())
return
arrayListOf
()
val
variants
=
this
.
features
.
size
return
arrayListOf
()
}
//List9 PlanFeaturesVariant()
data class
PlanFeaturesVariant
(
val
estateId
:
Int
,
val
planId
:
Int
,
val
furniture
:
Boolean
?,
val
sizes
:
Boolean
?,
val
walls
:
Boolean
?,
val
electric
:
Boolean
?
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
View file @
9e455842
...
@@ -66,6 +66,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
...
@@ -66,6 +66,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun
provideTour
():
TourContract
fun
provideTour
():
TourContract
fun
providePlan
():
FlatPlanContract
fun
provideLifeCycle
():
ForegroundLifecycleObserver
fun
provideLifeCycle
():
ForegroundLifecycleObserver
fun
provideNotifivations
():
INotificationCenter
fun
provideNotifivations
():
INotificationCenter
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/DataModule.kt
View file @
9e455842
...
@@ -59,6 +59,10 @@ abstract class ContractRepositoryModule {
...
@@ -59,6 +59,10 @@ abstract class ContractRepositoryModule {
@Binds
@Binds
@Singleton
@Singleton
abstract
fun
provideTourContract
(
impl
:
ToursRepository
):
TourContract
abstract
fun
provideTourContract
(
impl
:
ToursRepository
):
TourContract
@Binds
@Singleton
abstract
fun
provideTourContract
(
impl
:
PlanRepository
):
FlatPlanContract
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/DealContract.kt
View file @
9e455842
...
@@ -2,7 +2,6 @@ package com.biganto.visual.roompark.domain.contract
...
@@ -2,7 +2,6 @@ package com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
io.reactivex.Completable
import
io.reactivex.Completable
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -15,17 +14,6 @@ interface DealContract{
...
@@ -15,17 +14,6 @@ interface DealContract{
fun
getFavorites
()
:
Observable
<
List
<
EstateModel
>>
fun
getFavorites
()
:
Observable
<
List
<
EstateModel
>>
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getEstate
(
estateId
:
Int
):
Observable
<
EstateModel
>
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
fun
getEmptyPlan
(
estateId
:
Int
,
planId
:
Int
):
Observable
<
String
>
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
fun
getDeals
():
Observable
<
List
<
DealModel
>>
fun
getDeals
():
Observable
<
List
<
DealModel
>>
fun
fetchEstate
(
building
:
Int
,
number
:
Int
):
Observable
<
EstateModel
>
fun
fetchEstate
(
building
:
Int
,
number
:
Int
):
Observable
<
EstateModel
>
fun
setDealRead
(
dealId
:
String
):
Completable
fun
setDealRead
(
dealId
:
String
):
Completable
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/FlatPlanContract.kt
0 → 100644
View file @
9e455842
package
com.biganto.visual.roompark.domain.contract
import
com.biganto.visual.roompark.domain.model.PlanPresetModel
import
io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 20.04.2020.
*/
interface
FlatPlanContract
{
fun
getPlanTypes
(
estateId
:
Int
):
Observable
<
List
<
PlanPresetModel
>>
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?):
Observable
<
String
>
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/estate.kt
View file @
9e455842
...
@@ -17,7 +17,6 @@ class EstateInteractor @Inject constructor(
...
@@ -17,7 +17,6 @@ class EstateInteractor @Inject constructor(
fun
getPlanTypes
(
estateId
:
Int
)
=
fun
getPlanTypes
(
estateId
:
Int
)
=
useCase
.
getEstatePlanPresets
(
estateId
)
useCase
.
getEstatePlanPresets
(
estateId
)
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
useCase
.
getPlan
(
estateId
,
planId
)
fun
getPlan
(
plan
:
PlanPresetModel
)
=
fun
getPlan
(
plan
:
PlanPresetModel
)
=
useCase
.
getPlan
(
useCase
.
getPlan
(
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/estateUseCase.kt
View file @
9e455842
package
com.biganto.visual.roompark.domain.use_case
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -8,7 +9,8 @@ import javax.inject.Inject
...
@@ -8,7 +9,8 @@ import javax.inject.Inject
*/
*/
class
EstateUseCase
@Inject
constructor
(
class
EstateUseCase
@Inject
constructor
(
private
val
contract
:
DealContract
private
val
contract
:
DealContract
,
private
val
planContract
:
FlatPlanContract
)
{
)
{
fun
fetchFavorites
()
=
contract
.
getFavorites
()
fun
fetchFavorites
()
=
contract
.
getFavorites
()
...
@@ -19,12 +21,9 @@ class EstateUseCase @Inject constructor(
...
@@ -19,12 +21,9 @@ class EstateUseCase @Inject constructor(
contract
.
fetchEstate
(
building
,
number
)
contract
.
fetchEstate
(
building
,
number
)
fun
getEstatePlanPresets
(
estateId
:
Int
)
=
fun
getEstatePlanPresets
(
estateId
:
Int
)
=
c
ontract
.
getPlanTypes
(
estateId
)
planC
ontract
.
getPlanTypes
(
estateId
)
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
)
=
contract
.
getEmptyPlan
(
estateId
,
planId
)
fun
getPlan
(
fun
getPlan
(
estateId
:
Int
estateId
:
Int
,
planId
:
Int
,
planId
:
Int
...
@@ -32,7 +31,7 @@ class EstateUseCase @Inject constructor(
...
@@ -32,7 +31,7 @@ class EstateUseCase @Inject constructor(
,
sizes
:
Boolean
?
,
sizes
:
Boolean
?
,
walls
:
Boolean
?
,
walls
:
Boolean
?
,
electric
:
Boolean
?
,
electric
:
Boolean
?
)
=
c
ontract
.
getPlan
(
)
=
planC
ontract
.
getPlan
(
estateId
estateId
,
planId
,
planId
,
furniture
,
furniture
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
0 → 100644
View file @
9e455842
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 20.04.2020.
*/
class
PlanTypesUseCase
@Inject
constructor
(
private
val
planContract
:
FlatPlanContract
,
private
val
auth
:
AuthContract
){
// fun fetchNotDownloadedPlansSizes() =
// auth.currentUser()
// .map { user ->
// val list =
// user.deals?.map { it.estate as EstateEntity }?.toMutableList()
// ?: mutableListOf()
// list.addAll(user.estates?.map { it as EstateEntity } ?: arrayListOf())
// list
// }
// .flatMapIterable { it }
// .toFlowable(BackpressureStrategy.BUFFER)
// .parallel(4)
// .runOn(Schedulers.io())
// .flatMap { planContract.getPlanTypes(it.id) }
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
9e455842
...
@@ -133,6 +133,15 @@ class SettingsScreenController :
...
@@ -133,6 +133,15 @@ class SettingsScreenController :
override
fun
onViewBound
(
v
:
View
)
{
override
fun
onViewBound
(
v
:
View
)
{
bottomNavigationController
.
show
()
bottomNavigationController
.
show
()
toursDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
,
""
)
flatDownloaderTitle
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_plan_types_settings_with_sizes
,
""
)
setToolbar
()
setToolbar
()
bindRecycler
()
bindRecycler
()
}
}
...
...
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