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
76e62401
Commit
76e62401
authored
Mar 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/clear_cache' into develop
parents
8f4943c3
ab7bae22
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
177 additions
and
9 deletions
+177
-9
build.gradle
app/build.gradle
+1
-0
FilesRepository.kt
...nto/visual/roompark/data/data_provider/FilesRepository.kt
+2
-0
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+19
-0
RoomParkGlideModule.kt
.../biganto/visual/roompark/di/dagger/RoomParkGlideModule.kt
+41
-0
FilesContract.kt
.../biganto/visual/roompark/domain/contract/FilesContract.kt
+3
-0
settings.kt
...com/biganto/visual/roompark/domain/interactor/settings.kt
+2
-0
settingsUseCase.kt
...iganto/visual/roompark/domain/use_case/settingsUseCase.kt
+2
-0
AlbumHeaderAdapter.kt
...ark/presentation/screen/albums/util/AlbumHeaderAdapter.kt
+2
-0
AlbumListAdapter.kt
...mpark/presentation/screen/albums/util/AlbumListAdapter.kt
+2
-0
ScreenController.kt
.../roompark/presentation/screen/article/ScreenController.kt
+3
-0
textAdapter.kt
.../roompark/presentation/screen/article/util/textAdapter.kt
+2
-0
ScreenController.kt
...ual/roompark/presentation/screen/deal/ScreenController.kt
+2
-0
Adapter.kt
...visual/roompark/presentation/screen/deals/util/Adapter.kt
+2
-3
Adapter.kt
...al/roompark/presentation/screen/feed_list/util/Adapter.kt
+2
-0
ScreenContract.kt
...l/roompark/presentation/screen/settings/ScreenContract.kt
+2
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+28
-0
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+19
-0
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+1
-0
settings_screen.xml
app/src/main/res/layout/settings_screen.xml
+29
-6
styles.xml
app/src/main/res/values/styles.xml
+13
-0
No files found.
app/build.gradle
View file @
76e62401
...
@@ -125,6 +125,7 @@ dependencies {
...
@@ -125,6 +125,7 @@ dependencies {
implementation
'com.squareup.retrofit2:converter-gson:2.3.0'
implementation
'com.squareup.retrofit2:converter-gson:2.3.0'
implementation
'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation
'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation
'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation
'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation
'com.squareup.okhttp3:okhttp:3.14.0'
implementation
'com.squareup.okhttp3:logging-interceptor:3.12.2'
implementation
'com.squareup.okhttp3:logging-interceptor:3.12.2'
implementation
'com.squareup.okhttp3:okhttp-urlconnection:3.14.0'
implementation
'com.squareup.okhttp3:okhttp-urlconnection:3.14.0'
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FilesRepository.kt
View file @
76e62401
...
@@ -30,6 +30,8 @@ class FilesContractModule @Inject constructor(
...
@@ -30,6 +30,8 @@ class FilesContractModule @Inject constructor(
return
FileModule
.
getDirectory
(
context
,
d
)
return
FileModule
.
getDirectory
(
context
,
d
)
}
}
override
fun
deleteAllFiles
()
=
files
.
deleteAllCacheObservable
()
override
fun
getPlansSize
()
=
getFile
<
FileModule
.
FileDirectory
.
PlanTypeDir
>().
folderSize
override
fun
getPlansSize
()
=
getFile
<
FileModule
.
FileDirectory
.
PlanTypeDir
>().
folderSize
override
fun
getToursSize
()
=
getFile
<
FileModule
.
FileDirectory
.
ToursDir
>().
folderSize
override
fun
getToursSize
()
=
getFile
<
FileModule
.
FileDirectory
.
ToursDir
>().
folderSize
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
76e62401
...
@@ -6,6 +6,8 @@ import android.os.Environment
...
@@ -6,6 +6,8 @@ import android.os.Environment
import
com.biganto.visual.roompark.util.extensions.asInt
import
com.biganto.visual.roompark.util.extensions.asInt
import
com.google.gson.JsonElement
import
com.google.gson.JsonElement
import
dagger.Module
import
dagger.Module
import
io.reactivex.Observable
import
kotlinx.io.IOException
import
timber.log.Timber
import
timber.log.Timber
import
java.io.File
import
java.io.File
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -61,7 +63,24 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -61,7 +63,24 @@ class FileModule @Inject constructor(val context: Application) {
fun
deleteFile
(
uri
:
String
)=
getFile
(
uri
).
delete
()
fun
deleteFile
(
uri
:
String
)=
getFile
(
uri
).
delete
()
fun
deleteAllCacheObservable
()
=
Observable
.
create
<
Pair
<
Int
,
Int
>>
{
emitter
->
val
foldersToDelete
=
listOf
(
FileDirectory
.
Albums
(),
FileDirectory
.
FeedsDir
(),
FileDirectory
.
PlanTypeDir
(),
FileDirectory
.
ToursDir
()
)
foldersToDelete
.
forEachIndexed
{
index
,
dir
->
if
(
getDirectory
(
context
,
dir
).
deleteRecursively
())
emitter
.
onNext
(
Pair
(
index
,
foldersToDelete
.
size
-
1
))
else
emitter
.
onError
(
IOException
(
"Error occurred on files deleting!"
))
}
emitter
.
onComplete
()
}
val
getCoreCacheDirectory
:
String
val
getCoreCacheDirectory
:
String
get
(){
get
(){
return
rootFolder
.
absolutePath
return
rootFolder
.
absolutePath
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/RoomParkGlideModule.kt
0 → 100644
View file @
76e62401
package
com.biganto.visual.roompark.di.dagger
import
android.content.Context
import
com.bumptech.glide.GlideBuilder
import
com.bumptech.glide.annotation.GlideModule
import
com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory
import
com.bumptech.glide.module.AppGlideModule
/**
* Created by Vladislav Bogdashkin on 19.03.2020.
*/
@GlideModule
class
RoomParkGlideModule
:
AppGlideModule
()
{
// fun applyOptions(@NonNull context: Context?, @NonNull builder: GlideBuilder) {
// super.applyOptions(context, builder)
// builder.setDefaultRequestOptions(RequestOptions().format(DecodeFormat.PREFER_ARGB_8888))
// }
override
fun
applyOptions
(
context
:
Context
,
builder
:
GlideBuilder
)
{
val
filderName
=
"../files/photos"
builder
.
setDiskCache
(
InternalCacheDiskCacheFactory
(
context
,
filderName
,
1024L
*
1024L
*
256L
)
)
}
//
// fun registerComponents(
// @NonNull context: Context?, @NonNull glide: Glide?, @NonNull registry: Registry
// ) {
// registry.append(Photo::class.java, InputStream::class.java, Factory())
// }
// Disable manifest parsing to avoid adding similar modules twice.
override
fun
isManifestParsingEnabled
():
Boolean
{
return
false
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/contract/FilesContract.kt
View file @
76e62401
package
com.biganto.visual.roompark.domain.contract
package
com.biganto.visual.roompark.domain.contract
import
io.reactivex.Observable
/**
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
*/
...
@@ -11,4 +13,5 @@ interface FilesContract{
...
@@ -11,4 +13,5 @@ interface FilesContract{
fun
getFeedSize
():
Long
fun
getFeedSize
():
Long
fun
getToursSize
():
Long
fun
getToursSize
():
Long
fun
getPlansSize
():
Long
fun
getPlansSize
():
Long
fun
deleteAllFiles
():
Observable
<
Pair
<
Int
,
Int
>>
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/domain/interactor/settings.kt
View file @
76e62401
...
@@ -47,6 +47,8 @@ class SettingsInteractor @Inject constructor(
...
@@ -47,6 +47,8 @@ class SettingsInteractor @Inject constructor(
CachedDataModel
(
activity
.
resources
.
getString
(
R
.
string
.
overall_cache
),
it
,
0
)
CachedDataModel
(
activity
.
resources
.
getString
(
R
.
string
.
overall_cache
),
it
,
0
)
}
}
fun
deleteCacheFiles
()
=
settingsUseCase
.
clearAllCache
()
fun
getCacheInfo
()
=
fun
getCacheInfo
()
=
Observable
.
concatArray
(
plans
,
tours
,
feeds
,
albums
,
overall
).
toList
().
toObservable
()
Observable
.
concatArray
(
plans
,
tours
,
feeds
,
albums
,
overall
).
toList
().
toObservable
()
...
...
app/src/main/java/com/biganto/visual/roompark/domain/use_case/settingsUseCase.kt
View file @
76e62401
...
@@ -16,6 +16,8 @@ class SettingsUseCase @Inject constructor(
...
@@ -16,6 +16,8 @@ class SettingsUseCase @Inject constructor(
){
){
fun
signOut
()
=
authContract
.
signOut
()
fun
signOut
()
=
authContract
.
signOut
()
fun
clearAllCache
()
=
fileContract
.
deleteAllFiles
()
val
planTypesSize
val
planTypesSize
get
()
=
Observable
.
just
(
fileContract
.
getPlansSize
())
get
()
=
Observable
.
just
(
fileContract
.
getPlansSize
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumHeaderAdapter.kt
View file @
76e62401
...
@@ -9,6 +9,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
...
@@ -9,6 +9,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
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.presentation.screen.settings.util.CommonViewHolder
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
/**
/**
...
@@ -40,6 +41,7 @@ class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewMode
...
@@ -40,6 +41,7 @@ class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewMode
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
centerCrop
()
.
centerCrop
()
.
fitCenter
()
.
fitCenter
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
preview
)
.
into
(
preview
)
}
}
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/albums/util/AlbumListAdapter.kt
View file @
76e62401
...
@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
...
@@ -13,6 +13,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import
com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.detaches
import
com.jakewharton.rxbinding3.view.detaches
import
com.jakewharton.rxrelay2.BehaviorRelay
import
com.jakewharton.rxrelay2.BehaviorRelay
...
@@ -90,6 +91,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
...
@@ -90,6 +91,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
.
load
(
it
.
url
)
.
load
(
it
.
url
)
.
centerCrop
()
.
centerCrop
()
.
fitCenter
()
.
fitCenter
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
photoPreview
)
.
into
(
photoPreview
)
}}
}}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/ScreenController.kt
View file @
76e62401
...
@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdap
...
@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.presentation.screen.article.util.HtmlPageAdap
import
com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import
com.biganto.visual.roompark.presentation.screen.article.util.HtmlTag
import
com.biganto.visual.roompark.util.extensions.formatToSimple
import
com.biganto.visual.roompark.util.extensions.formatToSimple
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
jp.wasabeef.glide.transformations.BlurTransformation
import
jp.wasabeef.glide.transformations.BlurTransformation
import
timber.log.Timber
import
timber.log.Timber
...
@@ -123,10 +124,12 @@ class ArticleScreenController :
...
@@ -123,10 +124,12 @@ class ArticleScreenController :
Glide
.
with
(
blurPreview
)
Glide
.
with
(
blurPreview
)
.
load
(
viewState
.
item
.
previewUrl
)
.
load
(
viewState
.
item
.
previewUrl
)
.
transform
(
BlurTransformation
(
40
,
4
))
.
transform
(
BlurTransformation
(
40
,
4
))
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
blurPreview
)
.
into
(
blurPreview
)
Glide
.
with
(
articlePreview
)
Glide
.
with
(
articlePreview
)
.
load
(
viewState
.
item
.
previewUrl
)
.
load
(
viewState
.
item
.
previewUrl
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
articlePreview
)
.
into
(
articlePreview
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/article/util/textAdapter.kt
View file @
76e62401
...
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
...
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import
butterknife.ButterKnife
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
/**
/**
...
@@ -94,6 +95,7 @@ class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource
...
@@ -94,6 +95,7 @@ class HtmlImageViewHolder(itemView: View) :HtmlTagViewHolder<HtmlTag.ImageSource
Glide
.
with
(
itemView
)
Glide
.
with
(
itemView
)
.
load
(
url
)
.
load
(
url
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
itemView
as
ImageView
)
.
into
(
itemView
as
ImageView
)
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenController.kt
View file @
76e62401
...
@@ -23,6 +23,7 @@ import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusPr
...
@@ -23,6 +23,7 @@ import com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusPr
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.scrollChangeEvents
import
com.jakewharton.rxbinding3.view.scrollChangeEvents
...
@@ -212,6 +213,7 @@ class DealScreenController :
...
@@ -212,6 +213,7 @@ class DealScreenController :
viewState
.
estate
.
estate
.
multitourPreview
?.
let
{
viewState
.
estate
.
estate
.
multitourPreview
?.
let
{
Glide
.
with
(
tourScreen
)
Glide
.
with
(
tourScreen
)
.
load
(
it
)
.
load
(
it
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
tourScreen
)
.
into
(
tourScreen
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/util/Adapter.kt
View file @
76e62401
...
@@ -19,6 +19,7 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
...
@@ -19,6 +19,7 @@ import com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressAnimationState
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import
com.biganto.visual.roompark.util.view_utils.status_progress_view.StatusProgressCeil
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
io.reactivex.Observable
import
io.reactivex.Observable
...
@@ -98,12 +99,10 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
...
@@ -98,12 +99,10 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
statusLayout
.
addView
(
currentStatusText
,
0
)
statusLayout
.
addView
(
currentStatusText
,
0
)
statusLayout
.
invalidate
()
statusLayout
.
invalidate
()
model
.
tourPreview
?.
let
{
model
.
tourPreview
?.
let
{
Glide
.
with
(
tourScreen
)
Glide
.
with
(
tourScreen
)
.
load
(
it
)
.
load
(
it
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
tourScreen
)
.
into
(
tourScreen
)
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/feed_list/util/Adapter.kt
View file @
76e62401
...
@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
...
@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
com.bumptech.glide.load.engine.DiskCacheStrategy
import
timber.log.Timber
import
timber.log.Timber
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -46,6 +47,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
...
@@ -46,6 +47,7 @@ class ArticleViewHolder(itemView: View) : CommonViewHolder<ArticlePreviewModel>(
Glide
.
with
(
preview
)
Glide
.
with
(
preview
)
.
load
(
model
.
previewUrl
)
.
load
(
model
.
previewUrl
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
ALL
)
.
into
(
preview
)
.
into
(
preview
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenContract.kt
View file @
76e62401
...
@@ -9,5 +9,7 @@ import io.reactivex.Observable
...
@@ -9,5 +9,7 @@ import io.reactivex.Observable
interface
SettingsScreen
:
BigantoBaseContract
<
SettingsScreenViewState
>
{
interface
SettingsScreen
:
BigantoBaseContract
<
SettingsScreenViewState
>
{
fun
signOut
():
Observable
<
Int
>
fun
signOut
():
Observable
<
Int
>
fun
clearCache
():
Observable
<
Int
>
fun
refreshCacheInfo
():
Observable
<
Int
>
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
76e62401
...
@@ -16,13 +16,16 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListA
...
@@ -16,13 +16,16 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListA
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import
com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import
com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import
com.biganto.visual.roompark.util.extensions.bytesToSize
import
com.biganto.visual.roompark.util.extensions.bytesToSize
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
com.google.android.material.textview.MaterialTextView
import
com.google.android.material.textview.MaterialTextView
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxbinding3.view.clicks
import
com.jakewharton.rxrelay2.BehaviorRelay
import
io.reactivex.Observable
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
...
@@ -40,6 +43,15 @@ class SettingsScreenController :
...
@@ -40,6 +43,15 @@ class SettingsScreenController :
.
map
{
Timber
.
d
(
"Clicked sign out button"
);
1
}
.
map
{
Timber
.
d
(
"Clicked sign out button"
);
1
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
clearCache
():
Observable
<
Int
>
=
clearCacheButton
.
clicks
()
.
debounce
(
500
,
TimeUnit
.
MICROSECONDS
)
.
map
{
Timber
.
d
(
"Clicked clear cache button"
);
1
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
val
refreshEmitter
=
BehaviorRelay
.
create
<
Int
>()
override
fun
refreshCacheInfo
():
Observable
<
Int
>
=
refreshEmitter
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
getComponent
()
getComponent
()
}
}
...
@@ -72,6 +84,12 @@ class SettingsScreenController :
...
@@ -72,6 +84,12 @@ class SettingsScreenController :
@BindView
(
R
.
id
.
signOutButton
)
@BindView
(
R
.
id
.
signOutButton
)
lateinit
var
signOutButton
:
MaterialTextView
lateinit
var
signOutButton
:
MaterialTextView
@BindView
(
R
.
id
.
clear_cache_button
)
lateinit
var
clearCacheButton
:
MaterialTextView
@BindView
(
R
.
id
.
progress_lock_background
)
lateinit
var
progressShame
:
View
private
fun
setToolbar
(){
private
fun
setToolbar
(){
toolBar
.
appBar
.
liftOnScrollTargetViewId
=
R
.
id
.
nestedScrollContainer
toolBar
.
appBar
.
liftOnScrollTargetViewId
=
R
.
id
.
nestedScrollContainer
pushRecycler
.
isNestedScrollingEnabled
=
false
pushRecycler
.
isNestedScrollingEnabled
=
false
...
@@ -112,6 +130,7 @@ class SettingsScreenController :
...
@@ -112,6 +130,7 @@ class SettingsScreenController :
is
SettingsScreenViewState
.
LoadSettingsList
->
render
(
viewState
)
is
SettingsScreenViewState
.
LoadSettingsList
->
render
(
viewState
)
is
SettingsScreenViewState
.
SomeError
->
render
(
viewState
)
is
SettingsScreenViewState
.
SomeError
->
render
(
viewState
)
is
SettingsScreenViewState
.
SignOut
->
render
(
viewState
)
is
SettingsScreenViewState
.
SignOut
->
render
(
viewState
)
is
SettingsScreenViewState
.
OnCacheDeleting
->
render
(
viewState
)
}
}
}
}
...
@@ -119,7 +138,16 @@ class SettingsScreenController :
...
@@ -119,7 +138,16 @@ class SettingsScreenController :
showError
(
viewState
.
exception
)
showError
(
viewState
.
exception
)
private
fun
render
(
viewState
:
SettingsScreenViewState
.
Idle
){
private
fun
render
(
viewState
:
SettingsScreenViewState
.
Idle
){
progressShame
.
setGone
(
true
)
clearCacheButton
.
setGone
(
false
)
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
OnCacheDeleting
){
val
isProgressed
=
viewState
.
progress
>=
1f
progressShame
.
setGone
(
isProgressed
)
clearCacheButton
.
setGone
(!
isProgressed
)
refreshEmitter
.
accept
(
1
)
}
}
private
fun
render
(
viewState
:
SettingsScreenViewState
.
SignOut
){
private
fun
render
(
viewState
:
SettingsScreenViewState
.
SignOut
){
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
76e62401
...
@@ -43,9 +43,28 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -43,9 +43,28 @@ class SettingsScreenPresenter @Inject constructor(
}
}
val
refreshInfo
=
intent
(
SettingsScreen
::
refreshCacheInfo
)
.
flatMap
{
fetchSettings
}
val
onClearCache
=
intent
(
SettingsScreen
::
clearCache
)
.
flatMap
{
interactor
.
deleteCacheFiles
()
.
map
<
SettingsScreenViewState
>{
SettingsScreenViewState
.
OnCacheDeleting
(
it
.
first
/
it
.
second
.
toFloat
()
)
}
.
startWith
(
SettingsScreenViewState
.
OnCacheDeleting
(
0f
))
.
onErrorReturn
(
::
parseError
)
}
val
state
=
restoreStateObservable
val
state
=
restoreStateObservable
.
mergeWith
(
fetchSettings
)
.
mergeWith
(
fetchSettings
)
.
mergeWith
(
onSignOut
)
.
mergeWith
(
onSignOut
)
.
mergeWith
(
onClearCache
)
.
mergeWith
(
refreshInfo
)
.
doOnError
{
Timber
.
e
(
it
)}
.
doOnError
{
Timber
.
e
(
it
)}
.
subscribeOn
(
Schedulers
.
io
())
.
subscribeOn
(
Schedulers
.
io
())
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenViewState.kt
View file @
76e62401
...
@@ -15,4 +15,5 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
...
@@ -15,4 +15,5 @@ sealed class SettingsScreenViewState : BigantoBaseViewState() {
// class LoadCachedInfo(val cached:SettingsModel) : SettingsScreenViewState()
// class LoadCachedInfo(val cached:SettingsModel) : SettingsScreenViewState()
class
SomeError
(
val
exception
:
ExceptionString
)
:
SettingsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
SettingsScreenViewState
()
class
SignOut
()
:
SettingsScreenViewState
()
class
SignOut
()
:
SettingsScreenViewState
()
class
OnCacheDeleting
(
val
progress
:
Float
)
:
SettingsScreenViewState
()
}
}
\ No newline at end of file
app/src/main/res/layout/settings_screen.xml
View file @
76e62401
...
@@ -123,10 +123,33 @@
...
@@ -123,10 +123,33 @@
tools:listitem=
"@layout/text_description_viewholder"
/>
tools:listitem=
"@layout/text_description_viewholder"
/>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
style=
"@style/Default_TextView.Cancel_Text"
android:id=
"@+id/clear_cache_button"
style=
"@style/Default_TextView.Clear_Cache_Text"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_margin=
"16dp"
android:textAlignment=
"center"
/>
<FrameLayout
android:id=
"@+id/progress_lock_background"
android:background=
"@color/colorOpacityBackgroundInv"
android:layout_width=
"match_parent"
android:layout_height=
"48dp"
android:layout_margin=
"16dp"
android:backgroundTint=
"@color/colorPrimary"
android:visibility=
"gone"
>
<ProgressBar
android:id=
"@+id/settings_progress_bar"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"32dp"
/>
android:indeterminate=
"true"
android:layout_gravity=
"center"
/>
</FrameLayout>
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
...
@@ -142,10 +165,10 @@
...
@@ -142,10 +165,10 @@
<com.google.android.material.textview.MaterialTextView
<com.google.android.material.textview.MaterialTextView
android:id=
"@+id/signOutButton"
android:id=
"@+id/signOutButton"
style=
"@style/Default_TextView.
Cancel
_Text"
style=
"@style/Default_TextView.
Sign_Out
_Text"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"32dp"
android:layout_margin=
"32dp"
/>
android:text=
"СМЕНИТЬ АККАУНТ"
/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
76e62401
...
@@ -317,6 +317,19 @@
...
@@ -317,6 +317,19 @@
<item
name=
"android:textColor"
>
@color/colorError
</item>
<item
name=
"android:textColor"
>
@color/colorError
</item>
</style>
</style>
<style
name=
"Default_TextView.Clear_Cache_Text"
>
<item
name=
"android:text"
>
"ОЧИСТИТЬ КЭШ"
</item>
<item
name=
"android:gravity"
>
center
</item>
<item
name=
"android:textColor"
>
@color/colorError
</item>
</style>
<style
name=
"Default_TextView.Sign_Out_Text"
>
<item
name=
"android:text"
>
"СМЕНИТЬ АККАУНТ"
</item>
<item
name=
"android:gravity"
>
center
</item>
<item
name=
"android:textColor"
>
@color/colorError
</item>
</style>
<style
name=
"Default_TextView.Notice_Text"
>
<style
name=
"Default_TextView.Notice_Text"
>
<item
name=
"android:textColor"
>
@color/colorNoticeText
</item>
<item
name=
"android:textColor"
>
@color/colorNoticeText
</item>
</style>
</style>
...
...
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