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
413f7f1b
Commit
413f7f1b
authored
Jan 17, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor and fix abstract generic primary constructor call
parent
64cd117d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
37 deletions
+42
-37
FilesRepository.kt
...nto/visual/roompark/data/data_provider/FilesRepository.kt
+3
-16
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+34
-18
settings.kt
...java/com/biganto/visual/roompark/domain/model/settings.kt
+1
-1
ScreenPresenter.kt
.../roompark/presentation/screen/settings/ScreenPresenter.kt
+4
-2
No files found.
app/src/main/java/com/biganto/visual/roompark/data/data_provider/FilesRepository.kt
View file @
413f7f1b
...
@@ -6,7 +6,6 @@ import com.biganto.visual.roompark.data.repository.db.IDb
...
@@ -6,7 +6,6 @@ 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
com.biganto.visual.roompark.util.extensions.folderSize
import
timber.log.Timber
import
java.io.File
import
java.io.File
import
javax.inject.Inject
import
javax.inject.Inject
import
kotlin.reflect.full.primaryConstructor
import
kotlin.reflect.full.primaryConstructor
...
@@ -23,23 +22,11 @@ class FilesContractModule @Inject constructor(
...
@@ -23,23 +22,11 @@ class FilesContractModule @Inject constructor(
private
val
context
:
Application
private
val
context
:
Application
):
FilesContract
{
):
FilesContract
{
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getDirectory
():
T
?
=
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getDirectory
():
T
?
{
T
::
class
.
primaryConstructor
?.
call
()
val
type
=
T
::
class
Timber
.
d
(
"Type is :$type"
)
val
inst
=
type
.
primaryConstructor
?.
call
(
null
,
null
)
Timber
.
d
(
"inst is :$inst"
)
//val inst2 = type.constructors.first().call()
//Timber.d("inst2 is :$inst2")
return
inst
}
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getFile
():
File
{
private
inline
fun
<
reified
T
:
FileModule
.
FileDirectory
>
getFile
():
File
{
Timber
.
d
(
"type: ${T::class}"
)
val
d
=
getDirectory
<
T
>()
?:
error
(
"Unresolved class type"
)
val
d
=
getDirectory
<
T
>()
Timber
.
d
(
"d: ${d}"
)
if
(
d
==
null
)
error
(
"Unresolved class type"
)
return
FileModule
.
getDirectory
(
context
,
d
)
return
FileModule
.
getDirectory
(
context
,
d
)
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
413f7f1b
...
@@ -77,21 +77,25 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -77,21 +77,25 @@ class FileModule @Inject constructor(val context: Application) {
}
}
sealed
class
FileDirectory
(
val
dir
:
String
)
{
sealed
class
FileDirectory
(
protected
var
path
:
String
)
{
class
PlanTypeDir
:
FileDirectory
{
val
dir
:
String
get
()
=
path
constructor
(
dir
:
String
=
"/estates"
,
childName
:
String
?
=
null
)
class
PlanTypeDir
():
FileDirectory
(
dirName
){
:
super
(
dir
.
plus
(
childName
.
slashed
()))
private
companion
object
{
const
val
dirName
=
"/estates"
}
constructor
(
catalog
:
String
=
"/estates"
constructor
(
childName
:
String
?
=
null
)
:
this
(){
path
=
dirName
.
plus
(
childName
.
slashed
())}
constructor
(
catalog
:
String
=
dirName
,
estateId
:
Int
,
estateId
:
Int
,
planId
:
Int
,
planId
:
Int
,
furniture
:
Boolean
?
=
null
,
furniture
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
sizes
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
walls
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
,
electric
:
Boolean
?
=
null
)
:
super
(
catalog
.
plus
(
"/plan"
).
plus
(
"/$estateId"
).
plus
(
"/$planId"
)
)
:
this
(){
path
=
(
catalog
.
plus
(
"/plan"
).
plus
(
"/$estateId"
).
plus
(
"/$planId"
)
.
plus
(
"/plan${planId}"
+
.
plus
(
"/plan${planId}"
+
"${sizes?.asInt?.toString()?.map { "
_s
$
it
" }?:""}"
+
"${sizes?.asInt?.toString()?.map { "
_s
$
it
" }?:""}"
+
"${furniture?.asInt?.toString()?.map { "
_f
$
it
" }?:""}"
+
"${furniture?.asInt?.toString()?.map { "
_f
$
it
" }?:""}"
+
...
@@ -99,13 +103,25 @@ class FileModule @Inject constructor(val context: Application) {
...
@@ -99,13 +103,25 @@ class FileModule @Inject constructor(val context: Application) {
"${electric?.asInt?.toString()?.map { "
_e
$
it
" }?:""}"
)
"${electric?.asInt?.toString()?.map { "
_e
$
it
" }?:""}"
)
.
plus
(
".html"
))
.
plus
(
".html"
))
}
}
}
class
ToursDir
()
:
FileDirectory
(
dirName
){
private
companion
object
{
const
val
dirName
=
"/tours"
}
constructor
(
childName
:
String
?
=
null
)
:
this
(){
path
=
dirName
.
plus
(
childName
.
slashed
())}
}
class
ToursDir
(
dir
:
String
=
"/tours"
,
childName
:
String
?
=
null
)
class
FeedsDir
():
FileDirectory
(
dirName
)
{
:
FileDirectory
(
dir
.
plus
(
childName
.
slashed
()))
private
companion
object
{
const
val
dirName
=
"/feeds"
}
class
FeedsDir
(
dir
:
String
=
"/feeds"
,
childName
:
String
?
=
null
)
constructor
(
childName
:
String
?
=
null
)
:
FileDirectory
(
dir
.
plus
(
childName
.
slashed
()))
:
this
(){
path
=
dirName
.
plus
(
childName
.
slashed
())}
class
Albums
(
dir
:
String
=
"/photos"
,
childName
:
String
?
=
null
)
}
:
FileDirectory
(
dir
.
plus
(
childName
.
slashed
()))
class
Albums
():
FileDirectory
(
dirName
)
{
private
companion
object
{
const
val
dirName
=
"/photos"
}
constructor
(
childName
:
String
?
=
null
)
:
this
(){
path
=
dirName
.
plus
(
childName
.
slashed
())}
}
}
}
}
}
...
...
app/src/main/java/com/biganto/visual/roompark/domain/model/settings.kt
View file @
413f7f1b
...
@@ -21,5 +21,5 @@ data class CachedDataModel(
...
@@ -21,5 +21,5 @@ data class CachedDataModel(
data class
SettingsModel
(
data class
SettingsModel
(
val
pushItems
:
List
<
PushSwitchModel
>,
val
pushItems
:
List
<
PushSwitchModel
>,
var
offlineStoreData
:
List
<
CachedDataModel
>,
var
offlineStoreData
:
List
<
CachedDataModel
>,
va
l
cachedData
:
List
<
CachedDataModel
>
va
r
cachedData
:
List
<
CachedDataModel
>
)
)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/settings/ScreenPresenter.kt
View file @
413f7f1b
...
@@ -29,9 +29,11 @@ class SettingsScreenPresenter @Inject constructor(
...
@@ -29,9 +29,11 @@ class SettingsScreenPresenter @Inject constructor(
val
fetchSettings
=
interactor
.
fetchSettings
()
val
fetchSettings
=
interactor
.
fetchSettings
()
.
flatMap
{
settings
->
.
flatMap
{
settings
->
interactor
.
getCacheInfo
()
interactor
.
getCacheInfo
()
.
doOnNext
{
settings
.
offlineStoreData
=
it
}
.
doOnNext
{
Timber
.
d
(
"$it"
)
}
.
doOnNext
{
settings
.
cachedData
=
it
}
.
map
{
settings
}}
.
map
{
settings
}}
.
map
{
SettingsScreenViewState
.
LoadSettingsList
(
it
)
}
.
map
{
SettingsScreenViewState
.
LoadSettingsList
(
it
)}
val
onSignOut
=
intent
(
SettingsScreen
::
signOut
)
val
onSignOut
=
intent
(
SettingsScreen
::
signOut
)
.
flatMap
{
.
flatMap
{
...
...
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