Commit 56eaee29 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

add album card preview

parent 948b06c0
package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.domain.model.FeedsHeaderModel
import com.biganto.visual.roompark.domain.model.*
import io.reactivex.Single
import java.util.*
import javax.inject.Inject
......@@ -26,6 +23,8 @@ class FeedsInteractor @Inject constructor(
}
)
fun fetchAlbums(): Single<List<AlbumPreviewModel>> = Single.just(albumsPreviews)
private companion object {
......@@ -133,6 +132,33 @@ class FeedsInteractor @Inject constructor(
)
)
)
val albumsPreviews = listOf<AlbumPreviewModel>(
AlbumPreviewModel(
1,
2,
Date(3131231L),
"Dom 1",
"https://room-park.ru/assets/gallery_images/image_2600/00/00/02/764-1d9795.png",
false
),
AlbumPreviewModel(
1,
2,
Date(31312323421L),
"Dom 1",
"https://room-park.ru/assets/gallery_images/image_2600/00/00/02/626-8afd4a.jpeg",
false
),
AlbumPreviewModel(
1,
2,
Date(3131232131L),
"Dom 1",
"https://room-park.ru/assets/gallery_images/image_2600/00/00/02/573-1fa95c.jpeg",
false
)
)
}
}
......
......@@ -10,6 +10,7 @@ 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.domain.model.FeedModel
import com.biganto.visual.roompark.presentation.screen.feeds.utils.AlbumsPreviewAdapter
import com.biganto.visual.roompark.presentation.screen.feeds.utils.ArticlesPreviewAdapter
import com.google.android.material.tabs.TabLayout
import com.jakewharton.rxbinding3.material.selections
......@@ -44,21 +45,30 @@ class FeedsScreenController :
@BindView(R.id.feedsRecyclerView)
lateinit var feedsRecyclerView:RecyclerView
@BindView(R.id.dev_progress_recycler_view)
lateinit var devProgressRecyclerView:RecyclerView
private fun bindRecycler(){
feedsRecyclerView.isNestedScrollingEnabled = true
feedsRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
feedsRecyclerView.adapter = ArticlesPreviewAdapter()
feedsRecyclerView.itemAnimator = null
}
devProgressRecyclerView.isNestedScrollingEnabled = true
devProgressRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.HORIZONTAL, false)
devProgressRecyclerView.adapter = AlbumsPreviewAdapter()
devProgressRecyclerView.itemAnimator = null
}
private var storedFeedsList:List<FeedModel> = arrayListOf()
@Inject
override lateinit var injectedPresenter: FeedsScreenPresenter
override fun onViewBound(v: View) {
bindRecycler()
}
......@@ -69,6 +79,7 @@ class FeedsScreenController :
when(viewState){
is FeedsScreenViewState.Idle -> render(viewState)
is FeedsScreenViewState.FeedsPages -> render(viewState)
is FeedsScreenViewState.AlbumsPages-> render(viewState)
is FeedsScreenViewState.GetFeedArticlesPreview -> render(viewState)
}
}
......@@ -96,10 +107,12 @@ class FeedsScreenController :
storedFeedsList = viewState.items
}
private fun render(viewState: FeedsScreenViewState.AlbumsPages){
(devProgressRecyclerView.adapter as AlbumsPreviewAdapter).addItems(viewState.items)
}
private fun render(viewState: FeedsScreenViewState.GetFeedArticlesPreview){
(feedsRecyclerView.adapter as ArticlesPreviewAdapter).addItems(viewState.items)
snackbar.showSnackBar(viewState.items.first().announce)
}
private fun getComponent() = DaggerFeedsScreenComponent.factory()
......
......@@ -20,6 +20,10 @@ class FeedsScreenPresenter @Inject constructor(
override fun bindIntents() {
val fetchAlbums = interactor.fetchAlbums()
.map {FeedsScreenViewState.AlbumsPages(it) }
val fetchFeeds = interactor.fetchTopFeeds()
.map {FeedsScreenViewState.FeedsPages(it.feeds.toList()) }
......@@ -30,6 +34,7 @@ class FeedsScreenPresenter @Inject constructor(
val state = restoreStateObservable
.mergeWith(fetchFeeds)
.mergeWith(getFeedArticlesPreview)
.mergeWith(fetchAlbums)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......
package com.biganto.visual.roompark.presentation.screen.feeds
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.biganto.visual.roompark.domain.model.ArticlePreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
......@@ -12,5 +13,7 @@ import com.biganto.visual.roompark.domain.model.FeedModel
sealed class FeedsScreenViewState : BigantoBaseViewState() {
class Idle : FeedsScreenViewState()
class FeedsPages(val items:List<FeedModel>) : FeedsScreenViewState()
class AlbumsPages(val items:List<AlbumPreviewModel>) : FeedsScreenViewState()
class GetFeedArticlesPreview(val items:List<ArticlePreviewModel>) : FeedsScreenViewState()
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.feeds.utils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import butterknife.ButterKnife
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.domain.model.AlbumPreviewModel
import com.squareup.picasso.Picasso
import java.text.SimpleDateFormat
import java.util.*
/**
* Created by Vladislav Bogdashkin on 15.10.2019.
*/
class AlbumsPreviewAdapter : RecyclerView.Adapter<AlbumCardViewHolder>() {
private var list: MutableList<AlbumPreviewModel> = mutableListOf()
fun addItems(list:List<AlbumPreviewModel>){
this.list.clear()
this.list.addAll(list)
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AlbumCardViewHolder =
AlbumCardViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.album_preview_card_viewholder, parent, false)
)
override fun getItemCount(): Int = list.size
override fun onBindViewHolder(holder: AlbumCardViewHolder, position: Int) {
holder.bindModel(list[position])
}
}
class AlbumCardViewHolder(itemView: View) : RecyclerView.ViewHolder(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
init {
ButterKnife.bind(this, itemView)
}
fun bindModel(model: AlbumPreviewModel){
articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
Picasso.get()
.load(model.previewUrl)
.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="284dp"
android:layout_height="189dp"
app:cardElevation="0dp"
app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<com.biganto.visual.roompark.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="@drawable/catalog_item_mask"
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
<?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="2dp"
app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<com.biganto.visual.roompark.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: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="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="8dp"
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
......@@ -3,13 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="284dp"
android:layout_height="189dp"
android:layout_margin="16dp"
app:cardElevation="0dp"
app:cardForegroundColor="#00000000"
app:cardPreventCornerOverlap="false"
app:cardUseCompatPadding="false">
<com.biganto.visual.roompark.view_utils.image_view.RoundedImageView
android:id="@+id/imageView"
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
......@@ -25,7 +26,7 @@
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/textView5"
android:id="@+id/card_title"
style="@style/Header_TextView.Inverted_Header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -43,7 +44,7 @@
android:textAlignment="center" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/button"
android:id="@+id/card_updated"
style="@style/Accent_Minor_TextView.DatePlaceHolder"
android:layout_width="match_parent"
android:layout_height="24dp"
......
......@@ -27,6 +27,7 @@
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:itemCount="3"
app:layout_constraintTop_toBottomOf="@+id/feedsTabs"
tools:listitem="@layout/feed_direct_viewholder" />
......
......@@ -2,6 +2,7 @@
<androidx.core.widget.NestedScrollView
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:layout_width="match_parent"
android:layout_height="match_parent"
>
......@@ -33,13 +34,15 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/dev_progress_recycler_view"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dev_progress_header" />
app:layout_constraintTop_toBottomOf="@+id/dev_progress_header"
tools:itemCount="3"
tools:listitem="@layout/estate_card_viewholder" />
<androidx.recyclerview.widget.RecyclerView
......
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