Skip to content

Instantly share code, notes, and snippets.

View danielmalone's full-sized avatar

DJ Malone danielmalone

View GitHub Profile
package com.danielmalone.podcast
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
class MainActivity : AppCompatActivity() {
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/podcastTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
package com.danielmalone.podcast
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
class PodcastsAdapter :
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PodcastViewHolder {
val inflater = LayoutInflater.from(parent.context)
return PodcastViewHolder(inflater.inflate(R.layout.podcast_item, parent, false))
}
class PodcastsAdapter :
ListAdapter<Podcast, PodcastsAdapter.PodcastViewHolder>(PodcastDiffCallback()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PodcastViewHolder {
}
override fun onBindViewHolder(holder: PodcastViewHolder, position: Int) {
}
class PodcastViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
class PodcastsAdapter : ListAdapter<Podcast, PodcastViewHolder>(PodcastDiffCallback()) {
class PodcastViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind() {
}
}
}
class PodcastDiffCallback : DiffUtil.ItemCallback<Podcast>() {
override fun areItemsTheSame(oldItem: Podcast, newItem: Podcast): Boolean {
return true
}
override fun areContentsTheSame(oldItem: Podcast, newItem: Podcast): Boolean {
return true
}
}
package com.danielmalone.podcast
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
class PodcastsAdapter : ListAdapter<Podcast, PodcastViewHolder>(PodcastDiffCallback()) {
}
class PodcastDiffCallback : DiffUtil.ItemCallback<Podcast>() {
}
package com.danielmalone.podcast
data class Podcast(
val title: String,
val duration: String
)
package com.danielmalone.podcast
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.content_main.*
class MainActivity : AppCompatActivity() {