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
d01c7933
Commit
d01c7933
authored
Mar 20, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide clear cache functionality
parent
9e3f65bf
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
71 additions
and
4 deletions
+71
-4
FilesRepository.kt
...nto/visual/roompark/data/data_provider/FilesRepository.kt
+2
-0
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+18
-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
ScreenContract.kt
...l/roompark/presentation/screen/settings/ScreenContract.kt
+1
-0
ScreenController.kt
...roompark/presentation/screen/settings/ScreenController.kt
+12
-0
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+13
-0
ScreenViewState.kt
.../roompark/presentation/screen/settings/ScreenViewState.kt
+1
-0
settings_screen.xml
app/src/main/res/layout/settings_screen.xml
+4
-4
styles.xml
app/src/main/res/values/styles.xml
+13
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FilesRepository.kt
View file @
d01c7933
...
@@ -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 @
d01c7933
...
@@ -6,6 +6,7 @@ import android.os.Environment
...
@@ -6,6 +6,7 @@ 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
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 +62,24 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -61,7 +62,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
().
dir
,
FileDirectory
.
FeedsDir
().
dir
,
FileDirectory
.
PlanTypeDir
().
dir
,
FileDirectory
.
ToursDir
().
dir
)
foldersToDelete
.
forEachIndexed
{
index
,
dir
->
if
(
File
(
dir
).
deleteRecursively
())
emitter
.
onNext
(
Pair
(
index
,
foldersToDelete
.
size
))
else
emitter
.
onError
(
error
(
"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/domain/contract/FilesContract.kt
View file @
d01c7933
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 @
d01c7933
...
@@ -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 @
d01c7933
...
@@ -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/settings/ScreenContract.kt
View file @
d01c7933
...
@@ -9,5 +9,6 @@ import io.reactivex.Observable
...
@@ -9,5 +9,6 @@ import io.reactivex.Observable
interface
SettingsScreen
:
BigantoBaseContract
<
SettingsScreenViewState
>
{
interface
SettingsScreen
:
BigantoBaseContract
<
SettingsScreenViewState
>
{
fun
signOut
():
Observable
<
Int
>
fun
signOut
():
Observable
<
Int
>
fun
clearCache
():
Observable
<
Int
>
}
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenController.kt
View file @
d01c7933
...
@@ -23,6 +23,7 @@ import com.jakewharton.rxbinding3.view.clicks
...
@@ -23,6 +23,7 @@ import com.jakewharton.rxbinding3.view.clicks
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 +41,13 @@ class SettingsScreenController :
...
@@ -40,6 +41,13 @@ 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
())
override
fun
injectDependencies
()
{
override
fun
injectDependencies
()
{
getComponent
()
getComponent
()
}
}
...
@@ -72,6 +80,10 @@ class SettingsScreenController :
...
@@ -72,6 +80,10 @@ 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
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/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
d01c7933
...
@@ -42,10 +42,23 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -42,10 +42,23 @@ class SettingsScreenPresenter @Inject constructor(
.
onErrorReturn
(
::
parseError
)
.
onErrorReturn
(
::
parseError
)
}
}
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
)
.
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 @
d01c7933
...
@@ -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 @
d01c7933
...
@@ -123,7 +123,8 @@
...
@@ -123,7 +123,8 @@
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=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"32dp"
/>
android:layout_margin=
"32dp"
/>
...
@@ -142,10 +143,9 @@
...
@@ -142,10 +143,9 @@
<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 @
d01c7933
...
@@ -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