// Path: library/src/main/java/com/smartnsoft/droid4me/download/BasisDownloadInstructions.java
// public interface InputStreamDownloadInstructor
// {
// 
//   /**
//    * Indicates that the input stream should be asynchronous.
//    */
//   void setAsynchronous();
// 
//   /**
//    * Should be called when the input stream has just been downloaded.
//    *
//    * @param inputStream should not be {@code null}
//    */
//   void onDownloaded(InputStream inputStream);
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Bitmapable
// {
// 
//   /**
//    * @return the underlying bitmap size expressed in bytes
//    */
//   int getSizeInBytes();
// 
//   /**
//    * Should release the memory hold by the underlying bitmap, when reclaimed.
//    */
//   void recycle();
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Handlerable
// {
// 
//   /**
//    * Is supposed to run the given command in the UI thread.
//    *
//    * @param runnnable the command that should be executed
//    * @return {@code true} if and only if the execution in the UI thread has actually successfuly started
//    */
//   boolean post(Runnable runnnable);
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Viewable
// {
// 
//   /**
//    * @return a tag object associated to the underlying view.
//    */
//   Object getTag();
// 
//   /**
//    * Sets the tag object associated to the underlying view.
//    *
//    * @param tag
//    */
//   void setTag(Object tag);
// 
//   /**
//    * The identifier returned here is just use for logging purposes.
//    *
//    * @return the unique identifier of the underlying view: two physical different views should not have the same identifier
//    */
//   int getId();
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadInstructions.java
// public final static class BitmapableGif
//     implements Bitmapable
// {
// 
//   private final Gif gif;
// 
//   private final Bitmap bitmap;
// 
//   public BitmapableGif(Gif gif)
//   {
//     this.gif = gif;
//     bitmap = gif.getBitmap(0);
//   }
// 
//   @Override
//   public int getSizeInBytes()
//   {
//     if (gif == null)
//     {
//       return 0;
//     }
//     else
//     {
//       return gif.getHeight() * gif.getWidth() * gif.getFramesCount();
//     }
//   }
// 
//   @Override
//   public void recycle()
//   {
//     if (gif != null && gif.getBitmaps().isEmpty() == false)
//     {
//       for (Bitmap bitmap : gif.getBitmaps())
//       {
//         bitmap.recycle();
//       }
//     }
//   }
// 
//   public void endAnimation()
//   {
//     if (gif != null)
//     {
//       gif.endAnimation();
//     }
//   }
// 
//   public Gif getGif()
//   {
//     return gif;
//   }
// }


import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import android.view.View;
import com.smartnsoft.droid4me.download.BasisDownloadInstructions.InputStreamDownloadInstructor;
import com.smartnsoft.droid4me.download.DownloadContracts.Bitmapable;
import com.smartnsoft.droid4me.download.DownloadContracts.Handlerable;
import com.smartnsoft.droid4me.download.DownloadContracts.Viewable;
import com.smartnsoft.droid4me.download.DownloadInstructions.BitmapableGif;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
          else
          {
            instructions.onOver(true, alreadyStackedCommand.view, alreadyStackedCommand.bitmapUid, alreadyStackedCommand.imageSpecs);
          }
        }
      }

      // We need to download the bitmap or take it from a local persistence place
      // Hence, we stack the bitmap download command
      final DownloadBitmapCommand downloadCommand = computeDownloadBitmapCommand(id, view, url, bitmapUid, imageSpecs, handler, instructions);
      if (view != null)
      {
        prioritiesDownloadStack.put(view, downloadCommand);
        dump();
      }
      if (resumeWorkflowOnSameThread == false)
      {
        BasisBitmapDownloader.DOWNLOAD_THREAD_POOL.execute(downloadCommand);
      }
      else
      {
        // In that case, we want the workflow to keep on running from the calling thread
        downloadCommand.executeStart(true, false);
      }
    }

  }

  protected class DownloadBitmapCommand
      extends BasisCommand
