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
16ec499c
Commit
16ec499c
authored
Jan 16, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
calculate files size
parent
48c17059
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
3 deletions
+33
-3
FilesRepository.kt
...nto/visual/roompark/data/data_provider/FilesRepository.kt
+17
-2
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+3
-0
FilesContract.kt
.../biganto/visual/roompark/domain/contract/FilesContract.kt
+5
-0
ext.kt
...n/java/com/biganto/visual/roompark/util/extensions/ext.kt
+8
-1
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FilesRepository.kt
View file @
16ec499c
...
@@ -5,6 +5,8 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
...
@@ -5,6 +5,8 @@ import com.biganto.visual.roompark.data.repository.api.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.file.FileModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.domain.contract.FilesContract
import
com.biganto.visual.roompark.domain.contract.FilesContract
import
com.biganto.visual.roompark.util.extensions.folderSize
import
java.io.File
import
javax.inject.Inject
import
javax.inject.Inject
import
kotlin.reflect.full.primaryConstructor
import
kotlin.reflect.full.primaryConstructor
...
@@ -21,10 +23,23 @@ class FilesContractModule @Inject constructor(
...
@@ -21,10 +23,23 @@ class FilesContractModule @Inject constructor(
):
FilesContract
{
):
FilesContract
{
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getDirectory
():
T
?
=
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getDirectory
():
T
?
=
T
::
class
.
primaryConstructor
?.
call
()
T
::
class
.
primaryConstructor
?.
call
()
fun
getPlansSize
()
=
getDirectorySize
<>()
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getFile
():
File
{
val
d
=
getDirectory
<
T
>()
?:
error
(
"Unresolved class type"
)
return
FileModule
.
getDirectory
(
context
,
d
)
}
override
fun
getPlansSize
()
=
getFile
<
FileModule
.
FileDirectory
.
PlanTypeDir
>().
folderSize
override
fun
getToursSize
()
=
getFile
<
FileModule
.
FileDirectory
.
ToursDir
>().
folderSize
override
fun
getFeedSize
()
=
getFile
<
FileModule
.
FileDirectory
.
FeedsDir
>().
folderSize
override
fun
getAlbumSize
()
=
getFile
<
FileModule
.
FileDirectory
.
Albums
>().
folderSize
override
fun
allCacheSize
()
=
FileModule
.
assetsFile
(
context
).
folderSize
}
}
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
16ec499c
...
@@ -71,6 +71,9 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -71,6 +71,9 @@ class FileModule @Inject constructor(val context: Application) {
File
(
context
.
filesDir
.
absolutePath
.
plus
(
dirType
.
dir
))
File
(
context
.
filesDir
.
absolutePath
.
plus
(
dirType
.
dir
))
fun
assetsDirectory
(
context
:
Context
):
String
=
context
.
filesDir
.
absolutePath
fun
assetsDirectory
(
context
:
Context
):
String
=
context
.
filesDir
.
absolutePath
fun
assetsFile
(
context
:
Context
):
File
=
context
.
filesDir
.
absoluteFile
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/contract/FilesContract.kt
View file @
16ec499c
...
@@ -6,4 +6,9 @@ package com.biganto.visual.roompark.domain.contract
...
@@ -6,4 +6,9 @@ package com.biganto.visual.roompark.domain.contract
interface
FilesContract
{
interface
FilesContract
{
fun
allCacheSize
():
Long
fun
getAlbumSize
():
Long
fun
getFeedSize
():
Long
fun
getToursSize
():
Long
fun
getPlansSize
():
Long
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/util/extensions/ext.kt
View file @
16ec499c
...
@@ -5,6 +5,7 @@ import android.graphics.Canvas
...
@@ -5,6 +5,7 @@ import android.graphics.Canvas
import
android.graphics.RectF
import
android.graphics.RectF
import
android.view.View
import
android.view.View
import
timber.log.Timber
import
timber.log.Timber
import
java.io.File
import
java.text.DecimalFormat
import
java.text.DecimalFormat
import
java.text.SimpleDateFormat
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.*
...
@@ -98,3 +99,9 @@ fun Bitmap.scaleCenterCrop(viewHolder:View): Bitmap {
...
@@ -98,3 +99,9 @@ fun Bitmap.scaleCenterCrop(viewHolder:View): Bitmap {
return
dest
return
dest
}
}
val
File
.
folderSize
get
()
=
this
.
walkTopDown
()
.
asSequence
()
.
map
{
it
.
length
()}
.
sum
()
\ No newline at end of file
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