-
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.
[MIN-49] feat: story 리사이클러 뷰 구현(#23)
- Loading branch information
Showing
12 changed files
with
209 additions
and
30 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
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
8 changes: 8 additions & 0 deletions
8
common/src/main/java/com/example/common/data/dto/StoryListResponse.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,8 @@ | ||
package com.example.common.data.dto | ||
|
||
import com.example.common.data.entity.StoryWithDate | ||
|
||
data class StoryListResponse( | ||
val success: Boolean, | ||
val data: List<StoryWithDate> | ||
) |
22 changes: 7 additions & 15 deletions
22
common/src/main/java/com/example/common/data/entity/HomeData.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
7 changes: 7 additions & 0 deletions
7
common/src/main/java/com/example/common/data/entity/StoryWithDate.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,7 @@ | ||
package com.example.common.data.entity | ||
|
||
data class StoryWithDate( | ||
val year : String, | ||
val month : String, | ||
val posts : List<Story> | ||
) |
58 changes: 58 additions & 0 deletions
58
story/src/main/java/com/najudoryeong/mineme/story/StoryAdapter.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,58 @@ | ||
package com.najudoryeong.mineme.story | ||
|
||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.example.common.data.entity.Story | ||
import com.najudoryeong.mineme.common_ui.databinding.ItemStoryBinding | ||
import com.najudoryeong.mineme.story.databinding.TestStoryBinding | ||
|
||
|
||
class StoryAdapter : ListAdapter<StoryModel, RecyclerView.ViewHolder>(StoryDiffCallback()) { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { | ||
return StoryViewHolder( | ||
TestStoryBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { | ||
if (holder is StoryViewHolder){ | ||
val story = getItem(position) | ||
holder.bind(story) | ||
} | ||
} | ||
|
||
class StoryViewHolder(private val binding: TestStoryBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
fun bind(storyModel: StoryModel) { | ||
with(binding) { | ||
story = storyModel | ||
executePendingBindings() | ||
itemView.setOnClickListener { | ||
// story 상세보기 | ||
Log.d("testStory","상세보기 클릭") | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
private class StoryDiffCallback : DiffUtil.ItemCallback<StoryModel>() { | ||
override fun areItemsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { | ||
return oldItem === newItem | ||
} | ||
|
||
override fun areContentsTheSame(oldItem: StoryModel, newItem: StoryModel): Boolean { | ||
return oldItem == newItem | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
story/src/main/java/com/najudoryeong/mineme/story/StoryModel.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,8 @@ | ||
package com.najudoryeong.mineme.story | ||
|
||
data class StoryModel( | ||
val date: String, | ||
val postId: Int, | ||
val region: String, | ||
val thumbnailImage: String | ||
) |
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,18 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout 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"> | ||
|
||
<FrameLayout | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:padding="4dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".StoryFragment"> | ||
android:layout_height="match_parent"> | ||
|
||
<!-- TODO: Update blank fragment layout --> | ||
<TextView | ||
<androidx.core.widget.NestedScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:textSize="50dp" | ||
android:text="스토리부분" /> | ||
</FrameLayout> | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/recyclerView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_margin="16dp" | ||
android:clipToPadding="false" | ||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" | ||
app:spanCount="2" | ||
tools:listitem="@layout/test_story" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
|
||
</androidx.core.widget.NestedScrollView> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
</layout> |
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,67 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="story" | ||
type="com.najudoryeong.mineme.story.StoryModel" /> | ||
|
||
</data> | ||
|
||
|
||
<androidx.cardview.widget.CardView | ||
android:layout_margin="8dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="165dp" | ||
app:cardCornerRadius="8dp"> | ||
|
||
<FrameLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
|
||
<ImageView | ||
photoUrl="@{story.thumbnailImage}" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:scaleType="centerCrop" | ||
android:src="@drawable/img_profile" /> | ||
|
||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="top" | ||
android:background="#99C9C9C9"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:fontFamily="@font/cafe24_ssurround" | ||
android:padding="16dp" | ||
android:text="@{story.region}" | ||
android:textColor="#FFFFFF" | ||
android:textSize="14sp" /> | ||
|
||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:fontFamily="@font/cafe24_ssurround" | ||
android:gravity="end" | ||
android:padding="16dp" | ||
android:text="@{story.date}" | ||
android:textColor="#FFFFFF" | ||
android:textSize="14sp" /> | ||
|
||
|
||
</LinearLayout> | ||
|
||
</FrameLayout> | ||
</androidx.cardview.widget.CardView> | ||
</layout> |