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

album list adapter && photo adapter

parent 0073535e
...@@ -115,8 +115,8 @@ data class ImageAlbumRaw( ...@@ -115,8 +115,8 @@ data class ImageAlbumRaw(
val title:String, val title:String,
val sort:Int, val sort:Int,
val date:Date, val date:Date,
val parent_id:Int, val parent_id:Int?,
val preview: String val preview: String?
) )
data class GalleryImageRaw( data class GalleryImageRaw(
......
...@@ -72,7 +72,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity { ...@@ -72,7 +72,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
entity.setTitle(raw.title) entity.setTitle(raw.title)
entity.setPublished(raw.date) entity.setPublished(raw.date)
entity.setSort(raw.sort) entity.setSort(raw.sort)
entity.setPreview(raw.preview) entity.setPreview(raw.preview?:"https://room-park.ru/assets/gallery_images/image_2600/00/00/03/800-1b7546.png")
return entity return entity
} }
......
...@@ -121,7 +121,7 @@ class AlbumsScreenController : ...@@ -121,7 +121,7 @@ class AlbumsScreenController :
} }
private fun render(viewState: AlbumsScreenViewState.AlbumsSelected){ private fun render(viewState: AlbumsScreenViewState.AlbumsSelected){
(albumsRecyclerView.adapter as AlbumListAdapter).setItems(viewState.list)
} }
......
package com.biganto.visual.roompark.presentation.screen.favorites.util package com.biganto.visual.roompark.presentation.screen.favorites.util
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import butterknife.BindView import butterknife.BindView
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPhotoPreviewModel import com.biganto.visual.roompark.domain.model.AlbumSortedModel
import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.domain.model.PhotoResolutionModel
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.view_utils.image_view.RoundedImageView
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import com.squareup.picasso.Picasso
/** /**
* Created by Vladislav Bogdashkin on 16.10.2019. * Created by Vladislav Bogdashkin on 16.10.2019.
*/ */
class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumPhotoPreviewModel>() { class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumSortedModel>() {
override val vhKlazz = AlbumViewHolder::class override val vhKlazz = AlbumViewHolder::class
override fun getVhLayout(): Int = R.layout.date_album_viewholder override fun getVhLayout(): Int = R.layout.date_album_viewholder
} }
class AlbumViewHolder(itemView: View) : CommonViewHolder<AlbumPhotoPreviewModel>(itemView) { class AlbumViewHolder(itemView: View) : CommonViewHolder<AlbumSortedModel>(itemView) {
@BindView(R.id.date_title_textview) lateinit var albumTitle: MaterialTextView @BindView(R.id.date_title_textview) lateinit var albumTitle: MaterialTextView
// @BindView(R.id.camStatus) lateinit var camStatus: MaterialTextView @BindView(R.id.photos_recyclerview) lateinit var photosRecyclerView: RecyclerView
// @BindView(R.id.camStatusIcon) lateinit var camStatusIcon:ImageView // @BindView(R.id.camStatusIcon) lateinit var camStatusIcon:ImageView
override fun onViewBound(model: AlbumPhotoPreviewModel) { override fun onViewBound(model: AlbumSortedModel) {
albumTitle.text = model.title albumTitle.text = model.title
// camTitle.text = model.title photosRecyclerView.isNestedScrollingEnabled = true
// camStatus.text = if (model.streams.isNullOrEmpty()) "ОФФЛАЙН" else "ОНЛАЙН" photosRecyclerView.layoutManager =
// camStatusIcon.visibility = if (model.streams.isNullOrEmpty()) View.GONE else View.VISIBLE StaggeredGridLayoutManager(4, RecyclerView.VERTICAL)
val adapter = PhotosAdapter()
photosRecyclerView.adapter = adapter
photosRecyclerView.itemAnimator = null
adapter.setItems(model.items)
} }
} }
class PhotosAdapter : CommonRecyclerAdapter<PhotosViewHolder, PhotoModel>() {
override val vhKlazz = PhotosViewHolder::class
override fun getVhLayout(): Int = R.layout.photo_preview_viewholder
}
class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) {
@BindView(R.id.photo_preview_imageview) lateinit var photoPreview: RoundedImageView
override fun onViewBound(model: PhotoModel) {
model.resolutionList.lowelest()?.let {
Picasso.get()
.load(it.url)
.onlyScaleDown()
.fit()
.into(photoPreview)
}}
}
fun List<PhotoResolutionModel>.lowelest() =
this.minBy { it.resWidth * it.resHeight }
\ No newline at end of file
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
android:text="TextView" /> android:text="TextView" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/photos_recycler_iew" android:id="@+id/photos_recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
......
<?xml version="1.0" encoding="utf-8"?>
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/photo_preview_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_margin="4dp"
android:orientation="vertical"
app:image_corner_radius="4dp">
</com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView>
\ 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