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
bcdc9ac3
Commit
bcdc9ac3
authored
Jan 09, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
show and cache plans via api
parent
394e26c4
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
14 deletions
+88
-14
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-0
EstateRepository.kt
...to/visual/roompark/data/data_provider/EstateRepository.kt
+17
-1
RetrofitRepository.kt
...ompark/data/repository/api/retrofit/RetrofitRepository.kt
+15
-0
FileModule.kt
...iganto/visual/roompark/data/repository/file/FileModule.kt
+14
-7
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+5
-1
ScreenController.kt
...l/roompark/presentation/screen/estate/ScreenController.kt
+36
-5
No files found.
app/src/main/AndroidManifest.xml
View file @
bcdc9ac3
...
...
@@ -3,6 +3,7 @@
package=
"com.biganto.visual.roompark"
>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<application
android:name=
".base.RoomParkApplication"
android:allowBackup=
"true"
...
...
app/src/main/java/com/biganto/visual/roompark/data/data_provider/EstateRepository.kt
View file @
bcdc9ac3
...
...
@@ -5,6 +5,7 @@ import com.biganto.visual.roompark.data.local.UserState
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.requrey.model.EstateEntity
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.data.repository.mapper.fromRaw
import
com.biganto.visual.roompark.data.repository.mapper.fromRawList
import
com.biganto.visual.roompark.domain.contract.DealContract
...
...
@@ -26,7 +27,8 @@ import javax.inject.Inject
class
EstateRepository
@Inject
constructor
(
private
val
local
:
ILocalStore
,
private
val
api
:
IRoomParkApi
,
private
val
db
:
IDb
private
val
db
:
IDb
,
private
val
file
:
FileModule
):
DealContract
{
...
...
@@ -115,6 +117,12 @@ class EstateRepository @Inject constructor(
,
walls
:
Boolean
=
false
,
electric
:
Boolean
=
false
)
=
api
.
getDirectPlan
(
estateId
,
planId
,
furniture
,
sizes
,
walls
,
electric
)
.
map
{
val
sFile
=
FileModule
.
getDirectory
(
file
.
context
,
FileModule
.
FileDirectory
.
PlanTypeDir
(
childName
=
"planType-$estateId-$planId.html"
))
file
.
saveFileToDisk
(
sFile
,
it
)
sFile
.
path
}
.
subscribeOn
(
Schedulers
.
io
())
...
...
@@ -124,4 +132,12 @@ class EstateRepository @Inject constructor(
arrayListOf
(
getPlanApi
(
estateId
,
planId
))
)
// fun getPlanRequestString(estateId: Int
// , planId:Int
// , furniture:Boolean
// , sizes:Boolean
// , walls:Boolean
// , electric:Boolean
// ) = api.getDirectPlan(estateId,planId,furniture,sizes,electric).
}
app/src/main/java/com/biganto/visual/roompark/data/repository/api/retrofit/RetrofitRepository.kt
View file @
bcdc9ac3
...
...
@@ -112,6 +112,21 @@ class RetrofitRepository @Inject constructor(retrofit: Retrofit) : IRoomParkApi
)
.
compose
(
RetrofitResponseValidation
())
// fun getPlanString(
// estateId: Int,
// planType: Int,
// showFurniture: Boolean,
// showSizes: Boolean,
// showWalls: Boolean,
// showElectric: Boolean) = api.getPlan(
// estate_id = estateId,
// planType = planType,
// furniture = showFurniture.asInt,
// sizes = showSizes.asInt,
// walls = showWalls.asInt,
// electric = showElectric.asInt
// ).req
@Deprecated
(
"hidden by states.getEstate method"
)
override
fun
getMultiTour
(
building
:
Int
,
flat
:
Int
):
Observable
<
Int
>
=
...
...
app/src/main/java/com/biganto/visual/roompark/data/repository/file/FileModule.kt
View file @
bcdc9ac3
package
com.biganto.visual.roompark.data.repository.file
import
android.app.Application
import
android.content.Context
import
android.os.Environment
import
com.google.gson.JsonElement
import
dagger.Module
import
timber.log.Timber
import
java.io.File
import
javax.inject.Inject
/**
...
...
@@ -14,7 +16,7 @@ import java.io.File
@Module
class
File
sModule
(
private
val
context
:
Context
)
{
class
File
Module
@Inject
constructor
(
val
context
:
Application
)
{
private
val
rootFolder
:
File
get
()
{
...
...
@@ -49,7 +51,10 @@ class FilesModule(private val context: Context) {
}
fun
saveFileToDisk
(
file
:
File
,
content
:
String
){
Timber
.
d
(
"write to : $file"
)
Timber
.
d
(
"write to : ${file.name}"
)
// file.createNewFile()
file
.
parentFile
.
mkdirs
()
file
.
writeText
(
content
)
//to json array because core unity method parse data like TourData[] Estate[] etc..
}
...
...
@@ -61,18 +66,20 @@ class FilesModule(private val context: Context) {
}
companion
object
{
fun
getDirectory
(
context
:
Context
?,
dirType
:
FileDirectory
):
String
=
fun
getDirectory
(
context
:
Context
?,
dirType
:
FileDirectory
):
File
=
File
(
context
?.
filesDir
?.
absolutePath
?.
plus
(
dirType
.
dir
)
?:
throw
IllegalArgumentException
(
"Context cannot be null!"
)
)
fun
assetsDirectory
(
context
:
Context
?):
String
=
context
?.
filesDir
?.
absolutePath
?:
throw
IllegalArgumentException
(
"Context cannot be null!"
)
}
sealed
class
FileDirectory
(
val
dir
:
String
)
{
class
PlanTypeDir
(
dir
:
String
=
"
estates"
)
:
FileDirectory
(
dir
)
class
ToursDir
(
dir
:
String
=
"
tours"
)
:
FileDirectory
(
dir
)
class
FeedsDir
(
dir
:
String
=
"
feeds"
)
:
FileDirectory
(
dir
)
class
Albums
(
dir
:
String
=
"
photos"
)
:
FileDirectory
(
dir
)
class
PlanTypeDir
(
dir
:
String
=
"
/estates"
,
childName
:
String
?
=
null
)
:
FileDirectory
(
dir
.
plus
(
"/$childName"
)
)
class
ToursDir
(
dir
:
String
=
"
/tours"
,
childName
:
String
?
=
null
)
:
FileDirectory
(
dir
.
plus
(
"/childName"
)
)
class
FeedsDir
(
dir
:
String
=
"
/feeds"
,
childName
:
String
?
=
null
)
:
FileDirectory
(
dir
.
plus
(
"/childName"
)
)
class
Albums
(
dir
:
String
=
"
/photos"
,
childName
:
String
?
=
null
)
:
FileDirectory
(
dir
.
plus
(
"/childName"
)
)
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
View file @
bcdc9ac3
...
...
@@ -8,6 +8,7 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import
com.biganto.visual.roompark.data.repository.api.retrofit.di.RetrofitModule
import
com.biganto.visual.roompark.data.repository.db.IDb
import
com.biganto.visual.roompark.data.repository.db.requrey.DbModule
import
com.biganto.visual.roompark.data.repository.file.FileModule
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.contract.DealContract
import
com.biganto.visual.roompark.domain.contract.DevProgressContract
...
...
@@ -43,7 +44,8 @@ import javax.inject.Singleton
PicassoModule
::
class
,
ActivityModule
::
class
,
ContractRepositoryModule
::
class
,
AppActivityModule
::
class
])
AppActivityModule
::
class
,
FileModule
::
class
])
interface
AppComponent
:
AndroidInjector
<
RoomParkApplication
>{
fun
authC
():
AuthContract
...
...
@@ -65,6 +67,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun
providePicassoAsync
():
Picasso
fun
provideFileSystem
():
FileModule
@Component
.
Factory
interface
Factory
{
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenController.kt
View file @
bcdc9ac3
package
com.biganto.visual.roompark.presentation.screen.estate
import
android.net.Uri
import
android.os.Bundle
import
android.view.View
import
android.webkit.WebView
...
...
@@ -15,9 +16,12 @@ import com.jakewharton.rxbinding3.material.selections
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
java.io.BufferedReader
import
java.io.InputStreamReader
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
...
...
@@ -120,13 +124,40 @@ class EstateScreenController :
}
private
fun
render
(
viewState
:
EstateScreenViewState
.
LoadPlan
)
{
val
mimeTypeSvg
=
"image/svg+xml"
// val mimeTypeSvg = "image/svg+xml"
val
mimeTypeSvg
=
"text/html"
val
encoding
=
"utf-8"
viewState
.
planBody
.
replace
(
"<br>"
,
"<br />"
)
viewState
.
planBody
.
replace
(
"<\\br>"
,
"<br />"
)
//
viewState.planBody.replace("<br>","<br />")
//
viewState.planBody.replace("<\\br>","<br />")
// Timber.w("counts br : ${})
planWebView
.
settings
.
javaScriptEnabled
=
true
planWebView
.
loadData
(
viewState
.
planBody
,
mimeTypeSvg
,
encoding
)
planWebView
.
clearCache
(
true
)
// planWebView.loadUrl("https://room-park.ru/choose/flat/2/1/74/")
val
svgStream
=
resources
?.
openRawResource
(
R
.
raw
.
flat_plan_test
)
val
inputStreamReader
=
InputStreamReader
(
svgStream
!!
)
val
sb
=
StringBuilder
()
var
line
:
String
?
val
br
=
BufferedReader
(
inputStreamReader
)
line
=
br
.
readLine
()
while
(
line
!=
null
)
{
sb
.
append
(
line
)
line
=
br
.
readLine
()
}
br
.
close
()
var
svgBody
:
String
=
sb
.
toString
()
Timber
.
d
(
"ulr : ${viewState.planBody}"
)
val
uri
=
"file:///${Uri.parse(viewState.planBody).path}"
Timber
.
d
(
"uri: ${uri}"
)
svgBody
=
"https://room-park.ru/api/estates.getPlan?&client=androidplayer&client_version=3.0&v=2.0&estate_id=4902&plan_id=0&furniture=0&sizes=0&walls=0&electric=0"
svgBody
=
uri
planWebView
.
loadUrl
(
svgBody
)
// planWebView.loadUrl("https://room-park.ru/api/estates.getPlan?&client=androidplayer&client_version=3.0&v=2.0&estate_id=4009&plan_id=1&furniture=1&sizes=0&walls=0&electric=1")
// planWebView.loadDataWithBaseURL(
// "",viewState.planBody,mimeTypeSvg,encoding,null
// )
// planWebView.load(svgBody,mimeTypeSvg,encoding)
}
private
fun
getComponent
()
=
DaggerEstateScreenComponent
.
factory
()
...
...
@@ -137,4 +168,4 @@ class EstateScreenController :
override
fun
getLayoutId
():
Int
=
R
.
layout
.
flat_full_card_screen
}
\ 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