Commit 37e68aaf authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

update tours start /download look

parent 0459e678
...@@ -66,7 +66,6 @@ class ChooseResolutionDialogController : Controller { ...@@ -66,7 +66,6 @@ class ChooseResolutionDialogController : Controller {
detachDisposable.add( detachDisposable.add(
(recyclerView.adapter as PhotoSizeAdapter).onItemClicked.subscribe { (recyclerView.adapter as PhotoSizeAdapter).onItemClicked.subscribe {
Timber.d("gonna shit : $it")
router.replaceTopController(RouterTransaction.with( router.replaceTopController(RouterTransaction.with(
PhotoDialogController( PhotoDialogController(
it.url it.url
......
...@@ -7,20 +7,22 @@ import android.view.View ...@@ -7,20 +7,22 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.ActivityModule
import com.biganto.visual.roompark.di.dagger.AppComponent import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.interactor.ToursInteractor import com.biganto.visual.roompark.domain.interactor.ToursInteractor
import com.biganto.visual.roompark.domain.model.TourModel import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.domain.use_case.DownloadUseCase import com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity import com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.textview.MaterialTextView
import dagger.Binds import dagger.Binds
import dagger.BindsInstance import dagger.BindsInstance
import dagger.Component import dagger.Component
...@@ -49,8 +51,8 @@ class DownloadTourDialogController : Controller { ...@@ -49,8 +51,8 @@ class DownloadTourDialogController : Controller {
lateinit var progressBarDownload: ProgressBar lateinit var progressBarDownload: ProgressBar
lateinit var downloaderBg: ImageView lateinit var downloaderBg: ImageView
lateinit var downloadTourTitleText: TextView lateinit var downloadTourTitleText: MaterialTextView
lateinit var cancelDownloadText: TextView lateinit var cancelDownloadText: MaterialTextView
override fun onContextAvailable(context: Context) { override fun onContextAvailable(context: Context) {
super.onContextAvailable(context) super.onContextAvailable(context)
...@@ -69,6 +71,11 @@ class DownloadTourDialogController : Controller { ...@@ -69,6 +71,11 @@ class DownloadTourDialogController : Controller {
@Inject @Inject
lateinit var downloader: ToursInteractor lateinit var downloader: ToursInteractor
@Inject
lateinit var rpActivity: RoomParkMainActivity
lateinit var snackbar: ISnackBarProvider
private val disposables = CompositeDisposable() private val disposables = CompositeDisposable()
override fun onDetach(view: View) { override fun onDetach(view: View) {
...@@ -79,6 +86,8 @@ class DownloadTourDialogController : Controller { ...@@ -79,6 +86,8 @@ class DownloadTourDialogController : 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)
snackbar = ActivityModule.provideSnackBar(rpActivity)
progressBarDownload = view.findViewById(R.id.downloadProgress) progressBarDownload = view.findViewById(R.id.downloadProgress)
downloaderBg = view.findViewById(R.id.backgroundDownloader) downloaderBg = view.findViewById(R.id.backgroundDownloader)
cancelDownloadText = view.findViewById(R.id.cancelDownloadButton) cancelDownloadText = view.findViewById(R.id.cancelDownloadButton)
...@@ -86,13 +95,12 @@ class DownloadTourDialogController : Controller { ...@@ -86,13 +95,12 @@ class DownloadTourDialogController : Controller {
// progress.visibility = View.VISIBLE // progress.visibility = View.VISIBLE
downloadToken.isCancelled = true
downloadToken = DownloadUseCase.CancellationToken(false) downloadToken = DownloadUseCase.CancellationToken(false)
downloadTourTitleText.text = tour.title downloadTourTitleText.text = tour.title
Glide.with(view) Glide.with(view)
.load(tour.previewUrl) .load(tour.previewUrl)
.transform(BlurTransformation(25, 1)) .transform(BlurTransformation(13, 8))
.transform(ColorFilterTransformation(0x99000000.toInt())) .transform(ColorFilterTransformation(0x99000000.toInt()))
.into(downloaderBg) .into(downloaderBg)
...@@ -114,9 +122,11 @@ class DownloadTourDialogController : Controller { ...@@ -114,9 +122,11 @@ class DownloadTourDialogController : Controller {
} }
,{error -> ,{error ->
Timber.e(error) Timber.e(error)
// snackbars.showSnackBar("Ошибка во время загрузки тура!") snackbar.showSnackBar(error.localizedMessage)
} }
)) ))
cancelDownloadText.setOnClickListener {
downloadToken.isCancelled = true;handleBack() }
// downloadTour(it.tour.tour_id, downloadToken) // downloadTour(it.tour.tour_id, downloadToken)
// view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() } // view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
...@@ -170,4 +180,5 @@ abstract class DownloaderScreenModule{ ...@@ -170,4 +180,5 @@ abstract class DownloaderScreenModule{
@Binds @Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context abstract fun provideContext(activity: RoomParkMainActivity): Context
} }
package com.biganto.visual.roompark.conductor.dialogs.tour_chooser package com.biganto.visual.roompark.conductor.dialogs.tour_chooser
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
...@@ -15,13 +16,17 @@ import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChange ...@@ -15,13 +16,17 @@ import com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChange
import com.biganto.visual.roompark.domain.model.TourModel import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.biganto.visual.roompark.util.extensions.setGone
import com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import timber.log.Timber import java.util.concurrent.TimeUnit
import javax.inject.Inject
/** /**
...@@ -68,28 +73,37 @@ class ChooseTourDialogController : Controller { ...@@ -68,28 +73,37 @@ class ChooseTourDialogController : Controller {
} }
detachDisposable.add( detachDisposable.add(
(recyclerView.adapter as TourChooserAdapter).onItemClicked.subscribe { (recyclerView.adapter as TourChooserAdapter)
Timber.d("gonna shit : $it") .onItemClicked
router.replaceTopController(RouterTransaction.with(DownloadTourDialogController(it)) .debounce(300L,TimeUnit.MILLISECONDS)
.popChangeHandler(DialogChangeHandler()) .observeOn(AndroidSchedulers.mainThread())
.pushChangeHandler(DialogChangeHandler()) .subscribe(::onTourClicked))
)
})
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() } //view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
view.setOnClickListener { handleBack() } view.setOnClickListener { handleBack() }
return view return view
} }
private fun onTourClicked(tour: TourModel) = when(tour.downloadState){
DownloadState.Downloaded -> {
TODO("STart Player")
}
else -> {
router.replaceTopController(RouterTransaction.with(DownloadTourDialogController(tour))
.popChangeHandler(DialogChangeHandler())
.pushChangeHandler(DialogChangeHandler())
)
}
}
@LayoutRes @LayoutRes
fun getLayoutId() = R.layout.tours_chooser_screen fun getLayoutId() = R.layout.tours_chooser_screen
override fun handleBack(): Boolean { override fun handleBack(): Boolean {
return router.popCurrentController() return router.popCurrentController()
} }
} }
internal class TourChooserAdapter:CommonRecyclerAdapter<TourChooserViewHolder,TourModel>(){ internal class TourChooserAdapter:CommonRecyclerAdapter<TourChooserViewHolder,TourModel>(){
...@@ -105,12 +119,31 @@ internal class TourChooserViewHolder(itemView: View) :CommonViewHolder<TourModel ...@@ -105,12 +119,31 @@ internal class TourChooserViewHolder(itemView: View) :CommonViewHolder<TourModel
@BindView(R.id.tour_name) @BindView(R.id.tour_name)
lateinit var tourName : MaterialTextView lateinit var tourName : MaterialTextView
@BindView(R.id.tour_status_imageView)
lateinit var tourStatus : ImageView
@Inject
lateinit var activity:Context
override fun onViewBound(model: TourModel) { override fun onViewBound(model: TourModel) {
tourName.text = model.title tourName.text = model.title
Glide.with(tourPreview) Glide.with(tourPreview)
.load(model.previewUrl) .load(model.previewUrl)
.diskCacheStrategy(DiskCacheStrategy.ALL) .diskCacheStrategy(DiskCacheStrategy.ALL)
.into(tourPreview) .into(tourPreview)
tourStatus.setGone(model.downloadState == DownloadState.Downloaded)
tourStatus.setImageDrawable(
itemView.context.resources.getDrawable(
when(model.downloadState){
DownloadState.Downloaded -> R.drawable.ic_download
DownloadState.Suspended -> R.drawable.ic_download
DownloadState.DownloadQueue -> R.drawable.ic_download
else -> R.drawable.ic_download
}
,null)
)
} }
} }
...@@ -123,6 +123,7 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -123,6 +123,7 @@ class TourPreviewsUseCase @Inject constructor(
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent)) arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent))
) )
.take(1)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.map (::fromEntity) .map (::fromEntity)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
......
...@@ -318,6 +318,7 @@ class EstateScreenController : ...@@ -318,6 +318,7 @@ class EstateScreenController :
} }
private fun render(viewState: EstateScreenViewState.ToursLoaded) { private fun render(viewState: EstateScreenViewState.ToursLoaded) {
Timber.d("Wtf")
router.pushController(RouterTransaction.with( router.pushController(RouterTransaction.with(
ChooseTourDialogController(ArrayList(viewState.tours))) ChooseTourDialogController(ArrayList(viewState.tours)))
.popChangeHandler(DialogChangeHandler()) .popChangeHandler(DialogChangeHandler())
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/download_container" android:id="@+id/download_container"
...@@ -14,7 +13,7 @@ ...@@ -14,7 +13,7 @@
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:background="#A62B2727" android:background="#A62B2727"
/> />
<TextView <com.google.android.material.textview.MaterialTextView
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/downloadingTitle" android:id="@+id/downloadingTitle"
...@@ -26,23 +25,29 @@ ...@@ -26,23 +25,29 @@
app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="32dp" android:layout_marginBottom="32dp" app:layout_constraintTop_toTopOf="parent" android:layout_marginTop="32dp" android:layout_marginBottom="32dp"
app:layout_constraintBottom_toBottomOf="@+id/backgroundDownloader" app:layout_constraintBottom_toBottomOf="@+id/backgroundDownloader"
app:layout_constraintVertical_bias="0.32999998"/> app:layout_constraintVertical_bias="0.32999998"/>
<TextView
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/tourToDownloadTitle" android:id="@+id/tourToDownloadTitle"
app:layout_constraintTop_toBottomOf="@+id/downloadingTitle" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/downloadingTitle" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="32dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="32dp" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="32dp" style="@style/TitleTextDownloader"/> android:layout_marginEnd="32dp" style="@style/TitleTextDownloader"/>
<ProgressBar <ProgressBar
android:id="@+id/downloadProgress"
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="4dp" android:layout_height="4dp"
android:id="@+id/downloadProgress" android:layout_marginStart="32dp"
app:layout_constraintTop_toBottomOf="@+id/tourToDownloadTitle" app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:progressDrawable="@drawable/horizontal_progress_downloader"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="150dp" android:layout_marginEnd="150dp" app:layout_constraintStart_toStartOf="parent"
android:progressDrawable="@drawable/horizontal_progress_downloader" android:layout_marginTop="8dp"/> app:layout_constraintTop_toBottomOf="@+id/tourToDownloadTitle" />
<TextView
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/cancelDownloadButton" android:id="@+id/cancelDownloadButton"
......
...@@ -9,19 +9,19 @@ ...@@ -9,19 +9,19 @@
android:id="@+id/tour_preview_imageView" android:id="@+id/tour_preview_imageView"
android:layout_width="32dp" android:layout_width="32dp"
android:layout_height="32dp" android:layout_height="32dp"
android:layout_marginStart="0dp" android:layout_marginTop="8dp"
android:layout_marginTop="16dp" android:layout_marginBottom="8dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_bell_on" /> app:srcCompat="@drawable/ic_bell_on" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
style="@style/Common_Text.Notice"
android:id="@+id/tour_name" android:id="@+id/tour_name"
style="@style/Common_Text.Notice"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:ellipsize="end" android:ellipsize="end"
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
android:id="@+id/tour_status_imageView" android:id="@+id/tour_status_imageView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="@+id/tour_name" app:layout_constraintBottom_toBottomOf="@+id/tour_name"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
......
...@@ -441,7 +441,7 @@ ...@@ -441,7 +441,7 @@
</style> </style>
<style name="TitleTextDownloader" parent="Default_TextView"> <style name="TitleTextDownloader" parent="Default_TextView">
<!-- <item name="android:textColor">@color/def</item>--> <item name="android:textColor">@color/colorInvertedText</item>
</style> </style>
<style name="BubbleTitleText" parent="Header_TextView.Main_Header"> <style name="BubbleTitleText" parent="Header_TextView.Main_Header">
......
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