Commit 598c2505 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add fix layout and added header adapter

parent a098be97
......@@ -122,7 +122,7 @@ data class ImageAlbumRaw(
data class GalleryImageRaw(
val id:Int,
val title:String,
val description:String,
val description:String?,
val sort:Int,
val album_id:Int,
val resolutions:List<ResolutionRaw>
......
......@@ -2,10 +2,7 @@ package com.biganto.visual.roompark.data.repository.db.requrey.model
import com.biganto.visual.roompark.data.repository.db.requrey.PhotoResolutions
import com.biganto.visual.roompark.data.repository.db.requrey.utils.PhotoResolutionsConverter
import io.requery.Convert
import io.requery.Entity
import io.requery.Key
import io.requery.Persistable
import io.requery.*
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
......@@ -17,6 +14,7 @@ interface GalleryPhoto : Persistable {
@get:Key
val id:Int
val title:String
@get:Nullable
val description:String
val sort:Int
val album_id:Int
......
......@@ -43,7 +43,6 @@ import javax.inject.Singleton
AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{
fun authC(): AuthContract
fun feedsC(): FeedsContract
......@@ -51,7 +50,6 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun feedsAlb(): DevProgressContract
fun provideLocal():ILocalStore
fun provideApi():IRoomParkApi
......
......@@ -14,6 +14,7 @@ data class AlbumPreviewModel(
val parentId:Int,
val title:String,
val published: Date,
val previewUrl:String,
val isRead:Boolean
)
......@@ -39,7 +40,7 @@ data class PhotoListModel(val items:List<PhotoModel>)
data class PhotoModel(
val photoId:Int,
val albumId:Int,
val description:String,
val description:String?,
val sort:Int,
val resolutionList:List<PhotoResolutionModel>
......@@ -59,6 +60,7 @@ fun fromEntity(entity: ImageAlbumEntity):AlbumPreviewModel =
parentId = -1,
title = entity.title,
published = entity.published,
previewUrl = entity.preview,
isRead = false
)
......
......@@ -11,8 +11,8 @@ 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.util.AlbumsHeaderAdapter
import com.biganto.visual.roompark.presentation.screen.favorites.util.AlbumListAdapter
import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter
import com.biganto.visual.roompark.util.view_utils.grid.CeilsDecoration
import javax.inject.Inject
......@@ -46,7 +46,7 @@ class AlbumsScreenController :
headersRecyclerView.isNestedScrollingEnabled = true
headersRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false)
headersRecyclerView.adapter = AlbumsPreviewAdapter()
headersRecyclerView.adapter = AlbumsHeaderAdapter()
headersRecyclerView.itemAnimator = null
if (headersRecyclerView.itemDecorationCount == 0)
......@@ -111,11 +111,11 @@ class AlbumsScreenController :
showError(viewState.exception)
private fun render(viewState: AlbumsScreenViewState.AlbumsListLoaded) {
(headersRecyclerView.adapter as AlbumsPreviewAdapter).setItems(viewState.list)
(headersRecyclerView.adapter as AlbumsHeaderAdapter).setItems(viewState.list)
headersRecyclerView.let {
it.scrollToPosition(
(it.adapter as AlbumsPreviewAdapter).getItemPosition(viewState.selectedAlbumId)
(it.adapter as AlbumsHeaderAdapter).getItemPosition(viewState.selectedAlbumId)
)
}
}
......
package com.biganto.visual.roompark.presentation.screen.albums.util
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumPreviewModel>() {
override val vhKlazz = AlbumsHeaderViewHolder::class
override fun getVhLayout(): Int = R.layout.album_header_preview_viewholder
fun getItemPosition(model: AlbumPreviewModel) = getItemPosition(model.albumId)
fun getItemPosition(modelId: Int) = list.indexOfFirst {
it.albumId == modelId
}
}
class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(itemView) {
private val dateFormatter = SimpleDateFormat("dd MMMM yyyy", Locale("ru"))
@BindView(R.id.preview) lateinit var preview:ImageView
@BindView(R.id.card_title) lateinit var articleTitle:TextView
@BindView(R.id.card_updated) lateinit var articleDate:TextView
override fun onViewBound(model: AlbumPreviewModel) {
// articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
Picasso.get()
.load(model.previewUrl)
.centerCrop()
.fit()
.into(preview)
//
}
}
......@@ -19,16 +19,18 @@ import com.squareup.picasso.Picasso
*/
class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumSortedModel>() {
class AlbumListAdapter : CommonRecyclerAdapter<AlbumViewHolder, AlbumSortedModel>() {
override val vhKlazz = AlbumViewHolder::class
override fun getVhLayout(): Int = R.layout.date_album_viewholder
}
}
class AlbumViewHolder(itemView: View) : CommonViewHolder<AlbumSortedModel>(itemView) {
@BindView(R.id.date_title_textview) lateinit var albumTitle: MaterialTextView
@BindView(R.id.photos_recyclerview) lateinit var photosRecyclerView: RecyclerView
@BindView(R.id.date_title_textview)
lateinit var albumTitle: MaterialTextView
@BindView(R.id.photos_recyclerview)
lateinit var photosRecyclerView: RecyclerView
// @BindView(R.id.camStatusIcon) lateinit var camStatusIcon:ImageView
override fun onViewBound(model: AlbumSortedModel) {
......@@ -58,7 +60,7 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
model.resolutionList.lowelest()?.let {
Picasso.get()
.load(it.url)
.onlyScaleDown()
.centerCrop()
.fit()
.into(photoPreview)
}}
......
......@@ -14,6 +14,7 @@ import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.domain.model.WebCamModel
import com.biganto.visual.roompark.presentation.screen.albums.AlbumsScreenController
import com.biganto.visual.roompark.presentation.screen.article.ArticleScreenController
import com.biganto.visual.roompark.presentation.screen.feed_list.ArticlesScreenController
import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter
......@@ -194,7 +195,11 @@ class FeedsScreenController :
}
private fun render(viewState: FeedsScreenViewState.ToAlbum) {
TODO("to album screen")
router.pushController(
RouterTransaction.with(AlbumsScreenController(viewState.albumId))
.popChangeHandler(FadeChangeHandler())
.pushChangeHandler(FadeChangeHandler())
)
}
......
......@@ -8,6 +8,7 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
......@@ -39,6 +40,11 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
// articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
// Picasso.ge1preview)
articleTitle.text = model.title
Picasso.get()
.load(model.previewUrl)
.centerCrop()
.fit()
.into(preview)
}
}
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="142dp"
android:layout_height="94dp"
android:layout_margin="16dp"
app:cardElevation="4dp"
app:cardMaxElevation="6dp"
app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<com.biganto.visual.roompark.util.view_utils.image_view.RoundedImageView
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:background="@drawable/default_image_placeholder"
android:cropToPadding="true"
android:foreground="@color/colorOpacityBackground"
android:scaleType="centerCrop"
app:image_corner_radius="4dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_title"
style="@style/Default_TextView.Inverted_Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginBottom="4dp"
android:includeFontPadding="false"
android:text="Дом №1"
android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_updated"
style="@style/Accent_Minor_TextView.Inverted"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:includeFontPadding="false"
android:maxLines="1"
android:text="14 декабря 2019г"
android:textAlignment="center" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
\ 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