-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4710667
commit 6539a99
Showing
17 changed files
with
212 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
common/src/main/java/com/peterkrauz/grimoire/common/extension/ViewGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.peterkrauz.grimoire.common.extension | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.LayoutRes | ||
|
||
fun ViewGroup.inflate(@LayoutRes layoutId: Int): View { | ||
return LayoutInflater.from(context).inflate(layoutId, this, false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
domain/src/main/java/com/peterkrauz/grimoire/domain/entity/Arc.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
presentation/home/src/main/java/com/peterkrauz/grimoire/presentation/home/ArcViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.peterkrauz.grimoire.presentation.home | ||
|
||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView.ViewHolder | ||
import com.peterkrauz.grimoire.domain.entity.Arc | ||
import kotlinx.android.synthetic.main.item_arc.view.* | ||
|
||
class ArcViewHolder(view: View) : ViewHolder(view) { | ||
fun bind(arc: Arc) { | ||
itemView.run { | ||
textViewArcName.text = arc.title | ||
textViewArcDescription.text = arc.description | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
presentation/home/src/main/java/com/peterkrauz/grimoire/presentation/home/ArcsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.peterkrauz.grimoire.presentation.home | ||
|
||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.peterkrauz.grimoire.common.extension.inflate | ||
import com.peterkrauz.grimoire.domain.entity.Arc | ||
|
||
class ArcsAdapter : ListAdapter<Arc, ArcViewHolder>(ArcDiffCallback) { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ArcViewHolder { | ||
return ArcViewHolder(parent.inflate(R.layout.item_arc)) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ArcViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
|
||
private object ArcDiffCallback : DiffUtil.ItemCallback<Arc>() { | ||
override fun areItemsTheSame(old: Arc, new: Arc): Boolean { | ||
return old.id == new.id | ||
} | ||
|
||
override fun areContentsTheSame(old: Arc, new: Arc): Boolean { | ||
return old == new | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
presentation/home/src/main/java/com/peterkrauz/grimoire/presentation/home/ArcsState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.peterkrauz.grimoire.presentation.home | ||
|
||
enum class ArcsState { | ||
IDLE | ||
IDLE, LOADING | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="8dp" | ||
app:cardUseCompatPadding="true"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="20dp"> | ||
|
||
<TextView | ||
android:id="@+id/textViewArcName" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/kumbh_sans_bold" | ||
android:textSize="21sp" | ||
android:maxLines="1" | ||
android:layout_marginTop="4dp" | ||
tools:text="There and back again" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/textViewArcDescription" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:fontFamily="@font/kumbh_sans_regular" | ||
android:textSize="16sp" | ||
android:maxLines="3" | ||
android:ellipsize="middle" | ||
tools:text="Once upon a time..." | ||
app:layout_constraintTop_toBottomOf="@id/textViewArcName" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
<Button | ||
style="@style/Widget.MaterialComponents.Button.TextButton" | ||
android:id="@+id/buttonReadMore" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/read_more" | ||
app:layout_constraintTop_toBottomOf="@id/textViewArcDescription" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</com.google.android.material.card.MaterialCardView> |