// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/ImageLoader.java
// public interface ImageLoader {
// 
//   /**
//    * Configures an url to be downloaded.
//    */
//   ImageLoader load(String url);
// 
//   /**
//    * Configures a resource id to be loaded.
//    */
//   ImageLoader load(Integer resourceId);
// 
//   /**
//    * Loads a placeholder using a resource id to be shown while the external resource is being
//    * downloaded.
//    */
//   ImageLoader withPlaceholder(Integer placeholderId);
// 
//   /**
//    * Applies a circular transformation to transform the source bitmap into a circular one.
//    */
//   ImageLoader useCircularTransformation(boolean useCircularTransformation);
// 
//   /**
//    * Changes the external resource size once it downloaded and before to notify the listener.
//    */
//   ImageLoader size(int size);
// 
//   /**
//    * Configures a listener where the ImageLoader will notify once the resource be loaded. This
//    * method has to be called to start the resource download. The listener used can't be null.
//    */
//   void notify(Listener listener);
// 
//   /**
//    * Pauses all the resource downloads associated to this library.
//    */
//   void pause();
// 
//   /**
//    * Resumes all the resource downloads associated to this library.
//    */
//   void resume();
// 
//   /**
//    * Cancels all the pending requests to download a resource.
//    */
//   void cancelPendingRequests();
// 
//   /**
//    * Declares some methods which will be called during the resource download process implemented by
//    * the ImageLoader. Use this interface to be notified when the placeholder and the final resource
//    * be ready to be used.
//    */
//   interface Listener {
// 
//     void onPlaceholderLoaded(Drawable placeholder);
// 
//     void onImageLoaded(Bitmap image);
// 
//     void onError();
// 
//     void onDrawableLoaded(Drawable drawable);
//   }
// }


import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.imageloader.ImageLoader;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Observable;
/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pedrovgs.nox;


/**
 * Processes NoxItem instances to download the images or resources associated to a list of NoxItem
 * instances asynchronously. This object notifies the observers previously added when the resource
 * or the image associated to the NoxItem is ready to be used.
 *
 * @author Pedro Vicente Gomez Sanchez.
 */
class NoxItemCatalog extends Observable {

  private final List<NoxItem> noxItems;
  private final int noxItemSize;
// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/ImageLoader.java
// public interface ImageLoader {
// 
//   /**
//    * Configures an url to be downloaded.
//    */
//   ImageLoader load(String url);
// 
//   /**
//    * Configures a resource id to be loaded.
//    */
//   ImageLoader load(Integer resourceId);
// 
//   /**
//    * Loads a placeholder using a resource id to be shown while the external resource is being
//    * downloaded.
//    */
//   ImageLoader withPlaceholder(Integer placeholderId);
// 
//   /**
//    * Applies a circular transformation to transform the source bitmap into a circular one.
//    */
//   ImageLoader useCircularTransformation(boolean useCircularTransformation);
// 
//   /**
//    * Changes the external resource size once it downloaded and before to notify the listener.
//    */
//   ImageLoader size(int size);
// 
//   /**
//    * Configures a listener where the ImageLoader will notify once the resource be loaded. This
//    * method has to be called to start the resource download. The listener used can't be null.
//    */
//   void notify(Listener listener);
// 
//   /**
//    * Pauses all the resource downloads associated to this library.
//    */
//   void pause();
// 
//   /**
//    * Resumes all the resource downloads associated to this library.
//    */
//   void resume();
// 
//   /**
//    * Cancels all the pending requests to download a resource.
//    */
//   void cancelPendingRequests();
// 
//   /**
//    * Declares some methods which will be called during the resource download process implemented by
//    * the ImageLoader. Use this interface to be notified when the placeholder and the final resource
//    * be ready to be used.
//    */
//   interface Listener {
// 
//     void onPlaceholderLoaded(Drawable placeholder);
// 
//     void onImageLoaded(Bitmap image);
// 
//     void onError();
// 
//     void onDrawableLoaded(Drawable drawable);
//   }
// }


// Path: nox/src/main/java/com/github/pedrovgs/nox/NoxItemCatalog.java
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.imageloader.ImageLoader;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.Observable;

/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pedrovgs.nox;


/**
 * Processes NoxItem instances to download the images or resources associated to a list of NoxItem
 * instances asynchronously. This object notifies the observers previously added when the resource
 * or the image associated to the NoxItem is ready to be used.
 *
 * @author Pedro Vicente Gomez Sanchez.
 */
class NoxItemCatalog extends Observable {

  private final List<NoxItem> noxItems;
  private final int noxItemSize;
  private final ImageLoader imageLoader;