// Path: library/src/main/java/com/smartnsoft/droid4me/download/BasisDownloadInstructions.java
// public interface InputStreamDownloadInstructor
// {
// 
//   /**
//    * Indicates that the input stream should be asynchronous.
//    */
//   void setAsynchronous();
// 
//   /**
//    * Should be called when the input stream has just been downloaded.
//    *
//    * @param inputStream should not be {@code null}
//    */
//   void onDownloaded(InputStream inputStream);
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Bitmapable
// {
// 
//   /**
//    * @return the underlying bitmap size expressed in bytes
//    */
//   int getSizeInBytes();
// 
//   /**
//    * Should release the memory hold by the underlying bitmap, when reclaimed.
//    */
//   void recycle();
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Handlerable
// {
// 
//   /**
//    * Is supposed to run the given command in the UI thread.
//    *
//    * @param runnnable the command that should be executed
//    * @return {@code true} if and only if the execution in the UI thread has actually successfuly started
//    */
//   boolean post(Runnable runnnable);
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadContracts.java
// public interface Viewable
// {
// 
//   /**
//    * @return a tag object associated to the underlying view.
//    */
//   Object getTag();
// 
//   /**
//    * Sets the tag object associated to the underlying view.
//    *
//    * @param tag
//    */
//   void setTag(Object tag);
// 
//   /**
//    * The identifier returned here is just use for logging purposes.
//    *
//    * @return the unique identifier of the underlying view: two physical different views should not have the same identifier
//    */
//   int getId();
// 
// }
// 
// Path: library/src/main/java/com/smartnsoft/droid4me/download/DownloadInstructions.java
// public final static class BitmapableGif
//     implements Bitmapable
// {
// 
//   private final Gif gif;
// 
//   private final Bitmap bitmap;
// 
//   public BitmapableGif(Gif gif)
//   {
//     this.gif = gif;
//     bitmap = gif.getBitmap(0);
//   }
// 
//   @Override
//   public int getSizeInBytes()
//   {
//     if (gif == null)
//     {
//       return 0;
//     }
//     else
//     {
//       return gif.getHeight() * gif.getWidth() * gif.getFramesCount();
//     }
//   }
// 
//   @Override
//   public void recycle()
//   {
//     if (gif != null && gif.getBitmaps().isEmpty() == false)
//     {
//       for (Bitmap bitmap : gif.getBitmaps())
//       {
//         bitmap.recycle();
//       }
//     }
//   }
// 
//   public void endAnimation()
//   {
//     if (gif != null)
//     {
//       gif.endAnimation();
//     }
//   }
// 
//   public Gif getGif()
//   {
//     return gif;
//   }
// }


// Path: library/src/main/java/com/smartnsoft/droid4me/download/BasisBitmapDownloader.java
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import android.view.View;
import com.smartnsoft.droid4me.download.BasisDownloadInstructions.InputStreamDownloadInstructor;
import com.smartnsoft.droid4me.download.DownloadContracts.Bitmapable;
import com.smartnsoft.droid4me.download.DownloadContracts.Handlerable;
import com.smartnsoft.droid4me.download.DownloadContracts.Viewable;
import com.smartnsoft.droid4me.download.DownloadInstructions.BitmapableGif;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;

          else
          {
            instructions.onOver(true, alreadyStackedCommand.view, alreadyStackedCommand.bitmapUid, alreadyStackedCommand.imageSpecs);
          }
        }
      }

      // We need to download the bitmap or take it from a local persistence place
      // Hence, we stack the bitmap download command
      final DownloadBitmapCommand downloadCommand = computeDownloadBitmapCommand(id, view, url, bitmapUid, imageSpecs, handler, instructions);
      if (view != null)
      {
        prioritiesDownloadStack.put(view, downloadCommand);
        dump();
      }
      if (resumeWorkflowOnSameThread == false)
      {
        BasisBitmapDownloader.DOWNLOAD_THREAD_POOL.execute(downloadCommand);
      }
      else
      {
        // In that case, we want the workflow to keep on running from the calling thread
        downloadCommand.executeStart(true, false);
      }
    }

  }

  protected class DownloadBitmapCommand
      extends BasisCommand
      implements InputStreamDownloadInstructor