-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
14 changed files
with
273 additions
and
1 deletion.
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
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoAdapter.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,60 @@ | ||
package com.ssjm.sw_hackathon.home.recycler | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.ssjm.sw_hackathon.R | ||
import com.ssjm.sw_hackathon.databinding.ItemTodoOfHomeBinding | ||
|
||
class HomeTodoAdapter (private val context: Context, | ||
) : RecyclerView.Adapter<HomeTodoAdapter.HomeTodoViewHolder>() { | ||
|
||
var items = mutableListOf<HomeTodoItem>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : | ||
HomeTodoViewHolder { | ||
|
||
val view = LayoutInflater.from(context).inflate(R.layout.item_todo_of_home, parent, false) | ||
|
||
return HomeTodoViewHolder(ItemTodoOfHomeBinding.bind(view)) | ||
} | ||
|
||
override fun getItemCount(): Int = items.size | ||
|
||
override fun onBindViewHolder(holder: HomeTodoViewHolder, position: Int) { | ||
holder.bind(items[position]) | ||
|
||
// 링크 아이템 클릭 시 | ||
/*holder.itemView.setOnClickListener { | ||
onClickLinkItem(items[position].memoNum) | ||
}*/ | ||
} | ||
|
||
inner class HomeTodoViewHolder(private val binding: ItemTodoOfHomeBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(item: HomeTodoItem) { | ||
|
||
// 이미지 | ||
val imgResourceName = "img_todo_" + item.coverImage | ||
val iconResourceId = context.resources.getIdentifier(imgResourceName, "drawable", context.packageName) | ||
binding.imgTodoCover.setImageResource(iconResourceId) | ||
|
||
// 내용 | ||
binding.textTodoContent.text = item.content | ||
|
||
// 기간 | ||
binding.textTodoPeriod.text = item.period | ||
|
||
// 요일 리스트 보여줄 recyclerview 세팅 | ||
binding.recyclerviewHomeTodoDay.apply { | ||
adapter = HomeTodoDayAdapter(context).build(item.day) | ||
layoutManager = | ||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) | ||
} | ||
} | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoDayAdapter.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,46 @@ | ||
package com.ssjm.sw_hackathon.home.recycler | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.ssjm.sw_hackathon.R | ||
import com.ssjm.sw_hackathon.databinding.ItemTodoDayBinding | ||
import com.ssjm.sw_hackathon.databinding.ItemTodoOfHomeBinding | ||
|
||
class HomeTodoDayAdapter (private val context: Context, | ||
) : RecyclerView.Adapter<HomeTodoDayAdapter.HomeTodoDayViewHolder>() { | ||
|
||
var items = mutableListOf<String>() | ||
|
||
fun build(days: MutableList<String>?): HomeTodoDayAdapter { | ||
if(days != null) | ||
items = days | ||
|
||
return this | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : | ||
HomeTodoDayViewHolder { | ||
|
||
val view = LayoutInflater.from(context).inflate(R.layout.item_todo_day, parent, false) | ||
|
||
return HomeTodoDayViewHolder(ItemTodoDayBinding.bind(view)) | ||
} | ||
|
||
override fun getItemCount(): Int = items.size | ||
|
||
override fun onBindViewHolder(holder: HomeTodoDayViewHolder, position: Int) { | ||
holder.bind(items[position]) | ||
|
||
} | ||
|
||
inner class HomeTodoDayViewHolder(private val binding: ItemTodoDayBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(item: String) { | ||
binding.textTodoDay.text = item | ||
} | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/com/ssjm/sw_hackathon/home/recycler/HomeTodoItem.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.ssjm.sw_hackathon.home.recycler | ||
|
||
import android.graphics.drawable.Drawable | ||
|
||
data class HomeTodoItem( | ||
val coverImage: String, | ||
val content: String, | ||
val period: String, | ||
val day: MutableList<String> | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
app/src/main/res/layouts/home/drawable/shape_todo_cover_radius.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:padding="10dp" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="@color/white"/> | ||
<corners | ||
android:radius="12dp"/> | ||
|
||
</shape> |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:padding="10dp" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="@color/main_color_2"/> | ||
<corners | ||
android:radius="6dp" /> | ||
|
||
</shape> |
10 changes: 10 additions & 0 deletions
10
app/src/main/res/layouts/home/drawable/shape_todo_title.xml
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:padding="10dp" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="#CC000000"/> | ||
<corners | ||
android:radius="7dp" /> | ||
|
||
</shape> |
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,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/text_todo_day" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginRight="8dp" | ||
android:paddingVertical="4dp" | ||
android:paddingHorizontal="8dp" | ||
android:text="월" | ||
android:textSize="18sp" | ||
android:textColor="@color/black03" | ||
android:textStyle="bold" | ||
android:background="@drawable/shape_todo_day"/> |
61 changes: 61 additions & 0 deletions
61
app/src/main/res/layouts/home/layout/item_todo_of_home.xml
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,61 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="191dp" | ||
android:layout_height="233dp" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_marginRight="16dp"> | ||
|
||
<ImageView | ||
android:id="@+id/img_todo_cover" | ||
android:layout_width="191dp" | ||
android:layout_height="233dp" | ||
android:scaleType="centerCrop" | ||
android:clipToOutline="true" | ||
android:src="@drawable/img_todo_note1" | ||
android:background="@drawable/shape_todo_cover_radius"/> | ||
|
||
<!-- 실천사항 내용 --> | ||
<TextView | ||
android:id="@+id/text_todo_content" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginLeft="14dp" | ||
android:paddingVertical="6dp" | ||
android:paddingHorizontal="10dp" | ||
android:text="노트에 필사하기" | ||
android:textStyle="bold" | ||
android:textSize="16sp" | ||
android:textColor="@color/white" | ||
android:background="@drawable/shape_todo_title" | ||
android:layout_alignParentTop="true" | ||
android:layout_alignParentStart="true"/> | ||
|
||
<!-- 실천 기간 --> | ||
<TextView | ||
android:id="@+id/text_todo_period" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="6dp" | ||
android:layout_marginLeft="14dp" | ||
android:text="66일째 실천중" | ||
android:textStyle="bold" | ||
android:textSize="16sp" | ||
android:textColor="@color/main_color_2" | ||
android:layout_below="@id/text_todo_content" | ||
android:layout_alignParentStart="true"/> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/recyclerview_home_todo_day" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginLeft="14dp" | ||
android:layout_marginBottom="16dp" | ||
android:layout_alignParentBottom="true" | ||
android:layout_alignParentStart="true" | ||
android:orientation="horizontal" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
tools:listitem="@layout/item_todo_day"/> | ||
|
||
</RelativeLayout> |