Commit 1ebfa604 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

default preset subs

parent caf9ff18
...@@ -82,7 +82,12 @@ class StartPlansDownloadingDialogController : Controller { ...@@ -82,7 +82,12 @@ class StartPlansDownloadingDialogController : Controller {
snackbar = ActivityModule.provideSnackBar(rpActivity) snackbar = ActivityModule.provideSnackBar(rpActivity)
view.findViewById<MaterialTextView>(R.id.download_dialog_title)
.text = resources?.getString(R.string.download_all_plans_notice_text)
view.findViewById<MaterialTextView>(R.id.all_tours_size_textView)
.text = resources?.getString(R.string.download_all_plans_size_title
,"0")
file.freeSpace.bytesToSize().let { file.freeSpace.bytesToSize().let {
view.findViewById<MaterialTextView>(R.id.disk_size_textView) view.findViewById<MaterialTextView>(R.id.disk_size_textView)
......
...@@ -76,6 +76,14 @@ class StartToursDownloadingDialogController : Controller { ...@@ -76,6 +76,14 @@ class StartToursDownloadingDialogController : Controller {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
val view = inflater.inflate(getLayoutId(), container, false) val view = inflater.inflate(getLayoutId(), container, false)
view.findViewById<MaterialTextView>(R.id.download_dialog_title)
.text = resources?.getString(R.string.download_all_tours_notice_text)
view.findViewById<MaterialTextView>(R.id.all_tours_size_textView)
.text = resources?.getString(R.string.download_all_tours_size_title
,"0")
snackbar = ActivityModule.provideSnackBar(rpActivity) snackbar = ActivityModule.provideSnackBar(rpActivity)
file.freeSpace.bytesToSize().let { file.freeSpace.bytesToSize().let {
......
...@@ -4,11 +4,13 @@ import com.biganto.visual.androidplayer.data.repository.local.ILocalStore ...@@ -4,11 +4,13 @@ import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import com.biganto.visual.roompark.data.local.UserState import com.biganto.visual.roompark.data.local.UserState
import com.biganto.visual.roompark.data.repository.api.room_park.IRoomParkApi import com.biganto.visual.roompark.data.repository.api.room_park.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.db.requrey.model.SubscriptionEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity import com.biganto.visual.roompark.data.repository.db.requrey.model.UserEntity
import com.biganto.visual.roompark.data.repository.mapper.fromRaw import com.biganto.visual.roompark.data.repository.mapper.fromRaw
import com.biganto.visual.roompark.domain.contract.AuthContract import com.biganto.visual.roompark.domain.contract.AuthContract
import com.biganto.visual.roompark.domain.custom_exception.CustomApiException import com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import com.biganto.visual.roompark.domain.model.AuthInfoModel import com.biganto.visual.roompark.domain.model.AuthInfoModel
import com.biganto.visual.roompark.domain.model.SubscriptionTopic
import com.biganto.visual.roompark.domain.model.fromEntity import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
...@@ -37,6 +39,18 @@ class AuthContractModule @Inject constructor( ...@@ -37,6 +39,18 @@ class AuthContractModule @Inject constructor(
api.authenticate(email,password) api.authenticate(email,password)
.map ( ::fromRaw ) .map ( ::fromRaw )
.flatMap{ db.upsertUser(it) } .flatMap{ db.upsertUser(it) }
.flatMap {user ->
val userSubs = user.subscriptions?.map { it as SubscriptionEntity }
if (!userSubs.isNullOrEmpty()){
val newSubs = defaultSubsList(user).filter {defSub ->
!userSubs.map { it.topic }.contains(defSub.topic)
}.toList()
return@flatMap db.upsert(newSubs)
.toObservable()
.flatMap { db.refreshUser(user) }
}
else return@flatMap Observable.just(user)
}
.doOnNext{ Timber.d("user id: ${it.uuid}")} .doOnNext{ Timber.d("user id: ${it.uuid}")}
.doOnNext { local.setRecentUser(it.uuid.toString()).blockingAwait() } .doOnNext { local.setRecentUser(it.uuid.toString()).blockingAwait() }
.map(::fromEntity) .map(::fromEntity)
...@@ -60,3 +74,41 @@ class AuthContractModule @Inject constructor( ...@@ -60,3 +74,41 @@ class AuthContractModule @Inject constructor(
} } } }
} }
private fun defaultSubsList(owner:UserEntity) = arrayListOf(
SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Progress_1().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Progress_2().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Progress_3().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Progress_kindergarden().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.News().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Blog().topicName)
setOwner(owner)
setState(false)
}
,SubscriptionEntity().apply {
setTopic(SubscriptionTopic.Construction().topicName)
setOwner(owner)
setState(false)
}
)
\ No newline at end of file
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
android:orientation="vertical"> android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/download_dialog_title"
style="@style/Default_TextView.Header_Text" style="@style/Default_TextView.Header_Text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -133,6 +133,7 @@ ...@@ -133,6 +133,7 @@
<string name="plan_types_download_completed">Загрузка планов завершена.</string> <string name="plan_types_download_completed">Загрузка планов завершена.</string>
<string name="download_plan_types_screen_title">Cкачиваются планировки</string> <string name="download_plan_types_screen_title">Cкачиваются планировки</string>
<string name="download_all_tours_notice_text">Загрузить все туры?</string> <string name="download_all_tours_notice_text">Загрузить все туры?</string>
<string name="download_all_plans_notice_text">Загрузить все \n планировки?</string>
<string name="download_all_tours_size_title">Размер всех туров: %s</string> <string name="download_all_tours_size_title">Размер всех туров: %s</string>
<string name="download_all_plans_size_title">Размер всех планировок: %s</string> <string name="download_all_plans_size_title">Размер всех планировок: %s</string>
<string name="download_all_tours_disk_size_title">Размер свободного места на диске: %s</string> <string name="download_all_tours_disk_size_title">Размер свободного места на диске: %s</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment