-
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.
[ADD] #3 : Add askList Item at home view
- Loading branch information
Showing
7 changed files
with
408 additions
and
147 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
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/teamhousing/housing/ui/home/adapter/HomeAskListAdapter.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,42 @@ | ||
package com.teamhousing.housing.ui.home.adapter | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.teamhousing.housing.R | ||
import com.teamhousing.housing.databinding.RvItemHomeAskListBinding | ||
import com.teamhousing.housing.vo.HomeAskListData | ||
|
||
class HomeAskListAdapter(private val context: Context) : RecyclerView.Adapter<HomeAskListViewHolder>() { | ||
var data = mutableListOf<HomeAskListData>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeAskListViewHolder { | ||
val binding : RvItemHomeAskListBinding = DataBindingUtil.inflate( | ||
LayoutInflater.from(parent.context), | ||
R.layout.rv_item_home_ask_list, | ||
parent, | ||
false | ||
) | ||
|
||
return HomeAskListViewHolder( | ||
binding | ||
) | ||
} | ||
|
||
override fun onBindViewHolder(holder: HomeAskListViewHolder, position: Int) { | ||
data[position].let{ | ||
holder.bind(it) | ||
} | ||
} | ||
|
||
override fun getItemCount(): Int = data.size | ||
|
||
} | ||
|
||
class HomeAskListViewHolder(val binding:RvItemHomeAskListBinding) : RecyclerView.ViewHolder(binding.root){ | ||
fun bind(item : HomeAskListData){ | ||
binding.item = item | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/teamhousing/housing/util/BindingAdapter.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,24 @@ | ||
package com.teamhousing.housing.util | ||
|
||
|
||
import android.widget.TextView | ||
import androidx.databinding.BindingAdapter | ||
|
||
object BindingAdapter { | ||
|
||
@JvmStatic | ||
@BindingAdapter("setProgress") | ||
fun TextView.setProgress(progress: Int) { | ||
text = when (progress) { | ||
0 -> { | ||
"νμΈ μ " | ||
} | ||
1 -> { | ||
"νμΈ μ€" | ||
} | ||
else -> { | ||
"ν΄κ²° μλ£" | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/teamhousing/housing/vo/HomeAskListData.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.teamhousing.housing.vo | ||
|
||
data class HomeAskListData ( | ||
val category : String, | ||
val title : String, | ||
val contents : String, | ||
val progress : Int | ||
) |
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,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<solid android:color="@color/primary_black"/> | ||
<corners android:radius="1000dp"/> | ||
</shape> |
Oops, something went wrong.