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

sort albums by publish date

parent 0d2af45b
...@@ -73,7 +73,9 @@ class AlbumsContractModule @Inject constructor( ...@@ -73,7 +73,9 @@ class AlbumsContractModule @Inject constructor(
arrayListOf(fetchTopLevelAlbumsDb,fetchTopLevelAlbumsApi) arrayListOf(fetchTopLevelAlbumsDb,fetchTopLevelAlbumsApi)
) )
.doOnNext { Timber.d("got entity $it") } .doOnNext { Timber.d("got entity $it") }
.map { fromEntity(it,::fromEntity) } .map { fromEntity(it,::fromEntity).sortedByDescending{ album -> album.published } }
//endregion allAlbums //endregion allAlbums
//region concrete Albums //region concrete Albums
......
...@@ -10,6 +10,8 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyc ...@@ -10,6 +10,8 @@ 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.presentation.screen.settings.util.CommonViewHolder
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import java.text.SimpleDateFormat
import java.util.*
/** /**
...@@ -31,12 +33,17 @@ class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumP ...@@ -31,12 +33,17 @@ class AlbumsHeaderAdapter : CommonRecyclerAdapter<AlbumsHeaderViewHolder, AlbumP
class AlbumsHeaderViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(itemView) { 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.preview) lateinit var preview:ImageView
@BindView(R.id.card_title) lateinit var articleTitle:TextView @BindView(R.id.card_title) lateinit var articleTitle:TextView
@BindView(R.id.card_updated) lateinit var articleDate:TextView @BindView(R.id.card_updated) lateinit var articleDate:TextView
override fun onViewBound(model: AlbumPreviewModel) { override fun onViewBound(model: AlbumPreviewModel) {
articleTitle.text = model.title articleTitle.text = model.title
articleDate.text = dateFormatter.format(model.published)
Glide.with(itemView) Glide.with(itemView)
.load(model.previewUrl) .load(model.previewUrl)
.centerCrop() .centerCrop()
......
...@@ -41,6 +41,9 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>( ...@@ -41,6 +41,9 @@ class AlbumCardViewHolder(itemView: View) : CommonViewHolder<AlbumPreviewModel>(
articleTitle.text = model.title articleTitle.text = model.title
articleTitle.text = model.title articleTitle.text = model.title
articleDate.text = dateFormatter.format(model.published)
Glide.with(preview) Glide.with(preview)
.load(model.previewUrl) .load(model.previewUrl)
.centerCrop() .centerCrop()
......
...@@ -4,7 +4,11 @@ ...@@ -4,7 +4,11 @@
android:layout_width="284dp" android:layout_width="284dp"
android:layout_height="189dp" android:layout_height="189dp"
android:layout_margin="16dp" android:layout_margin="16dp"
app:cardElevation="0dp" app:cardElevation="8dp"
app:cardMaxElevation="12dp"
android:padding="16dp"
app:cardCornerRadius="4dp"
app:cardForegroundColor="#00000000" app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false" app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false"> app:cardUseCompatPadding="false">
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:includeFontPadding="false" android:includeFontPadding="false"
android:text="Дом №1"
android:textAlignment="center" /> android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
...@@ -49,7 +48,6 @@ ...@@ -49,7 +48,6 @@
android:gravity="center" android:gravity="center"
android:includeFontPadding="false" android:includeFontPadding="false"
android:maxLines="1" android:maxLines="1"
android:text="14 декабря 2019г"
android:textAlignment="center" /> android:textAlignment="center" />
<FrameLayout <FrameLayout
......
...@@ -4,9 +4,11 @@ ...@@ -4,9 +4,11 @@
android:layout_width="142dp" android:layout_width="142dp"
android:layout_height="94dp" android:layout_height="94dp"
android:layout_margin="16dp" android:layout_margin="16dp"
android:padding="8dp"
app:cardCornerRadius="4dp"
app:cardElevation="4dp" app:cardElevation="4dp"
app:cardMaxElevation="8dp"
app:cardForegroundColor="#00000000" app:cardForegroundColor="#00000000"
app:cardMaxElevation="6dp"
app:cardPreventCornerOverlap="false" app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false" app:cardUseCompatPadding="false"
app:contentPadding="8dp"> app:contentPadding="8dp">
...@@ -34,7 +36,6 @@ ...@@ -34,7 +36,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
android:text="Дом №1"
android:textAlignment="center" /> android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
...@@ -47,7 +48,6 @@ ...@@ -47,7 +48,6 @@
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:text="14 декабря 2019г"
android:textAlignment="center" /> android:textAlignment="center" />
<FrameLayout <FrameLayout
......
<?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="284dp"
android:layout_height="189dp"
android:layout_margin="16dp"
app:cardElevation="4dp"
app:cardMaxElevation="8dp"
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/Header_TextView.Inverted_Header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:layout_marginBottom="4dp"
android:text="Дом №1"
android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView6"
style="@style/Common_Text.Inverted"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Последнее обновление"
android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/card_updated"
style="@style/Accent_Minor_TextView.DatePlaceHolder"
android:layout_width="match_parent"
android:layout_height="24dp"
android:layout_marginStart="64dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="64dp"
android:gravity="center"
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