Commit 94e478fa authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

view patterns added

parent 52e38547
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.AlbumsListModel
import com.biganto.visual.roompark.domain.use_case.AlbumsUseCase
import com.biganto.visual.roompark.domain.use_case.CamsUseCase
import io.reactivex.Observable
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 09.10.2019.
*/
class AlbumssInteractor @Inject constructor(
private val useCase: AlbumsUseCase
) {
fun fetchHeaderAlbums() = useCase.getProgressAlbums()
fun fetchAlbumPhotos(parentId:Int) =
useCase.getChildAlbum(parentId)
}
package com.biganto.visual.roompark.presentation.screen.albums
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface AlbumsScreen : BigantoBaseContract<AlbumsScreenViewState> {
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.web_cam
import android.os.Bundle
import android.view.View
import androidx.core.os.bundleOf
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.IBottomNavigation
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.presentation.screen.albums.AlbumsScreen
import com.biganto.visual.roompark.presentation.screen.albums.AlbumsScreenPresenter
import com.biganto.visual.roompark.presentation.screen.albums.AlbumsScreenViewState
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.ui.PlayerView
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
const val SELECTED_ALBUM_INDEX_KEY = "SELECTED_ALBUM_INDEX"
class AlbumsScreenController :
BigantoBaseController<AlbumsScreenViewState
, AlbumsScreen
, AlbumsScreenPresenter>
, AlbumsScreen {
constructor(args: Bundle):super(args)
constructor(id: Int) : super(bundleOf(SELECTED_CAM_INDEX_KEY to id))
@BindView(R.id.webCamPlayerView)
lateinit var playerView:PlayerView
lateinit var player:SimpleExoPlayer
override fun onViewBound(v: View) {
toolBar.hideAll()
bottomNavigation.hide()
}
override fun injectDependencies() {
getComponent()
}
@Inject
override lateinit var injectedPresenter: AlbumsScreenPresenter
// @Inject
// lateinit var snacky:ISnackBarProvider
lateinit var rpActivity: RoomParkMainActivity
fun getComponent() = DaggerAlbumsScreenComponent
.factory()
.create(RoomParkApplication.component
,activity as RoomParkMainActivity
,args.getInt(SELECTED_CAM_INDEX_KEY))
.inject(this)
// @Inject
// lateinit var ac: RoomParkMainActivity
@Inject
lateinit var bottomNavigation: IBottomNavigation
override fun render(viewState: AlbumsScreenViewState) {
when(viewState){
is AlbumsScreenViewState.Idle -> render(viewState)
is AlbumsScreenViewState.AlbumsSelected -> render(viewState)
is AlbumsScreenViewState.AlbumsListLoaded-> render(viewState)
is AlbumsScreenViewState.SomeError -> render(viewState)
}
}
private fun render(viewState: AlbumsScreenViewState.Idle){
}
private fun render(viewState: AlbumsScreenViewState.SomeError) =
showError(viewState.exception)
private fun render(viewState: AlbumsScreenViewState.AlbumsListLoaded){
}
private fun render(viewState: AlbumsScreenViewState.AlbumsSelected){
}
override fun getLayoutId(): Int = R.layout.prog
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.albums
import android.content.Context
import com.biganto.visual.roompark.base.IBottomNavigation
import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.presentation.screen.web_cam.AlbumsScreenController
import com.biganto.visual.roompark.presentation.screen.web_cam.SELECTED_ALBUM_INDEX_KEY
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import javax.inject.Named
///**
// * Created by Vladislav Bogdashkin on 30.09.2019.
// */
@PerScreen
@Component(
modules = [AlbumsScreenModule::class]
,dependencies = [AppComponent::class]
)
interface AlbumsScreenComponent {
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent
,@BindsInstance activity: RoomParkMainActivity
,@BindsInstance @Named(SELECTED_ALBUM_INDEX_KEY) camIndex:Int
): AlbumsScreenComponent
}
fun inject(controller: AlbumsScreenController)
}
@Module
abstract class AlbumsScreenModule{
@PerScreen
@Binds
abstract fun provideContext(activity: RoomParkMainActivity): Context
@PerScreen
@Binds
abstract fun provideBottomNavigation(activitiy: RoomParkMainActivity): IBottomNavigation
}
package com.biganto.visual.roompark.presentation.screen.albums
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import com.biganto.visual.roompark.domain.interactor.AlbumssInteractor
import com.biganto.visual.roompark.presentation.screen.web_cam.SELECTED_CAM_INDEX_KEY
import com.biganto.visual.roompark.util.monades.ExceptionString
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject
import javax.inject.Named
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class AlbumsScreenPresenter @Inject constructor(
private val interactor: AlbumssInteractor
,@Named(SELECTED_CAM_INDEX_KEY) private var selectedCamIndex:Int
)
: BigantoBasePresenter<AlbumsScreen, AlbumsScreenViewState>() {
override fun defaultErrorViewStateHandler() =
{e: ExceptionString -> AlbumsScreenViewState.SomeError(e) }
override fun bindIntents() {
val state = restoreStateObservable
.mergeWith(interactor.fetchCams()
.map {AlbumsScreenViewState.AlbumsListLoaded(it.items.toList(),selectedCamIndex)}
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
subscribeViewState(state.cast(AlbumsScreenViewState::class.java), AlbumsScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.albums
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.AlbumPhotoPreviewModel
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.util.monades.ExceptionString
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class AlbumsScreenViewState : BigantoBaseViewState() {
class Idle : AlbumsScreenViewState()
class AlbumsListLoaded(val list:List<AlbumPreviewModel>, val selectedCamIndex:Int) : AlbumsScreenViewState()
class AlbumsSelected(val list:List<AlbumPhotoPreviewModel>) : AlbumsScreenViewState()
class PhotoSelected(val photoId:Int) : AlbumsScreenViewState()
class SomeError(val exception: ExceptionString) : AlbumsScreenViewState()
}
\ No newline at end of file
......@@ -4,7 +4,8 @@
android:layout_width="142dp"
android:layout_height="94dp"
android:layout_margin="16dp"
app:cardElevation="2dp"
app:cardElevation="4dp"
app:cardMaxElevation="6dp"
app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorOpacityBackground"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/include12"
tools:itemCount="3"
tools:listitem="@layout/date_album_viewholder" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/headers_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="1"
tools:listitem="@layout/estate_card_viewholder" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/header_album_title"
style="@style/Header_TextView.Inverted_Header"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="32dp"
android:gravity="center_vertical"
android:text="Дом №1"
android:textAlignment="viewStart"
app:layout_constraintEnd_toStartOf="@+id/include"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/headers_recycler_view" />
<include
android:id="@+id/include"
layout="@layout/bell_switch_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="@+id/header_album_title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/headers_recycler_view" />
<include
android:id="@+id/include12"
layout="@layout/horizontal_divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/header_album_title" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.textview.MaterialTextView
style="@style/Common_Text.Inverted"
android:id="@+id/date_title_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/photos_recycler_iew"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"
android:orientation="vertical" />
</LinearLayout>
\ No newline at end of file
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