title: How to implement a RecyclerView when using Model View Presenter pattern?
body: <p>I am working with MVP for the first time and I believe I get the idea of it but I am not sure about the RecyclerView. As far as I can say, MVP is about making views as passive as possible so all business logic goes to the Presenter but how can this be achieved for the Recycler View?</p>
  
  <p>Here is my code so far: </p>
  
  <p><strong>Contract</strong></p>
  
  <pre><code>public interface PhotosContract {
  // View
  interface View {//: IBaseActivity {
      fun showPhotos(photos: ArrayList&lt;Photo&gt;)
      fun showText(message: String)
  }
  // Presenter
  interface Presenter {//: IBasePresenter&lt;View&gt; {
      fun getPhotos()
  }
  }
  </code></pre>
  
  <p><strong>Presenter</strong></p>
  
  <pre><code>public class PhotosPresenter(var view: PhotosContract.View) :PhotosContract.Presenter {
  
  var dataList = ArrayList&lt;Photo&gt;()
  
  override fun getPhotos() {
      //call for endpoint
      val call : Call&lt;ArrayList&lt;Photo&gt;&gt; = ApiClient.getClient.getPhotos()
  
      call.enqueue(object: Callback&lt;ArrayList&lt;Photo&gt;&gt; {
          override fun onFailure(call: Call&lt;ArrayList&lt;Photo&gt;&gt;, t: Throwable) {
              Log.d("FAIL","FAILED")
          }
  
          override fun onResponse(
              call: Call&lt;ArrayList&lt;Photo&gt;&gt;,
              response: Response&lt;ArrayList&lt;Photo&gt;&gt;
          )
          {
              Log.d("SUCCESS","SUCCESSED")
  
              dataList.addAll(response!!.body()!!)
              Log.d("SIZELIST",dataList.size.toString())
  
              view.showPhotos(dataList)
              view.showText("SUCCESS")
          }
  
      })
  
  }
  
  }
  </code></pre>
  
  <p><strong>RecyclerViewAdapter</strong></p>
  
  <pre><code>class PhotosAdapter(private var dataList: List&lt;Photo&gt;, private val context: Context) : RecyclerView.Adapter&lt;PhotosAdapter.PhotosViewHolder&gt;() {
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PhotosAdapter.PhotosViewHolder {
      return PhotosViewHolder(LayoutInflater.from(this.context).inflate(R.layout.list_item_home, parent, false))
  }
  
  override fun getItemCount(): Int {
      return dataList.size
  }
  
  override fun onBindViewHolder(holder: PhotosAdapter.PhotosViewHolder, position: Int) {
      val dataModel = dataList[position]
      holder.titleTextView.text = dataModel.title
  }
  
  class PhotosViewHolder(itemLayoutView: View) : RecyclerView.ViewHolder(itemLayoutView){
      var titleTextView: TextView = itemLayoutView.tv_title
  }
  
  }
  </code></pre>
  
  <p><strong>Activity</strong></p>
  
  <pre><code>class PhotosActivity : AppCompatActivity(),PhotosContract.View {
  private lateinit var presenter: PhotosPresenter
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_photos)
  
      presenter = PhotosPresenter(this)
  
      presenter.getPhotos()
  
  }
  
  override fun showPhotos(photos: ArrayList&lt;Photo&gt;) {
      photosRecyclerView.layoutManager = LinearLayoutManager(this)
      photosRecyclerView.adapter = PhotosAdapter(photos,this)
  
      photosRecyclerView.adapter?.notifyDataSetChanged()
  }
  
  override fun showText(message: String) {
      Toast.makeText(this,message,Toast.LENGTH_LONG).show()
  }
  
  
   }
  </code></pre>