Commit a9d211a1 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

move slider to correct index

parent c6397e8d
...@@ -113,10 +113,12 @@ class PhotoScreenController : ...@@ -113,10 +113,12 @@ class PhotoScreenController :
(photoViewPager.adapter as PhotosAdapter).setItems( (photoViewPager.adapter as PhotosAdapter).setItems(
viewState.list.asSequence().sortedBy{it.sort}.toList() viewState.list.asSequence().sortedBy{it.sort}.toList()
) )
photoViewPager.currentItem = viewState.selectedId
slider.visibility= View.VISIBLE slider.visibility= View.VISIBLE
slider.setUpViewPager(photoViewPager) slider.setUpViewPager(photoViewPager)
photoViewPager.currentItem =
(photoViewPager.adapter as PhotosAdapter).indexById(viewState.selectedId)
} }
private fun render(viewState: PhotoScreenViewState.AldumFetched) { private fun render(viewState: PhotoScreenViewState.AldumFetched) {
...@@ -127,11 +129,12 @@ class PhotoScreenController : ...@@ -127,11 +129,12 @@ class PhotoScreenController :
private fun render(viewState: PhotoScreenViewState.PhotoFetched){ private fun render(viewState: PhotoScreenViewState.PhotoFetched){
(photoViewPager.adapter as PhotosAdapter).setItems(arrayListOf(viewState.model)) (photoViewPager.adapter as PhotosAdapter).setItems(arrayListOf(viewState.model))
} }
private fun render(viewState: PhotoScreenViewState.PhotoSelected){ private fun render(viewState: PhotoScreenViewState.PhotoSelected){
// (photoViewPager.adapter as PhotoViewerAdapter).setItems(arrayListOf(viewState.model)) // (photoViewPager.adapter as PhotoViewerAdapter).setItems(arrayListOf(viewState.model))
} }
override fun handleBack(): Boolean {router.popController(this); return true}
override fun getLayoutId(): Int = R.layout.photo_view_screen override fun getLayoutId(): Int = R.layout.photo_view_screen
......
...@@ -177,6 +177,7 @@ class PhotoPreviewSlider @JvmOverloads constructor( ...@@ -177,6 +177,7 @@ class PhotoPreviewSlider @JvmOverloads constructor(
texThread?.start() texThread?.start()
adapter?.let {adapter -> adapter?.let {adapter ->
texThread?.setAdapter(adapter.photosPreviewList) texThread?.setAdapter(adapter.photosPreviewList)
texThread?.setIndex(vp?.currentItem?:0)
// texThread?.setIndex(min(_l.size,2)) // texThread?.setIndex(min(_l.size,2))
}?: error("adapter not ready!") }?: error("adapter not ready!")
} }
......
...@@ -25,6 +25,8 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() { ...@@ -25,6 +25,8 @@ class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
} }
fun indexById(id:Int):Int = list.indexOfFirst { it.photoId == id }
override val vhKlazz = PhotosViewHolder::class override val vhKlazz = PhotosViewHolder::class
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
android:id="@+id/linearLayout6" android:id="@+id/linearLayout6"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorOpacityBackground"> android:background="#000000">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/photoTitle" android:id="@+id/photoTitle"
...@@ -61,8 +61,8 @@ ...@@ -61,8 +61,8 @@
android:id="@+id/change_size_button" android:id="@+id/change_size_button"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2" app:layout_constraintTop_toTopOf="@+id/guideline2"
app:srcCompat="@drawable/iic_full_view" /> app:srcCompat="@drawable/iic_full_view" />
......
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