Commit 948b06c0 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

feeds preview block

parent 089f00bc
......@@ -2,12 +2,15 @@ package com.biganto.visual.roompark.presentation.screen.feeds
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import butterknife.BindView
import com.biganto.visual.roompark.R
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.ArticlesPreviewAdapter
import com.google.android.material.tabs.TabLayout
import com.jakewharton.rxbinding3.material.selections
import io.reactivex.Observable
......@@ -38,6 +41,17 @@ class FeedsScreenController :
@BindView(R.id.feedsTabs)
lateinit var feedsTabs:TabLayout
@BindView(R.id.feedsRecyclerView)
lateinit var feedsRecyclerView:RecyclerView
private fun bindRecycler(){
feedsRecyclerView.isNestedScrollingEnabled = true
feedsRecyclerView.layoutManager =
LinearLayoutManager(activity, RecyclerView.VERTICAL, false)
feedsRecyclerView.adapter = ArticlesPreviewAdapter()
feedsRecyclerView.itemAnimator = null
}
private var storedFeedsList:List<FeedModel> = arrayListOf()
......@@ -46,7 +60,7 @@ class FeedsScreenController :
override fun onViewBound(v: View) {
bindRecycler()
}
override fun render(viewState: FeedsScreenViewState) {
......@@ -84,6 +98,7 @@ class FeedsScreenController :
private fun render(viewState: FeedsScreenViewState.GetFeedArticlesPreview){
(feedsRecyclerView.adapter as ArticlesPreviewAdapter).addItems(viewState.items)
snackbar.showSnackBar(viewState.items.first().announce)
}
......
......@@ -22,10 +22,17 @@ class ArticlesPreviewAdapter : RecyclerView.Adapter<ArticlePreviewViewHolder>()
private var list: MutableList<ArticlePreviewModel> = mutableListOf()
fun addItems(list:List<ArticlePreviewModel>){
this.list.clear()
this.list.addAll(list)
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ArticlePreviewViewHolder =
ArticlePreviewViewHolder(
LayoutInflater.from(parent.context)
.inflate(com.biganto.visual.roompark.R.layout.feed_direct_viewholder, parent, false)
.inflate(R.layout.feed_viewholder, parent, false)
)
override fun getItemCount(): Int = list.size
......@@ -45,7 +52,6 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
@BindView(R.id.imageHolder) lateinit var preview:ImageView
@BindView(R.id.feed_date_text_view) lateinit var articleDate:TextView
@BindView(R.id.feed_title_info_text_view) lateinit var articleTitle:TextView
@BindView(R.id.feed_text_info_text_view) lateinit var articleDescription:TextView
@BindView(R.id.feed_read) lateinit var articleIsRead:View
......@@ -56,7 +62,6 @@ class ArticlePreviewViewHolder(itemView: View) : RecyclerView.ViewHolder(itemVie
fun bindModel(model: ArticlePreviewModel){
articleDate.text = dateFormatter.format(model.published)
articleTitle.text = model.title
articleDescription.text = model.announce
articleIsRead.setGone(model.isRead)
Picasso.get()
......
......@@ -4,15 +4,16 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_height="wrap_content"
android:background="@color/colorFeedViewHolderBackground"
android:orientation="vertical"
android:paddingEnd="128dp">
android:orientation="vertical">
<com.biganto.visual.roompark.view_utils.image_view.RoundedImageView
android:id="@+id/imageHolder"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="@color/colorAccentSecondary"
app:image_corner_radius="4dp"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -31,7 +32,7 @@
android:id="@+id/feed_read"
android:layout_width="8dp"
android:layout_height="8dp"
android:layout_marginTop="2dp"
android:layout_marginTop="10dp"
android:background="@drawable/new_feed_icon"
android:visibility="visible"
app:layout_constraintStart_toStartOf="@+id/guideline"
......@@ -40,26 +41,33 @@
<TextView
android:id="@+id/feed_date_text_view"
style="@style/Feed.Notice"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:includeFontPadding="false"
android:text="22 / 02 / 2019"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/guideline"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/feed_title_info_text_view"
style="@style/Common_Text.Inverted"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginBottom="8dp"
android:includeFontPadding="false"
android:maxLines="3"
android:text="В «РУМЯНЦЕВО-ПАРК» ПРИСТУПИЛИ К МОНТАЖУ ОКОННЫХ БЛОКОВ"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline"
app:layout_constraintTop_toBottomOf="@+id/feed_date_text_view" />
app:layout_constraintStart_toEndOf="@+id/guideline"
app:layout_constraintTop_toBottomOf="@+id/feed_date_text_view"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="448dp"
android:layout_height="wrap_content"
android:background="@drawable/gradient_background_accent"
android:orientation="vertical"
android:paddingStart="16dp">
......@@ -14,32 +14,35 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#00000000"
app:tabMaxWidth="@dimen/feeds_tab_max_width"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabMaxWidth="@dimen/feeds_tab_max_width"
app:tabMode="scrollable" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/feedsRecyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
tools:listitem="@layout/feed_direct_viewholder"
app:layout_constraintBottom_toTopOf="@+id/feeds_divider"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feedsTabs" />
app:layout_constraintTop_toBottomOf="@+id/feedsTabs"
tools:listitem="@layout/feed_direct_viewholder" />
<include
android:id="@+id/feeds_divider"
layout="@layout/horizontal_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp"
android:background="@drawable/botttom_bar_shadow"
app:layout_constraintBottom_toTopOf="@+id/textView4" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feedsRecyclerView" />
<com.google.android.material.button.MaterialButton
android:id="@+id/textView4"
android:id="@+id/to_feed_articles"
style="@style/AllFeeds.News"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -47,5 +50,6 @@
android:gravity="center_vertical|end"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/feeds_divider" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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