title: Getting Drawable with Picasso
body: <p>Recently I got acquainted with the Picasso framework for downloading pictures from the Internet. But, the matter is that, as I understood, the framework itself can not give exactly what I want. I have some data class which uses for recycler view's list. And there must be Drawable, because I'm using something like that:</p>
  
  <pre><code>holder?.photoView?.setImageResource(userList[position].photoId)
  </code></pre>
  
  <p>in my custom adapter onBindViewHolder. So, I already have an property that must be used. Well, not to be confused, just say that I need to get Drawable resource from this:</p>
  
  <pre><code>Picasso.with(context).load(url).centerCrop().fit()
  </code></pre>
  
  <p>or something like that.
  Thank you in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>First of all, my fragment:</p>
  
  <pre><code>fun setImg(url: String) {//Code that doesn't work
      val url = userList[position].photoId
      Picasso.with(context).load(url).placeHolder(R.drawable.image).into(imageView)
  }
  
  override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
      val view = inflater.inflate(R.layout.fragment_hotels, container, false)
  
      val rv = view.findViewById&lt;RecyclerView&gt;(R.id.hotelsView)
      rv.layoutManager = LinearLayoutManager(context, LinearLayout.VERTICAL, false)
      val list = ArrayList&lt;Hotel&gt;()
      list.add(Item("Milk (Just for example)", "$1.99", setImg("img")))
      list.add(Hotel("Banana", "$2.99", setImg("img")))
  
      var adapter = CustomAdapter(list)
      rv.adapter = adapter
  
      return view
  }
  </code></pre>
  
  <p>Custom Adapter:</p>
  
  <pre><code>class CustomAdapter(val userList: ArrayList&lt;Hotel&gt;): RecyclerView.Adapter&lt;CustomAdapter.ViewHolder&gt;() {
  
  override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
      holder?.textTitle?.text = userList[position].title
      holder?.textPrice?.text = userList[position].price
      //holder?.photoView?.setImageResource(userList[position].photoId)
  }
  
  override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
      val v = LayoutInflater.from(parent?.context).inflate(R.layout.view_adapter, parent, false)
      return ViewHolder(v)
  }
  
  override fun getItemCount(): Int {
      return userList.size
  }
  
  class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView){
      val textTitle = itemView.findViewById&lt;TextView&gt;(R.id.text_first)
      val textPrice = itemView.findViewById&lt;TextView&gt;(R.id.text_second)
      val photoView = itemView.findViewById&lt;ImageView&gt;(R.id.photoView)
  }
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="wrap_content"
  tools:ignore="NamespaceTypo"&gt;
  
  &lt;android.support.v7.widget.CardView
      android:layout_margin="5dp"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:cardBackgroundColor="#FFF"&gt;
      &lt;LinearLayout
          android:padding="10dp"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;ImageView
              android:id="@+id/photoView"
              android:layout_width="match_parent"
              android:layout_height="100dp"/&gt;
          &lt;TextView
              android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
              android:id="@+id/text_first"
              android:text="Title"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"/&gt;
          &lt;TextView
              android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
              android:text="Price"
              android:id="@+id/text_second"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/android.support.v7.widget.CardView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>That's all.</p>