-
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
Areeb Shaikh
committed
Nov 18, 2024
1 parent
afc89de
commit 4b55bd8
Showing
12 changed files
with
322 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/bignerdranch/android/listr/naughty/NaughtyAdapter.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,32 @@ | ||
package com.bignerdranch.android.listr.naughty | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bignerdranch.android.listr.databinding.NaughtyListItemBinding import com.bignerdranch.android.listr.databinding.NiceListItemBinding | ||
import com.bignerdranch.android.listr.nice.NaughtyData | ||
|
||
|
||
class NaughtyAdapter(val messages: List<NaughtyData>): RecyclerView.Adapter<NaughtyAdapter.NaughtyViewHolder>() { | ||
|
||
inner class NaughtyViewHolder(private val binding: NaughtyListItemBinding): RecyclerView.ViewHolder(binding.root) { | ||
fun bind(naughtyData: NaughtyData) { | ||
binding.naughtyMessageText.text = naughtyData.message | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NaughtyViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = NaughtyListItemBinding.inflate(inflater, parent, false) | ||
return NaughtyViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: NaughtyViewHolder, position: Int) { | ||
val naughtyData = messages[position] | ||
holder.bind(naughtyData) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return messages.size | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/bignerdranch/android/listr/naughty/NaughtyData.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,3 @@ | ||
package com.bignerdranch.android.listr.nice | ||
|
||
data class NaughtyData(val message: 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
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/bignerdranch/android/listr/nice/NiceAdapter.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,30 @@ | ||
package com.bignerdranch.android.listr.nice | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bignerdranch.android.listr.databinding.NiceListItemBinding | ||
|
||
class NiceAdapter(val messages: List<NiceData>): RecyclerView.Adapter<NiceAdapter.NiceViewHolder>() { | ||
|
||
inner class NiceViewHolder(private val binding: NiceListItemBinding): RecyclerView.ViewHolder(binding.root) { | ||
fun bind(niceData: NiceData) { | ||
binding.niceMessageText.text = niceData.message | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NiceViewHolder { | ||
val inflater = LayoutInflater.from(parent.context) | ||
val binding = NiceListItemBinding.inflate(inflater, parent, false) | ||
return NiceViewHolder(binding) | ||
} | ||
|
||
override fun onBindViewHolder(holder: NiceViewHolder, position: Int) { | ||
val niceData = messages[position] | ||
holder.bind(niceData) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return messages.size | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/bignerdranch/android/listr/nice/NiceData.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,3 @@ | ||
package com.bignerdranch.android.listr.nice | ||
|
||
data class NiceData(val message: 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
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
Oops, something went wrong.