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
0d2af45b
Commit
0d2af45b
authored
Apr 09, 2020
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start courd for lists
parent
403a7924
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
147 additions
and
19 deletions
+147
-19
TourChooserDialogController.kt
...uctor/dialogs/tour_chooser/TourChooserDialogController.kt
+1
-0
tours.kt
...va/com/biganto/visual/roompark/domain/interactor/tours.kt
+7
-1
ScreenContract.kt
...isual/roompark/presentation/screen/deal/ScreenContract.kt
+1
-0
ScreenController.kt
...ual/roompark/presentation/screen/deal/ScreenController.kt
+23
-0
ScreenPresenter.kt
...sual/roompark/presentation/screen/deal/ScreenPresenter.kt
+17
-3
ScreenViewState.kt
...sual/roompark/presentation/screen/deal/ScreenViewState.kt
+2
-0
ScreenContract.kt
...sual/roompark/presentation/screen/deals/ScreenContract.kt
+3
-0
ScreenController.kt
...al/roompark/presentation/screen/deals/ScreenController.kt
+22
-8
ScreenPresenter.kt
...ual/roompark/presentation/screen/deals/ScreenPresenter.kt
+12
-2
ScreenViewState.kt
...ual/roompark/presentation/screen/deals/ScreenViewState.kt
+2
-0
Adapter.kt
...visual/roompark/presentation/screen/deals/util/Adapter.kt
+2
-2
ScreenController.kt
...l/roompark/presentation/screen/estate/ScreenController.kt
+1
-1
ScreenContract.kt
.../roompark/presentation/screen/favorites/ScreenContract.kt
+3
-0
ScreenController.kt
...oompark/presentation/screen/favorites/ScreenController.kt
+20
-0
ScreenPresenter.kt
...roompark/presentation/screen/favorites/ScreenPresenter.kt
+12
-2
ScreenViewState.kt
...roompark/presentation/screen/favorites/ScreenViewState.kt
+2
-0
FavoritesAdapter.kt
...rk/presentation/screen/favorites/util/FavoritesAdapter.kt
+17
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/dialogs/tour_chooser/TourChooserDialogController.kt
View file @
0d2af45b
...
...
@@ -91,6 +91,7 @@ class ChooseTourDialogController : Controller {
when
(
tour
.
downloadState
)
{
DownloadState
.
Downloaded
->
{
activity
?.
let
{
startPlayer
(
it
,
tour
)
}
handleBack
()
}
else
->
{
router
.
replaceTopController
(
...
...
app/src/main/java/com/biganto/visual/roompark/domain/interactor/tours.kt
View file @
0d2af45b
package
com.biganto.visual.roompark.domain.interactor
import
com.biganto.visual.roompark.domain.model.EstateModel
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.TourPreviewsUseCase
import
io.reactivex.Observable
import
javax.inject.Inject
/**
...
...
@@ -14,7 +16,11 @@ class ToursInteractor @Inject constructor(
private
val
tourUseCase
:
TourPreviewsUseCase
){
fun
getEstateTourList
(
estate
:
EstateModel
)
=
fun
getEstateTourList
(
multiTourId
:
Int
?,
estateId
:
Int
)
=
tourUseCase
.
fetchTourOffer
(
multiTourId
?:
error
(
"Отсутсвуют виртуальные туры для данного объекта"
),
estateId
)
fun
getEstateTourList
(
estate
:
EstateModel
):
Observable
<
List
<
TourModel
>>
=
tourUseCase
.
fetchTourOffer
(
estate
.
multitourId
?:
error
(
"Отсутсвуют виртуальные туры для данного объекта"
),
estate
.
id
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenContract.kt
View file @
0d2af45b
...
...
@@ -9,5 +9,6 @@ import io.reactivex.Observable
interface
DealScreen
:
BigantoBaseContract
<
DealScreenViewState
>
{
fun
onSubscription
():
Observable
<
Boolean
>
fun
tourCardClicked
():
Observable
<
Int
>
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenController.kt
View file @
0d2af45b
...
...
@@ -12,10 +12,13 @@ import com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.tour_chooser.ChooseTourDialogController
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.typeDoubleString
import
com.biganto.visual.roompark.domain.model.typeShortString
import
com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.extensions.toRubly
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
...
...
@@ -96,6 +99,14 @@ class DealScreenController :
@BindView
(
R
.
id
.
start_tour_image_view
)
lateinit
var
tourScreen
:
RoundedImageView
override
fun
tourCardClicked
():
Observable
<
Int
>
=
tourScreen
.
clicks
()
.
map
{
1
}
.
debounce
(
320L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
private
var
servedDeal
:
DealModel
?
=
null
override
fun
onAttach
(
view
:
View
)
{
...
...
@@ -189,6 +200,7 @@ class DealScreenController :
is
DealScreenViewState
.
RestoreView
->
render
(
viewState
)
is
DealScreenViewState
.
SubscriptionStatus
->
render
(
viewState
)
is
DealScreenViewState
.
SubscriptionError
->
render
(
viewState
)
is
DealScreenViewState
.
ToursLoaded
->
render
(
viewState
)
}
}
...
...
@@ -232,6 +244,15 @@ class DealScreenController :
}
}
private
fun
render
(
viewState
:
DealScreenViewState
.
ToursLoaded
)
{
router
.
pushController
(
RouterTransaction
.
with
(
ChooseTourDialogController
(
ArrayList
(
viewState
.
tours
))
)
.
popChangeHandler
(
DialogChangeHandler
())
.
pushChangeHandler
(
DialogChangeHandler
())
)
}
private
fun
render
(
viewState
:
DealScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
...
...
@@ -245,6 +266,8 @@ class DealScreenController :
private
fun
render
(
viewState
:
DealScreenViewState
.
LoadDeal
)
{
servedDeal
=
viewState
.
estate
startTourView
.
setGone
(
servedDeal
?.
estate
?.
multitourId
==
null
)
dealTitle
.
text
=
resources
?.
getString
(
viewState
.
estate
.
estate
.
type
.
typeDoubleString
(),
viewState
.
estate
.
estate
.
number
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenPresenter.kt
View file @
0d2af45b
...
...
@@ -3,6 +3,8 @@ package com.biganto.visual.roompark.presentation.screen.deal
import
android.content.Context
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.DealInteractor
import
com.biganto.visual.roompark.domain.interactor.ToursInteractor
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.SubscriptionModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.Observable
...
...
@@ -19,6 +21,7 @@ import javax.inject.Named
class
DealScreenPresenter
@Inject
constructor
(
private
val
interactor
:
DealInteractor
,
private
val
toursInteractor
:
ToursInteractor
,
private
val
context
:
Context
,
@Named
(
SELECTED_DEAL_ID_KEY
)
private
val
dealId
:
String
)
...
...
@@ -28,7 +31,7 @@ class DealScreenPresenter @Inject constructor(
override
fun
defaultErrorViewStateHandler
()
=
{
e
:
ExceptionString
->
DealScreenViewState
.
SomeError
(
e
)
}
private
var
restoreModel
=
RestoreModel
(
null
)
private
var
restoreModel
=
RestoreModel
(
null
,
null
)
override
fun
detachView
()
{
super
.
detachView
()
...
...
@@ -38,6 +41,7 @@ class DealScreenPresenter @Inject constructor(
override
fun
bindIntents
()
{
val
fetchDeal
=
interactor
.
getDeal
(
dealId
)
.
doOnNext
{
restoreModel
.
deal
=
it
}
.
map
<
DealScreenViewState
>{
deal
->
DealScreenViewState
.
LoadDeal
(
deal
,
interactor
.
getStatusListSync
())
}
...
...
@@ -64,13 +68,23 @@ class DealScreenPresenter @Inject constructor(
.
map
<
DealScreenViewState
>
{
DealScreenViewState
.
SubscriptionStatus
(
it
.
state
)
}
.
startWith
(
Observable
.
just
<
DealScreenViewState
>(
DealScreenViewState
.
Idle
()))
val
onStartTours
=
intent
(
DealScreen
::
tourCardClicked
)
.
map
{
restoreModel
.
deal
}
.
map
{
it
.
estate
}
.
flatMap
{
estate
->
toursInteractor
.
getEstateTourList
(
estate
)
.
map
{
DealScreenViewState
.
ToursLoaded
(
it
)
}
}
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
restoreStateObservable
,
fetchDeal
,
setRead
,
onSubChecked
,
fetchSubscription
fetchSubscription
,
onStartTours
))
.
doOnError
{
Timber
.
e
(
it
)
}
.
onErrorReturn
(
::
parseError
)
...
...
@@ -83,4 +97,4 @@ class DealScreenPresenter @Inject constructor(
data class
RestoreModel
(
var
sub
:
SubscriptionModel
?)
\ No newline at end of file
data class
RestoreModel
(
var
sub
:
SubscriptionModel
?,
var
deal
:
DealModel
?)
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deal/ScreenViewState.kt
View file @
0d2af45b
...
...
@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.presentation.screen.deal
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.DealModel
import
com.biganto.visual.roompark.domain.model.StatusModel
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
/**
...
...
@@ -17,4 +18,5 @@ sealed class DealScreenViewState : BigantoBaseViewState() {
class
RestoreView
(
val
restore
:
RestoreModel
)
:
DealScreenViewState
()
class
SubscriptionStatus
(
val
subState
:
Boolean
)
:
DealScreenViewState
()
class
SubscriptionError
(
val
subState
:
Boolean
)
:
DealScreenViewState
()
class
ToursLoaded
(
val
tours
:
List
<
TourModel
>)
:
DealScreenViewState
()
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenContract.kt
View file @
0d2af45b
package
com.biganto.visual.roompark.presentation.screen.deals
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.domain.model.DealPreviewModel
import
io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface
DealsScreen
:
BigantoBaseContract
<
DealsScreenViewState
>
{
fun
tourCardClicked
():
Observable
<
DealPreviewModel
>
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenController.kt
View file @
0d2af45b
...
...
@@ -9,12 +9,16 @@ import com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.tour_chooser.ChooseTourDialogController
import
com.biganto.visual.roompark.domain.model.DealPreviewModel
import
com.biganto.visual.roompark.presentation.screen.deal.DealScreenController
import
com.biganto.visual.roompark.presentation.screen.deals.util.DealsListAdapter
import
com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
javax.inject.Inject
...
...
@@ -90,14 +94,7 @@ class DealsScreenController :
.
popChangeHandler
(
FadeChangeHandler
())
.
pushChangeHandler
(
FadeChangeHandler
())
)
},
(
dealsRecyclerView
.
adapter
as
DealsListAdapter
)
.
startTour
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
{
Timber
.
d
(
"got tour clicked $it"
)
showMessage
(
R
.
string
.
tour_not_allowed
)
}
}
)
}
...
...
@@ -107,6 +104,12 @@ class DealsScreenController :
bindRecycler
()
}
override
fun
tourCardClicked
():
Observable
<
DealPreviewModel
>
=
(
dealsRecyclerView
.
adapter
as
DealsListAdapter
)
.
startTour
.
map
{
it
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
render
(
viewState
:
DealsScreenViewState
)
{
super
.
render
(
viewState
)
Timber
.
d
(
"Render state $viewState"
)
...
...
@@ -114,6 +117,7 @@ class DealsScreenController :
is
DealsScreenViewState
.
Idle
->
render
(
viewState
)
is
DealsScreenViewState
.
DealsLoaded
->
render
(
viewState
)
is
DealsScreenViewState
.
SomeError
->
render
(
viewState
)
is
DealsScreenViewState
.
ToursLoaded
->
render
(
viewState
)
}
}
...
...
@@ -125,6 +129,16 @@ class DealsScreenController :
(
dealsRecyclerView
.
adapter
as
DealsListAdapter
).
addItems
(
viewState
.
items
)
}
private
fun
render
(
viewState
:
DealsScreenViewState
.
ToursLoaded
)
{
router
.
pushController
(
RouterTransaction
.
with
(
ChooseTourDialogController
(
ArrayList
(
viewState
.
tours
))
)
.
popChangeHandler
(
DialogChangeHandler
())
.
pushChangeHandler
(
DialogChangeHandler
())
)
}
private
fun
render
(
viewState
:
DealsScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenPresenter.kt
View file @
0d2af45b
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.deals
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.DealsInteractor
import
com.biganto.visual.roompark.domain.interactor.ToursInteractor
import
com.biganto.visual.roompark.domain.model.DealPreviewModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.Observable
...
...
@@ -16,7 +17,8 @@ import javax.inject.Inject
class
DealsScreenPresenter
@Inject
constructor
(
private
val
interactor
:
DealsInteractor
private
val
interactor
:
DealsInteractor
,
private
val
toursInteractor
:
ToursInteractor
)
:
BigantoBasePresenter
<
DealsScreen
,
DealsScreenViewState
>()
{
...
...
@@ -42,10 +44,18 @@ class DealsScreenPresenter @Inject constructor(
.
map
<
DealsScreenViewState
>(
DealsScreenViewState
::
DealsLoaded
)
.
onErrorReturn
(
::
parseError
)
val
onStartTours
=
intent
(
DealsScreen
::
tourCardClicked
)
.
flatMap
{
dealPreview
->
toursInteractor
.
getEstateTourList
(
dealPreview
.
tourId
,
dealPreview
.
estateId
)
.
map
{
DealsScreenViewState
.
ToursLoaded
(
it
)
}
}
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
restoreStateObservable
,
fetchDeals
fetchDeals
,
onStartTours
)
)
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/ScreenViewState.kt
View file @
0d2af45b
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.deals
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.DealPreviewModel
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
/**
...
...
@@ -13,5 +14,6 @@ sealed class DealsScreenViewState : BigantoBaseViewState() {
class
Idle
:
DealsScreenViewState
()
class
DealsLoaded
(
val
items
:
List
<
DealPreviewModel
>)
:
DealsScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
DealsScreenViewState
()
class
ToursLoaded
(
val
tours
:
List
<
TourModel
>)
:
DealsScreenViewState
()
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/deals/util/Adapter.kt
View file @
0d2af45b
...
...
@@ -34,7 +34,7 @@ class DealsListAdapter : CommonRecyclerAdapter<DealViewHolder, DealPreviewModel>
override
fun
getVhLayout
()
=
R
.
layout
.
deal_card_viewholder
private
val
onFlatClicked
=
PublishSubject
.
create
<
Int
>()
private
val
onTourClickced
=
PublishSubject
.
create
<
Int
>()
private
val
onTourClickced
=
PublishSubject
.
create
<
DealPreviewModel
>()
override
fun
onBindViewHolder
(
holder
:
DealViewHolder
,
position
:
Int
)
{
super
.
onBindViewHolder
(
holder
,
position
)
...
...
@@ -73,7 +73,7 @@ class DealViewHolder(itemView: View) : CommonViewHolder<DealPreviewModel>(itemVi
@BindView
(
R
.
id
.
deal_read
)
lateinit
var
dealReadFlag
:
View
val
onStartFlatObs
:
Observable
<
Int
?>
get
()
=
startFlat
.
clicks
().
map
{
bindedModel
.
estateId
}
val
onStartTourObs
:
Observable
<
Int
?>
get
()
=
startTour
.
clicks
().
map
{
bindedModel
.
tourId
}
val
onStartTourObs
:
Observable
<
DealPreviewModel
>
get
()
=
startTour
.
clicks
().
map
{
bindedModel
}
override
fun
onViewBound
(
model
:
DealPreviewModel
)
{
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/estate/ScreenController.kt
View file @
0d2af45b
...
...
@@ -270,6 +270,7 @@ class EstateScreenController :
}
private
fun
render
(
viewState
:
EstateScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
...
...
@@ -318,7 +319,6 @@ class EstateScreenController :
}
private
fun
render
(
viewState
:
EstateScreenViewState
.
ToursLoaded
)
{
Timber
.
d
(
"Wtf"
)
router
.
pushController
(
RouterTransaction
.
with
(
ChooseTourDialogController
(
ArrayList
(
viewState
.
tours
)))
.
popChangeHandler
(
DialogChangeHandler
())
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/favorites/ScreenContract.kt
View file @
0d2af45b
package
com.biganto.visual.roompark.presentation.screen.favorites
import
com.biganto.visual.roompark.conductor.BigantoBaseContract
import
com.biganto.visual.roompark.domain.model.EstateModel
import
io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface
FavoritesScreen
:
BigantoBaseContract
<
FavoritesScreenViewState
>
{
fun
tourCardClicked
():
Observable
<
EstateModel
>
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/favorites/ScreenController.kt
View file @
0d2af45b
...
...
@@ -9,13 +9,18 @@ import com.biganto.visual.roompark.base.HeaderToolbarModel
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.dialogs.change_handler.DialogChangeHandler
import
com.biganto.visual.roompark.conductor.dialogs.tour_chooser.ChooseTourDialogController
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.presentation.screen.estate.EstateScreenController
import
com.biganto.visual.roompark.presentation.screen.favorites.util.FavoritesListAdapter
import
com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import
com.bluelinelabs.conductor.RouterTransaction
import
com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
timber.log.Timber
import
java.util.concurrent.TimeUnit
import
javax.inject.Inject
/**
...
...
@@ -38,6 +43,11 @@ class FavoritesScreenController :
@BindView
(
R
.
id
.
favorites_cards_recycler_view
)
lateinit
var
favoritesRecyclerView
:
RecyclerView
override
fun
tourCardClicked
():
Observable
<
EstateModel
>
=
(
favoritesRecyclerView
.
adapter
as
FavoritesListAdapter
)
.
startTour
.
debounce
(
220L
,
TimeUnit
.
MILLISECONDS
)
.
observeOn
(
AndroidSchedulers
.
mainThread
())
override
fun
onAttach
(
view
:
View
)
{
super
.
onAttach
(
view
)
...
...
@@ -93,6 +103,7 @@ class FavoritesScreenController :
is
FavoritesScreenViewState
.
Idle
->
render
(
viewState
)
is
FavoritesScreenViewState
.
FavoriteEstatesLoaded
->
render
(
viewState
)
is
FavoritesScreenViewState
.
SomeError
->
render
(
viewState
)
is
FavoritesScreenViewState
.
ToursLoaded
->
render
(
viewState
)
}
}
...
...
@@ -100,6 +111,15 @@ class FavoritesScreenController :
}
private
fun
render
(
viewState
:
FavoritesScreenViewState
.
ToursLoaded
)
{
router
.
pushController
(
RouterTransaction
.
with
(
ChooseTourDialogController
(
ArrayList
(
viewState
.
tours
))
)
.
popChangeHandler
(
DialogChangeHandler
())
.
pushChangeHandler
(
DialogChangeHandler
())
)
}
private
fun
render
(
viewState
:
FavoritesScreenViewState
.
SomeError
)
=
showError
(
viewState
.
exception
)
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/favorites/ScreenPresenter.kt
View file @
0d2af45b
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
com.biganto.visual.roompark.domain.interactor.FavoritesInteractor
import
com.biganto.visual.roompark.domain.interactor.ToursInteractor
import
com.biganto.visual.roompark.util.monades.ExceptionString
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
...
...
@@ -15,7 +16,8 @@ import javax.inject.Inject
class
FavoritesScreenPresenter
@Inject
constructor
(
private
val
interactor
:
FavoritesInteractor
private
val
interactor
:
FavoritesInteractor
,
private
val
toursInteractor
:
ToursInteractor
)
:
BigantoBasePresenter
<
FavoritesScreen
,
FavoritesScreenViewState
>()
{
...
...
@@ -27,10 +29,18 @@ class FavoritesScreenPresenter @Inject constructor(
val
prefetchCards
=
interactor
.
getFavoritesForCurrentUser
()
.
map
{
FavoritesScreenViewState
.
FavoriteEstatesLoaded
(
it
)
}
val
onStartTours
=
intent
(
FavoritesScreen
::
tourCardClicked
)
.
flatMap
{
estate
->
toursInteractor
.
getEstateTourList
(
estate
)
.
map
{
FavoritesScreenViewState
.
ToursLoaded
(
it
)
}
}
val
state
=
Observable
.
mergeDelayError
(
arrayListOf
(
restoreStateObservable
,
prefetchCards
prefetchCards
,
onStartTours
)
)
.
doOnError
{
Timber
.
e
(
it
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/favorites/ScreenViewState.kt
View file @
0d2af45b
...
...
@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.presentation.screen.favorites
import
com.biganto.visual.roompark.conductor.BigantoBaseViewState
import
com.biganto.visual.roompark.domain.model.EstateModel
import
com.biganto.visual.roompark.domain.model.TourModel
import
com.biganto.visual.roompark.util.monades.ExceptionString
/**
...
...
@@ -13,4 +14,5 @@ sealed class FavoritesScreenViewState : BigantoBaseViewState() {
class
Idle
:
FavoritesScreenViewState
()
class
FavoriteEstatesLoaded
(
val
items
:
List
<
EstateModel
>)
:
FavoritesScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
FavoritesScreenViewState
()
class
ToursLoaded
(
val
tours
:
List
<
TourModel
>)
:
FavoritesScreenViewState
()
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/favorites/util/FavoritesAdapter.kt
View file @
0d2af45b
...
...
@@ -14,6 +14,9 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc
import
com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import
com.biganto.visual.roompark.util.extensions.setGone
import
com.biganto.visual.roompark.util.extensions.startUrl
import
com.jakewharton.rxbinding3.view.clicks
import
io.reactivex.Observable
import
io.reactivex.subjects.PublishSubject
/**
* Created by Vladislav Bogdashkin on 16.10.2019.
...
...
@@ -22,6 +25,15 @@ import com.biganto.visual.roompark.util.extensions.startUrl
class
FavoritesListAdapter
:
CommonRecyclerAdapter
<
FavoriteViewHolder
,
EstateModel
>()
{
override
val
vhKlazz
=
FavoriteViewHolder
::
class
override
fun
getVhLayout
():
Int
=
R
.
layout
.
favorite_card_viewholder
private
val
onTourClickced
=
PublishSubject
.
create
<
EstateModel
>()
override
fun
onBindViewHolder
(
holder
:
FavoriteViewHolder
,
position
:
Int
)
{
super
.
onBindViewHolder
(
holder
,
position
)
holder
.
onStartTourObs
.
subscribe
(
onTourClickced
)
}
val
startTour
get
()
=
onTourClickced
}
...
...
@@ -45,10 +57,13 @@ class FavoriteViewHolder(itemView: View) : CommonViewHolder<EstateModel>(itemVie
init
{
ButterKnife
.
bind
(
this
,
itemView
)
}
val
onStartTourObs
:
Observable
<
EstateModel
>
get
()
=
startTour
.
clicks
().
map
{
bindedModel
}
override
fun
onViewBound
(
model
:
EstateModel
)
{
estateTitle
.
text
=
itemView
.
context
.
resources
?.
getString
(
model
.
type
.
typeDoubleString
(),
model
.
number
)
...
...
@@ -57,6 +72,8 @@ class FavoriteViewHolder(itemView: View) : CommonViewHolder<EstateModel>(itemVie
startTour
.
setGone
(
model
.
type
!=
FlatType
.
FLAT
)
startTour
.
setGone
(
model
.
multitourId
==
null
)
siteLink
.
setGone
(
model
.
url
==
null
)
siteLinkDivider
.
setGone
(
model
.
url
==
null
)
model
.
url
?.
let
{
url
->
...
...
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