title: Cannot execute task: the task is already running
body: <p>I am calling the <code>AsycnTask</code> inside the <code>Adapter</code>, but when I scrolling the <code>RecyclerView</code> some error appears, and this is the error.</p>
  
  <pre><code>E/MainAdapter: getAttachment failed
  java.lang.IllegalStateException: Cannot execute task: the task is already running.
  </code></pre>
  
  <p>and this is my code.</p>
  
  <pre><code>class MainAdapter(private dataSet: ArrayList&lt;MyObject&gt;): RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt;() {
  
      private val disposable = CompositeDisposable()
      // some stuff here...
  
      override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
          disposable.add(
              getApiService().getAttachment()
                  .subscribeOn(Schedulers.io())
                  .observerOn(AndroidSchedulers.mainThread())
                  .subscribe(
                      { it -&gt;
                          Log.i(TAG, "getAttachment success")
                          if (fileType.isImage) {
                              holder.imageLoader.execute(it.byteStream()) // the error is pointing here
                          } else if (fileType.isVideo) {
                              holder.videoLoader.execute(it.byteStream())
                          }
                      },
                      {
                          Log.e(TAG, "getAttachment fail", it)
                      }
                  )
          )
      }
  
  
      class ItemViewHolder(itemView: View), OnMediaLoaderListener {
          override fun onImageLoadFinish(bitmap: Bitmap) {
              Glide.with(itemView)
                      .load(bitmap)
                      .into(itemView.img)
          }
  
          override fun onVideoLoadFinish(uri: Uri) {
              itemView.video.setVideoURI(uri)
              itemView.video.start()
          }
  
          val videoLoader = VideoLoader(this)
          val imageLoader = ImageLoader(this)
      }
  
      class VideoLoader(private val listener: OnMediaLoaderListener): AsyncTask&lt;InputStream, Void, File&gt;() {
          // some stuff here...
      }
  
      class ImageLoader(private val listener: OnMediaLoaderListener): AsyncTask&lt;InputStream, Void, Bitmap&gt;() {
          // some stuff here...
      }
  }
  
  interface OnMediaLoaderListener {
      fun onVideoLoadFinish(uri: Uri)
      fun onImageLoadFinish(bitmap: Bitmap)
  }
  </code></pre>
  
  <p>I don't why this error appear.
  Any idea on how to properly call the <code>AsyncTask</code> inside the <code>Adapter</code> and to prevent this error?</p>
  
  <p>Thanks.</p>