title: How to call a fragment's function from adapter in Kotlin?
body: <p>I am a beginner in Kotlin android development and not able to call a fragment function from adapter. Following <a href="https://stackoverflow.com/questions/49802541/kotlin-cant-replace-fragment-from-recyclerview-adapter">this</a> approach, I wrote below code but still no luck.</p>
  
  <p>Adapter code</p>
  
  <pre><code>class CallItemAdapter(
      val context: Context,
      private val callItems: List&lt;CallItem&gt;,
      private val listener: ClickListener
  ) : RecyclerView.Adapter&lt;CallItemAdapter.MyViewHolder&gt;() {
      interface ClickListener {
          fun onClickListener(item: CallItem)
      }
  
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
          val callItemView = LayoutInflater.from(context).inflate(R.layout.item_call, parent, false)
          return MyViewHolder(callItemView)
      }
  
      override fun getItemCount(): Int {
          return callItems.size
      }
  
      override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
          val callItem = callItems[position]
          holder.setData(callItem, position, listener)
      }
  
      inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
          private var currentCallItem: CallItem? = null
          private var currentPosition: Int = 0
  
          init {
              itemView.btnCall.setOnClickListener {
                 // TODO 
              }
          }
  
          fun setData(callItem: CallItem?, position: Int, listener: ClickListener) {
              itemView.txtPersonName.text = callItem!!.name
              itemView.txtTask.text = callItem.task
              itemView.setOnClickListener {
                  listener.onClickListener(callItem)
              }
  
              this.currentCallItem = callItem
              this.currentPosition = position
          }
      }
  }
  </code></pre>
  
  <p>Fragment code</p>
  
  <pre><code>class CallingWorkFragment : Fragment(), CallItemAdapter.ClickListener {
      override fun onClickListener(item: CallItem) {
          println("Interface working")
          context!!.applicationContext.showToast("Wubba lubba dub dub")
      }
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? {
          return inflater.inflate(R.layout.fragment_work_calling, container, false)
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
  
          val callItems: MutableList&lt;CallItem&gt; = ArrayList()
  
          val adapter = CallItemAdapter(activity!!.applicationContext, callItems, this)
          recyclerViewCallItem.adapter = adapter
      }
  .
  .
  .
  </code></pre>
  
  <p>But on click nothing is happening. Please let me know what I am doing wrong. 
  EDIT: I have added full adapter code.</p>