-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#16 [ui] 홈 / to do 리사이클러뷰 #20
base: main
Are you sure you want to change the base?
Changes from all commits
5f7f4ea
5108078
f8cf833
e468ee6
6172448
beb5a7c
0a128bf
bd80b49
11ac57d
c659eb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.hous.housaoslab.ui.home.model | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.hous.housaoslab.databinding.ItemHomeToDoBinding | ||
|
||
class ToDoAdapter : RecyclerView.Adapter<ToDoAdapter.ToDoViewHolder>() { | ||
val toDoList = mutableListOf<ToDoData>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ToDoViewHolder { | ||
val binding = | ||
ItemHomeToDoBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
parent, | ||
false | ||
) | ||
return ToDoViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: ToDoViewHolder, position: Int) { | ||
holder.onBind(toDoList[position]) | ||
} | ||
|
||
override fun getItemCount(): Int = toDoList.size | ||
|
||
class ToDoViewHolder( | ||
private val binding: ItemHomeToDoBinding | ||
) : RecyclerView.ViewHolder(binding.root) { | ||
fun onBind(data: ToDoData) { | ||
binding.tvHomeToDo.text = data.rules | ||
} | ||
} | ||
Comment on lines
+27
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. item 쪽엔 data로 variable을 받는다고 선언했지만 사용하지 않았으며, 현재로선 후자의 방식이 나아 보이지만, api가 나오면 data class 중 하나의 값을 바인딩할 것 같으니 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 데이터바인딩을 사용해주세요!! ㅋㅋㅋㅋ |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hous.housaoslab.ui.home.model | ||
|
||
data class ToDoData( | ||
val rules: String | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="#5E9EFF" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M19,3L5,3c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.11,0 2,-0.9 2,-2L21,5c0,-1.1 -0.89,-2 -2,-2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" /> | ||
</vector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:tint="#5E9EFF" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path | ||
android:fillColor="@android:color/white" | ||
android:pathData="M19,5v14H5V5h14m0,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" /> | ||
</vector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:drawable="@drawable/ic_blue_line_check_box" android:state_checked="false" /> | ||
<item android:drawable="@drawable/ic_blue_fill_check_box" android:state_checked="true" /> | ||
</selector> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ | |
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv_home_rules" | ||
android:layout_width="165dp" | ||
android:layout_width="170dp" | ||
android:layout_height="172dp" | ||
Comment on lines
+59
to
60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrap과 0dp를 사용해서 container 크기를 조정해주세요!! |
||
android:layout_marginTop="12dp" | ||
android:background="@drawable/shape_blue_bg_fill_16_rectangle" | ||
|
@@ -70,5 +70,34 @@ | |
app:layout_constraintTop_toBottomOf="@id/tv_home_rules" | ||
tools:listitem="@layout/item_home_rules" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_to_do" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="28dp" | ||
android:text="@string/home_to_do" | ||
android:textColor="@color/black" | ||
android:textSize="16sp" | ||
android:textStyle="bold" | ||
app:layout_constraintStart_toStartOf="@id/rv_home_to_do" | ||
app:layout_constraintTop_toBottomOf="@id/rv_home_coming_up" /> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv_home_to_do" | ||
android:layout_width="170dp" | ||
android:layout_height="172dp" | ||
Comment on lines
+87
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기두요!! |
||
android:layout_marginTop="12dp" | ||
android:layout_marginEnd="20dp" | ||
android:background="@drawable/shape_blue_bg_fill_16_rectangle" | ||
android:orientation="vertical" | ||
android:overScrollMode="never" | ||
android:paddingHorizontal="20dp" | ||
android:paddingTop="12dp" | ||
android:paddingBottom="20dp" | ||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_home_to_do" | ||
tools:listitem="@layout/item_home_to_do" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="todoData" | ||
type="com.hous.housaoslab.ui.home.model.ToDoData" /> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:paddingTop="9dp"> | ||
|
||
<CheckBox | ||
android:id="@+id/cb_home_to_do" | ||
android:layout_width="16dp" | ||
android:layout_height="16dp" | ||
Comment on lines
+20
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 wrap_content나 0dp 사용하기! |
||
android:background="@drawable/sel_home_to_do_check_box" | ||
android:button="@android:color/transparent" | ||
android:checked="false" | ||
app:layout_constraintBottom_toBottomOf="@id/tv_home_to_do" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="@id/tv_home_to_do" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_to_do" | ||
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재 fragment_home 에도 tv_home_to_do 라는 id가 사용되고 있습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 한가지 궁금한 점이 다른 layout인데 textView id값앞에 where을 다르게 해야하는 이유가 있을까요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @murjune 일단 늦어서 죄송합니다. 형 말 듣고 생각해보니까, dataBinding, ViewBinding 은 한 레이아웃만 보니까 굳이 달라야 할 이유가 없네요...? 다른분들 생각은 어떤가요?? |
||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="10dp" | ||
android:textColor="@color/black" | ||
android:textSize="13sp" | ||
android:textStyle="bold" | ||
app:layout_constraintStart_toEndOf="@id/cb_home_to_do" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:text="청소기 돌리기" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapter는 model 패키지 보다 home 패키지 안에 있는 것이 좋을 것 같습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 맞아 이거 말해주고 싶었는데 ㅋㅋㅋ
첨언으로 model패키지는 ui패키지가 아니라 data패키지에 넣어주시면 좋을 것 같슴니다!!
MainActivity도 ui.home이 아닌 ui패키지에 넣어주시면 좋을 것 같숩니다 ㅎ ㅅ ㅎ