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
95e93ea2
Commit
95e93ea2
authored
Apr 22, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add start tours downloading dialog
parent
8e272697
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
294 additions
and
2 deletions
+294
-2
StartToursDownloadingDialogController.kt
...ogs/tour_chooser/StartToursDownloadingDialogController.kt
+165
-0
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+2
-1
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+14
-1
tours_download_dialog_screen.xml
app/src/main/res/layout/tours_download_dialog_screen.xml
+106
-0
strings.xml
app/src/main/res/values/strings.xml
+7
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/StartToursDownloadingDialogController.kt
0 → 100644
View file @
95e93ea2
package
com.biganto.visual.roompark.conductor.dialogs.tour_chooser
import
android.content.Context
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Button
import
android.widget.ImageView
import
androidx.annotation.LayoutRes
import
androidx.recyclerview.widget.DividerItemDecoration
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
butterknife.BindView
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.data.repository.file.FileModule
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.model.TourModel
import
com.biganto.visual.roompark.domain.model.bytesToSize
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import
com.bluelinelabs.conductor.Controller
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
dagger.Binds
import
dagger.BindsInstance
import
dagger.Component
import
dagger.Module
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.disposables.CompositeDisposable
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.04.2019.
*/
private
const
val
TOTAL_SIZE_DOWNLOAD_KEY
=
"TOURS_TO_DOWNLOAD_OVERALL_SIZE"
class
StartToursDownloadingDialogController
:
Controller
{
constructor
(
args
:
Bundle
)
:
super
(
args
)
constructor
(
size
:
Long
)
:
super
(
Bundle
().
apply
{
putLong
(
TOTAL_SIZE_DOWNLOAD_KEY
,
size
)
}
)
private
val
detachDisposable
=
CompositeDisposable
()
override
fun
onDetach
(
view
:
View
)
{
detachDisposable
.
clear
()
super
.
onDetach
(
view
)
}
@Inject
lateinit
var
downloader
:
SettingsInteractor
@Inject
lateinit
var
file
:
FileModule
lateinit
var
snackbar
:
ISnackBarProvider
@Inject
lateinit
var
rpActivity
:
RoomParkMainActivity
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
DaggerStartToursDownloadingDialogScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
snackbar
=
ActivityModule
.
provideSnackBar
(
rpActivity
)
args
.
getLong
(
TOTAL_SIZE_DOWNLOAD_KEY
).
let
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
all_tours_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_size_title
,
it
.
bytesToSize
())
}
file
.
freeSpace
.
bytesToSize
().
let
{
view
.
findViewById
<
MaterialTextView
>(
R
.
id
.
disk_size_textView
)
.
text
=
resources
?.
getString
(
R
.
string
.
download_all_tours_disk_size_title
,
it
)
}
view
.
findViewById
<
Button
>(
R
.
id
.
alert_dismiss_button
)
.
setOnClickListener
{
handleBack
()
}
view
.
findViewById
<
Button
>(
R
.
id
.
close_current_button
)
.
setOnClickListener
{
handleBack
()
}
detachDisposable
.
add
(
view
.
findViewById
<
Button
>(
R
.
id
.
alert_ok_button
)
.
clicks
()
.
debounce
(
200
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
flatMapCompletable
{
downloader
.
startToursDownloading
()
}
.
subscribe
({
snackbar
.
showSnackBar
(
R
.
string
.
download_all_tours_start_snackbar_message
)
handleBack
()
},{
Timber
.
e
(
it
)
snackbar
.
showSnackBar
(
R
.
string
.
download_all_tours_errors_snackbar_message
)
handleBack
()
}
)
)
// view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view
.
setOnClickListener
{
handleBack
()
}
return
view
}
@LayoutRes
fun
getLayoutId
()
=
R
.
layout
.
tours_download_dialog_screen
override
fun
handleBack
():
Boolean
{
return
router
.
popCurrentController
()
}
}
@PerScreen
@Component
(
modules
=
[
StartToursDownloadingDialogScreenModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
interface
StartToursDownloadingDialogComponent
{
@Component
.
Factory
interface
Factory
{
fun
create
(
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
):
DownloaderScreenComponent
}
fun
inject
(
controller
:
StartToursDownloadingDialogController
)
}
@Module
abstract
class
StartToursDownloadingDialogScreenModule
{
@PerScreen
@Binds
abstract
fun
provideContext
(
activity
:
RoomParkMainActivity
):
Context
}
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
95e93ea2
...
@@ -116,11 +116,12 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -116,11 +116,12 @@ class FileModule @Inject constructor(val context: Application) {
}
}
val
getCoreCacheDirectory
:
String
val
getCoreCacheDirectory
:
String
get
(){
get
(){
return
rootFolder
.
absolutePath
return
rootFolder
.
absolutePath
}
}
val
freeSpace
=
rootFolder
.
freeSpace
companion
object
{
companion
object
{
fun
getDirectory
(
context
:
Context
,
dirType
:
FileDirectory
):
File
=
fun
getDirectory
(
context
:
Context
,
dirType
:
FileDirectory
):
File
=
File
(
context
.
filesDir
.
absolutePath
.
plus
(
dirType
.
dir
))
File
(
context
.
filesDir
.
absolutePath
.
plus
(
dirType
.
dir
))
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
95e93ea2
...
@@ -15,6 +15,7 @@ import com.biganto.visual.roompark.base.RoomParkMainActivity
...
@@ -15,6 +15,7 @@ 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.DownloadPlansDialogController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.tour_chooser.StartToursDownloadingDialogController
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
...
@@ -55,7 +56,8 @@ class SettingsScreenController :
...
@@ -55,7 +56,8 @@ class SettingsScreenController :
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
downloadAllTours
():
Observable
<
Int
>
=
override
fun
downloadAllTours
():
Observable
<
Int
>
=
toursDownloaderButton
.
clicks
().
map
{
1
}.
observeOn
(
AndroidSchedulers
.
mainThread
())
toursDownloaderButton
.
clicks
().
filter
{
false
}
.
map
{
1
}.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
val
refreshEmitter
=
BehaviorRelay
.
create
<
Int
>()
private
val
refreshEmitter
=
BehaviorRelay
.
create
<
Int
>()
...
@@ -128,6 +130,16 @@ class SettingsScreenController :
...
@@ -128,6 +130,16 @@ class SettingsScreenController :
)
)
}
}
@OnClick
(
R
.
id
.
downloadToursIcon
)
fun
startDownloadingDialog
(){
router
.
setRoot
(
RouterTransaction
.
with
(
StartToursDownloadingDialogController
(
tempToursSize
))
.
pushChangeHandler
(
FadeChangeHandler
())
.
popChangeHandler
(
FadeChangeHandler
())
)
}
private
var
tempToursSize
=
0L
private
fun
bindRecycler
(){
private
fun
bindRecycler
(){
pushRecycler
.
isNestedScrollingEnabled
=
true
pushRecycler
.
isNestedScrollingEnabled
=
true
pushRecycler
.
layoutManager
=
pushRecycler
.
layoutManager
=
...
@@ -184,6 +196,7 @@ class SettingsScreenController :
...
@@ -184,6 +196,7 @@ class SettingsScreenController :
}
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnSizePrefetch
)
{
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnSizePrefetch
)
{
tempToursSize
=
viewState
.
size
toursDownloaderTitle
.
text
=
toursDownloaderTitle
.
text
=
resources
?.
getString
(
resources
?.
getString
(
R
.
string
.
download_all_tours_settings_with_size
R
.
string
.
download_all_tours_settings_with_size
...
...
app/src/main/res/layout/tours_download_dialog_screen.xml
0 → 100644
View file @
95e93ea2
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/playTourCardOpacityLight"
android:backgroundTintMode=
"src_atop"
android:clickable=
"true"
android:focusable=
"true"
>
<com.google.android.material.card.MaterialCardView
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginStart=
"32dp"
android:layout_marginEnd=
"32dp"
app:cardElevation=
"2dp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintVertical_bias=
"0.32999998"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<com.google.android.material.textview.MaterialTextView
style=
"@style/Default_TextView.Header_Text"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"16dp"
android:text=
"@string/download_all_tours_notice_text"
android:textAlignment=
"center"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/all_tours_size_textView"
style=
"@style/Default_TextView.Notice_Text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"2dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:text=
"@string/download_all_tours_size_title"
/>
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/disk_size_textView"
style=
"@style/Default_TextView.Notice_Text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"2dp"
android:layout_marginStart=
"8dp"
android:layout_marginEnd=
"8dp"
android:text=
"@string/download_all_tours_disk_size_title"
/>
<LinearLayout
android:id=
"@+id/buttons_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:weightSum=
"2"
>
<Button
android:id=
"@+id/alert_ok_button"
style=
"@style/DefaultButton.DismissButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"@string/download_all_tours_yes_action"
/>
<Button
android:id=
"@+id/alert_dismiss_button"
style=
"@style/DefaultButton.DismissButton"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:text=
"@string/download_all_tours_cancel_action"
android:visibility=
"visible"
/>
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id=
"@+id/close_current_button"
android:layout_width=
"32dp"
android:layout_height=
"32dp"
android:layout_alignParentTop=
"true"
android:layout_alignParentEnd=
"true"
android:layout_marginTop=
"16dp"
android:layout_marginEnd=
"8dp"
android:clickable=
"false"
android:contentDescription=
"@string/content_description_close"
android:focusable=
"false"
android:scaleType=
"fitXY"
android:src=
"@drawable/ic_close_circled"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/values/strings.xml
View file @
95e93ea2
...
@@ -132,5 +132,12 @@
...
@@ -132,5 +132,12 @@
<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>
<string
name=
"plan_types_download_completed"
>
Загрузка планов завершена.
</string>
<string
name=
"download_plan_types_screen_title"
>
Cкачиваются планировки
</string>
<string
name=
"download_plan_types_screen_title"
>
Cкачиваются планировки
</string>
<string
name=
"download_all_tours_notice_text"
>
Загрузить все туры?
</string>
<string
name=
"download_all_tours_size_title"
>
Размер всех туров: %s
</string>
<string
name=
"download_all_tours_disk_size_title"
>
Размер свободного места на диске: %s
</string>
<string
name=
"download_all_tours_yes_action"
>
Скачать
</string>
<string
name=
"download_all_tours_cancel_action"
>
Отмена
</string>
<string
name=
"download_all_tours_errors_snackbar_message"
>
Ошибка при попытке загрузить туры!
</string>
<string
name=
"download_all_tours_start_snackbar_message"
>
Загрузка туров началась!
</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