Last active
November 7, 2021 11:23
-
-
Save mwshubham/ff835e604b90de2925cd227108704b53 to your computer and use it in GitHub Desktop.
RealmRecyclerViewAdapter example in kotlin using Realm Results and autoUpdate property
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
class HomeListAdapter(val context: Context, contactBeans: RealmResults<ContactBean>?, val realmInstance: Realm, autoUpdate: Boolean) | |
: RealmRecyclerViewAdapter<ContactBean, HomeListAdapter.ViewHolder>(contactBeans, autoUpdate) { | |
val TAG = HomeListAdapter::class.simpleName | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
val view = LayoutInflater.from(context).inflate(R.layout.item_chat, parent, false) | |
return ViewHolder(view) | |
} | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
} | |
override fun getItemCount(): Int { | |
return if (data == null) 0 else data!!.size | |
} | |
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please, change the name of file to
kotlin_realm_rv_adapter_auto_update_demo.kt
to let GitHub highlight the kotlin syntax