I am trying to refresh or update a recycle view every time then I get a new message.
every time when i get a new message, then I update a list with the new message and then I want to update the recycle view by that list.
related class structure are given below. Please check.
I am new to Kotlin and android development, so Please help me to solve the challenge.
MainActivity Class
class MainActivity : AppCompatActivity(),UpdateRecycleView{
override fun refreshRecycleView(msg: String){
//I am calling this function "refreshRecycleView" in some other class where I get MQTT message
//this function can successfully call "onReceinveMQTTmessage"
//now I want to "refresh or Update" the recycle view with the "MQTTmessage" which falls in this function through the arguement "msg"
//How can I call the Adapter here to create the recycle view
}
override fun onCreate(savedInstanceState: Bundle?){}
}
MainAdapter Class
class MainAdapter(val context: Context, item_list_str : String) : RecyclerView.Adapter<MainAdapter.MyViewHolder>() {
val item_list = item_list_str
var output_lst: List<String> = item_list.split("," ).map { it.trim() }
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {}
override fun getItemCount(): Int {}
override fun getItemViewType(position: Int): Int {}
inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var seek_val = 0
var seek_tag = ""
var currentTitle: String? = null
var currentPosition: Int = 0
init {}
}
}
class CustomViewHolder(val view : View) : RecyclerView.ViewHolder(view){
}