Skip to content

Commit

Permalink
Updated Photos View with StaggeredGridLayout Way
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaraki596 committed Jan 26, 2021
1 parent 082e4b6 commit 9580381
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class PhotosActivity : AppCompatActivity() {
when (state) {
is State.Loading -> binding.progressHorizontal.show()
is State.Success -> {
adapter.submitList(state.data.take(6))
//Only taking n photos at a given time
adapter.submitList(state.data.take(10))
binding.progressHorizontal.hide()
}
is State.Error -> {
Expand All @@ -81,6 +82,7 @@ class PhotosActivity : AppCompatActivity() {

private fun setUpRecylerView() {
binding.recyclerPhotos.adapter = adapter
binding.recyclerPhotos.setHasFixedSize(true)
}

private fun setupToolbar() {
Expand Down
35 changes: 12 additions & 23 deletions app/src/main/res/layout/row_item_photos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,21 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_row_item"
android:layout_width="match_parent"
android:layout_height="@dimen/dimen_photos_height"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardCornerRadius="@dimen/dimen_card_radius"
app:cardElevation="@dimen/dimen_card_elevation">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
app:cardCornerRadius="@dimen/cardview_default_radius"
app:cardElevation="@dimen/cardview_default_elevation">


<ImageView
android:id="@+id/image_photos"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/cover_photo_content_desc"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:srcCompat="@tools:sample/backgrounds/scenic[10]" />

<ImageView
android:id="@+id/image_photos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/cover_photo_content_desc"
android:scaleType="fitXY"
tools:srcCompat="@tools:sample/backgrounds/scenic[10]" />


</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

</com.google.android.material.card.MaterialCardView>

0 comments on commit 9580381

Please sign in to comment.