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
6d527311
Commit
6d527311
authored
Apr 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plan types downloader
parent
02226f64
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
267 additions
and
6 deletions
+267
-6
DownloadPlansDialogController.kt
...ompark/conductor/dialogs/DownloadPlansDialogController.kt
+185
-0
PlanRepository.kt
...anto/visual/roompark/data/data_provider/PlanRepository.kt
+11
-0
FlatPlanContract.kt
...ganto/visual/roompark/domain/contract/FlatPlanContract.kt
+1
-0
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+3
-0
planTypesUseCase.kt
...ganto/visual/roompark/domain/use_case/planTypesUseCase.kt
+55
-6
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+11
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/DownloadPlansDialogController.kt
0 → 100644
View file @
6d527311
package
com.biganto.visual.roompark.conductor.dialogs
import
android.content.Context
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.ProgressBar
import
androidx.annotation.LayoutRes
import
androidx.core.os.bundleOf
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppComponent
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.domain.interactor.SettingsInteractor
import
com.biganto.visual.roompark.domain.interactor.ToursInteractor
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.domain.model.fromEntity
import
com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import
com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import
com.bluelinelabs.conductor.Controller
import
com.bumptech.glide.Glide
import
com.google.android.material.textview.MaterialTextView
import
dagger.Binds
import
dagger.BindsInstance
import
dagger.Component
import
dagger.Module
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.schedulers.Schedulers
import
jp.wasabeef.glide.transformations.BlurTransformation
import
jp.wasabeef.glide.transformations.ColorFilterTransformation
import
timber.log.Timber
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
class
DownloadPlansDialogController
:
Controller
{
constructor
():
super
()
constructor
(
args
:
Bundle
)
:
super
(
args
)
lateinit
var
progressBarDownload
:
ProgressBar
lateinit
var
downloaderBg
:
ImageView
lateinit
var
downloadTourTitleText
:
MaterialTextView
lateinit
var
cancelDownloadText
:
MaterialTextView
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
PlansDownloaderScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
}
private
var
downloadToken
=
DownloadUseCase
.
CancellationToken
(
false
)
@Inject
lateinit
var
downloader
:
SettingsInteractor
@Inject
lateinit
var
rpActivity
:
RoomParkMainActivity
lateinit
var
snackbar
:
ISnackBarProvider
private
val
disposables
=
CompositeDisposable
()
override
fun
onDetach
(
view
:
View
)
{
disposables
.
clear
()
super
.
onDetach
(
view
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
snackbar
=
ActivityModule
.
provideSnackBar
(
rpActivity
)
progressBarDownload
=
view
.
findViewById
(
R
.
id
.
downloadProgress
)
downloaderBg
=
view
.
findViewById
(
R
.
id
.
backgroundDownloader
)
cancelDownloadText
=
view
.
findViewById
(
R
.
id
.
cancelDownloadButton
)
downloadTourTitleText
=
view
.
findViewById
(
R
.
id
.
tourToDownloadTitle
)
// progress.visibility = View.VISIBLE
downloadToken
=
DownloadUseCase
.
CancellationToken
(
false
)
downloadTourTitleText
.
text
=
""
Glide
.
with
(
view
)
.
load
(
R
.
drawable
.
ic_plan
)
.
transform
(
BlurTransformation
(
13
,
8
)
,
ColorFilterTransformation
(
0
x99000000
.
toInt
()))
.
into
(
downloaderBg
)
disposables
.
add
(
downloader
.
downloadTourPlans
(
downloadToken
)
// .onErrorReturn { parseError(it);TourPreviewEntity() }
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
{
model
->
downloadTourTitleText
.
text
=
"${model.currentProgress}/${model.totalProgress}"
updateProgressBar
(
model
.
currentProgress
,
model
.
totalProgress
)
snackbar
.
showSnackBar
(
R
.
string
.
plan_types_download_completed
)
handleBack
()
}
,{
error
->
Timber
.
e
(
error
)
snackbar
.
showSnackBar
(
error
.
localizedMessage
)
handleBack
()
}
))
cancelDownloadText
.
setOnClickListener
{
handleBack
()
}
// downloadTour(it.tour.tour_id, downloadToken)
// view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
return
view
}
private
fun
updateProgressBar
(
curr
:
Int
,
max
:
Int
){
activity
?.
runOnUiThread
{
progressBarDownload
.
max
=
max
progressBarDownload
.
progress
=
curr
}
}
@LayoutRes
fun
getLayoutId
()
=
R
.
layout
.
download_tour_layout
override
fun
handleBack
():
Boolean
{
downloadToken
.
isCancelled
=
true
return
router
.
popController
(
this
)
}
}
@PerScreen
@Component
(
modules
=
[
DownloaderScreenModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
interface
PlansDownloaderScreenComponent
{
@Component
.
Factory
interface
Factory
{
fun
create
(
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
):
PlansDownloaderScreenComponent
}
//
// val presenter: ArticlesScreenPresenter
fun
inject
(
controller
:
DownloadPlansDialogController
)
}
@Module
abstract
class
DownloaderScreenModule
{
@PerScreen
@Binds
abstract
fun
provideContext
(
activity
:
RoomParkMainActivity
):
Context
@PerScreen
@Binds
abstract
fun
provideActivity
(
activity
:
RoomParkMainActivity
):
BaseRoomParkActivity
}
app/src/main/java/com/biganto/visual/roompark/data/data_provider/PlanRepository.kt
View file @
6d527311
...
@@ -110,6 +110,17 @@ class PlanRepository @Inject constructor(
...
@@ -110,6 +110,17 @@ class PlanRepository @Inject constructor(
// arrayListOf(getPlanApi(estateId,planId))
// arrayListOf(getPlanApi(estateId,planId))
// )
// )
override
fun
getPlan
(
featuresVariant
:
PlanFeaturesVariant
)
=
getPlan
(
estateId
=
featuresVariant
.
estateId
,
planId
=
featuresVariant
.
planId
,
furniture
=
featuresVariant
.
furniture
,
sizes
=
featuresVariant
.
sizes
,
walls
=
featuresVariant
.
walls
,
electric
=
featuresVariant
.
electric
)
override
fun
getPlan
(
estateId
:
Int
override
fun
getPlan
(
estateId
:
Int
,
planId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
,
furniture
:
Boolean
?
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/FlatPlanContract.kt
View file @
6d527311
...
@@ -21,4 +21,5 @@ interface FlatPlanContract{
...
@@ -21,4 +21,5 @@ interface FlatPlanContract{
,
electric
:
Boolean
?):
Observable
<
String
>
,
electric
:
Boolean
?):
Observable
<
String
>
fun
getPlanFile
(
featuresVariant
:
PlanFeaturesVariant
):
File
fun
getPlanFile
(
featuresVariant
:
PlanFeaturesVariant
):
File
fun
getPlan
(
featuresVariant
:
PlanFeaturesVariant
):
Observable
<
String
>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
6d527311
...
@@ -32,6 +32,9 @@ class SettingsInteractor @Inject constructor(
...
@@ -32,6 +32,9 @@ class SettingsInteractor @Inject constructor(
private
val
planTypes
:
PlanTypesUseCase
private
val
planTypes
:
PlanTypesUseCase
){
){
fun
downloadTourPlans
(
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
=
planTypes
.
downloadAllPlanTypes
(
cancellationToken
)
fun
fetchToursSizes
()
=
toursUc
.
fetchToursSizes
()
fun
fetchToursSizes
()
=
toursUc
.
fetchToursSizes
()
fun
fetchPlanTypesSizes
()
=
planTypes
.
fetchNotDownloadedPlansSizes
()
fun
fetchPlanTypesSizes
()
=
planTypes
.
fetchNotDownloadedPlansSizes
()
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/planTypesUseCase.kt
View file @
6d527311
package
com.biganto.visual.roompark.domain.use_case
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.data.data_provider.PlanFeaturesVariant
import
com.biganto.visual.roompark.data.data_provider.featuresVariants
import
com.biganto.visual.roompark.data.data_provider.featuresVariants
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.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
com.biganto.visual.roompark.domain.contract.FlatPlanContract
import
io.reactivex.Observable
import
io.reactivex.rxkotlin.subscribeBy
import
io.reactivex.schedulers.Schedulers
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -13,9 +17,9 @@ import javax.inject.Inject
...
@@ -13,9 +17,9 @@ import javax.inject.Inject
class
PlanTypesUseCase
@Inject
constructor
(
class
PlanTypesUseCase
@Inject
constructor
(
private
val
planContract
:
FlatPlanContract
,
private
val
planContract
:
FlatPlanContract
,
private
val
auth
:
AuthContract
private
val
auth
:
AuthContract
){
)
{
fun
fetchNotDownloadedPlansSizes
()
=
private
val
fetchAllPlanTypes
=
auth
.
currentUser
()
auth
.
currentUser
()
.
map
{
user
->
.
map
{
user
->
val
list
=
val
list
=
...
@@ -27,8 +31,53 @@ class PlanTypesUseCase @Inject constructor(
...
@@ -27,8 +31,53 @@ class PlanTypesUseCase @Inject constructor(
.
flatMapIterable
{
it
}
.
flatMapIterable
{
it
}
.
flatMap
{
.
flatMap
{
planContract
.
getPlanTypes
(
it
.
id
)
planContract
.
getPlanTypes
(
it
.
id
)
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}}
.
map
{
plantypes
->
plantypes
.
flatMap
{
plan
->
plan
.
featuresVariants
}
}
}
fun
fetchNotDownloadedPlansSizes
():
Observable
<
Int
>
=
fetchAllPlanTypes
.
map
{
list
->
list
.
sumBy
{
if
(
planContract
.
getPlanFile
(
it
).
exists
())
0
else
1
}
}
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
+
t2
}
fun
downloadAllPlanTypes
(
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
=
fetchAllPlanTypes
.
filter
{
!
cancellationToken
.
isCancelled
}
.
flatMap
{
downloadPlan
(
it
,
cancellationToken
)}
fun
downloadPlan
(
list
:
List
<
PlanFeaturesVariant
>
,
cancellationToken
:
DownloadUseCase
.
CancellationToken
)
:
Observable
<
DownloadProgress
>
{
var
runThreads
=
list
.
size
var
completedThreads
=
0
return
Observable
.
create
<
DownloadProgress
>
{
emitter
->
list
.
forEach
{
planContract
.
getPlan
(
it
)
.
filter
{
!
cancellationToken
.
isCancelled
}
.
subscribeOn
(
Schedulers
.
io
())
.
map
{
1
}
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
.
plus
(
t2
)
}
.
subscribe
{
emitter
.
onNext
(
DownloadProgress
(
it
,
list
.
size
))
completedThreads
++
}
}
while
(
completedThreads
<
runThreads
&&
cancellationToken
.
isCancelled
.
not
())
Thread
.
sleep
(
100
)
if
(
cancellationToken
.
isCancelled
)
emitter
.
onError
(
Throwable
(
"Cacnelled by user"
))
emitter
.
onComplete
()
}.
subscribeOn
(
Schedulers
.
computation
())
}
}
.
map
{
list
->
list
.
sumBy
{
if
(
planContract
.
getPlanFile
(
it
).
exists
())
0
else
1
}}
.
scan
{
t1
:
Int
,
t2
:
Int
->
t1
+
t2
}
}
}
data class
DownloadProgress
(
val
currentProgress
:
Int
,
val
totalProgress
:
Int
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
6d527311
...
@@ -7,11 +7,14 @@ import androidx.core.widget.NestedScrollView
...
@@ -7,11 +7,14 @@ import androidx.core.widget.NestedScrollView
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
butterknife.BindView
import
butterknife.OnClick
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.DownloadPlansDialogController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
...
@@ -105,6 +108,14 @@ class SettingsScreenController :
...
@@ -105,6 +108,14 @@ class SettingsScreenController :
@BindView
(
R
.
id
.
progress_lock_background
)
@BindView
(
R
.
id
.
progress_lock_background
)
lateinit
var
progressShame
:
View
lateinit
var
progressShame
:
View
@OnClick
(
R
.
id
.
downloadFlatCardsIcon
)
fun
onStartTourPlans
(){
router
.
pushController
(
RouterTransaction
.
with
(
DownloadPlansDialogController
())
.
pushChangeHandler
(
DialogChangeHandler
())
.
popChangeHandler
(
DialogChangeHandler
())
)
}
private
fun
setToolbar
(){
private
fun
setToolbar
(){
toolBar
.
appBar
.
liftOnScrollTargetViewId
=
R
.
id
.
nestedScrollContainer
toolBar
.
appBar
.
liftOnScrollTargetViewId
=
R
.
id
.
nestedScrollContainer
pushRecycler
.
isNestedScrollingEnabled
=
false
pushRecycler
.
isNestedScrollingEnabled
=
false
...
...
app/src/main/res/values/strings.xml
View file @
6d527311
...
@@ -123,5 +123,6 @@
...
@@ -123,5 +123,6 @@
<string
name=
"game_view_content_description"
/>
<string
name=
"game_view_content_description"
/>
<string
name=
"download_all_tours_settings_with_size"
>
Скачать виртуальные туры моих квартир из избранного и сделок (%s)
</string>
<string
name=
"download_all_tours_settings_with_size"
>
Скачать виртуальные туры моих квартир из избранного и сделок (%s)
</string>
<string
name=
"download_all_plan_types_settings_with_sizes"
>
Скачать карточки моих квартир из избранного и сделок (%s)
</string>
<string
name=
"download_all_plan_types_settings_with_sizes"
>
Скачать карточки моих квартир из избранного и сделок (%s)
</string>
<string
name=
"plan_types_download_completed"
>
Загрузка планов завершена.
</string>
</resources>
</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