// Path: app/src/main/java/com/choices/imagecompare/holders/BaseViewHolder.java
// public abstract class BaseViewHolder<V extends View & Instrumented>
//         extends RecyclerView.ViewHolder {
// 
//     protected final V mImageView;
//     private final PerfListener mPerfListener;
//     private final View mParentView;
//     private Context mContext;
// 
//     public BaseViewHolder(
//             Context context,
//             View parentView,
//             V imageView,
//             PerfListener perfListener) {
//         super(imageView);
//         this.mContext = context;
//         this.mPerfListener = perfListener;
//         this.mParentView = parentView;
//         this.mImageView = imageView;
//         if (mParentView != null) {
//             int size = calcDesiredSize(mParentView.getWidth(), mParentView.getHeight());
//             updateViewLayoutParams(mImageView, size, size);
//         }
//     }
// 
//     public void bind(String model) {
//         mImageView.initInstrumentation(model.toString(), mPerfListener);
//         onBind(model);
//     }
// 
//     /**
//      * Load an image of the specified uri into the view, asynchronously.
//      */
//     protected abstract void onBind(String uri);
// 
//     protected Context getContext() {
//         return mContext;
//     }
// 
//     private void updateViewLayoutParams(View view, int width, int height) {
//         ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
//         if (layoutParams == null || layoutParams.height != width || layoutParams.width != height) {
//             layoutParams = new AbsListView.LayoutParams(width, height);
//             view.setLayoutParams(layoutParams);
//         }
//     }
// 
//     private int calcDesiredSize(int parentWidth, int parentHeight) {
//         int orientation = mContext.getResources().getConfiguration().orientation;
//         int desiredSize = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
//                 parentHeight / 2 : parentHeight / 3;
//         return Math.min(desiredSize, parentWidth);
//     }
// }
// 
// Path: app/src/main/java/com/choices/imagecompare/instrumentation/PerfListener.java
// public class PerfListener {
//     private long mSumOfWaitTime;
//     private long mStartedRequests;
//     private long mSuccessfulRequests;
//     private long mCancelledRequests;
//     private long mFailedRequests;
// 
//     public PerfListener() {
//         mSumOfWaitTime = 0;
//         mStartedRequests = 0;
//         mSuccessfulRequests = 0;
//         mCancelledRequests = 0;
//         mFailedRequests = 0;
//     }
// 
//     /**
//      * Called whenever image request finishes successfully, that is whenever final image is set.
//      */
//     public void reportSuccess(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mSuccessfulRequests++;
//     }
// 
//     /**
//      * Called whenever image request fails, that is whenever failure drawable is set.
//      */
//     public void reportFailure(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mFailedRequests++;
//     }
// 
//     /**
//      * Called whenever image request is cancelled, that is whenever image view is reused without
//      * setting final image first
//      */
//     public void reportCancellation(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mCancelledRequests++;
//     }
// 
//     /**
//      * Called whenver new request is started.
//      */
//     public void reportStart() {
//         mStartedRequests++;
//     }
// 
//     /**
//      * @return average wait time, that is sum of reported wait times divided by number of completed
//      * requests
//      */
//     public long getAverageWaitTime() {
//         final long completedRequests = getCompletedRequests();
//         return completedRequests > 0 ? mSumOfWaitTime / completedRequests : 0;
//     }
// 
//     /**
//      * @return difference between number of started requests and number of completed requests
//      */
//     public long getOutstandingRequests() {
//         return mStartedRequests - getCompletedRequests();
//     }
// 
//     /**
//      * @return number of cancelled requests
//      */
//     public long getCancelledRequests() {
//         return mCancelledRequests;
//     }
// 
//     /**
//      * @return number of completed requests, either by seting final image, failure or cancellation
//      */
//     public long getCompletedRequests() {
//         return mSuccessfulRequests + mCancelledRequests + mFailedRequests;
//     }
// }


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import com.choices.imagecompare.holders.BaseViewHolder;
import com.choices.imagecompare.instrumentation.PerfListener;
import java.util.LinkedList;
import java.util.List;
/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.choices.imagecompare.adapters;




/**
 * Base class for RecyclerView Adapters
 */
public abstract class ImageListAdapter extends RecyclerView.Adapter<BaseViewHolder<?>> {

    private final PerfListener mPerfListener;

    private final Context mContext;

    private List<String> mModel;

    public ImageListAdapter(final Context context, final PerfListener perfListener) {
        this.mContext = context;
        this.mPerfListener = perfListener;
        this.mModel = new LinkedList<String>();
    }

    public void addUrl(final String url) {
        mModel.add(url);
    }

    protected PerfListener getPerfListener() {
        return mPerfListener;
    }

    protected String getItem(final int position) {
        return mModel.get(position);
    }

    @Override
    public int getItemCount() {
// Path: app/src/main/java/com/choices/imagecompare/holders/BaseViewHolder.java
// public abstract class BaseViewHolder<V extends View & Instrumented>
//         extends RecyclerView.ViewHolder {
// 
//     protected final V mImageView;
//     private final PerfListener mPerfListener;
//     private final View mParentView;
//     private Context mContext;
// 
//     public BaseViewHolder(
//             Context context,
//             View parentView,
//             V imageView,
//             PerfListener perfListener) {
//         super(imageView);
//         this.mContext = context;
//         this.mPerfListener = perfListener;
//         this.mParentView = parentView;
//         this.mImageView = imageView;
//         if (mParentView != null) {
//             int size = calcDesiredSize(mParentView.getWidth(), mParentView.getHeight());
//             updateViewLayoutParams(mImageView, size, size);
//         }
//     }
// 
//     public void bind(String model) {
//         mImageView.initInstrumentation(model.toString(), mPerfListener);
//         onBind(model);
//     }
// 
//     /**
//      * Load an image of the specified uri into the view, asynchronously.
//      */
//     protected abstract void onBind(String uri);
// 
//     protected Context getContext() {
//         return mContext;
//     }
// 
//     private void updateViewLayoutParams(View view, int width, int height) {
//         ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
//         if (layoutParams == null || layoutParams.height != width || layoutParams.width != height) {
//             layoutParams = new AbsListView.LayoutParams(width, height);
//             view.setLayoutParams(layoutParams);
//         }
//     }
// 
//     private int calcDesiredSize(int parentWidth, int parentHeight) {
//         int orientation = mContext.getResources().getConfiguration().orientation;
//         int desiredSize = (orientation == Configuration.ORIENTATION_LANDSCAPE) ?
//                 parentHeight / 2 : parentHeight / 3;
//         return Math.min(desiredSize, parentWidth);
//     }
// }
// 
// Path: app/src/main/java/com/choices/imagecompare/instrumentation/PerfListener.java
// public class PerfListener {
//     private long mSumOfWaitTime;
//     private long mStartedRequests;
//     private long mSuccessfulRequests;
//     private long mCancelledRequests;
//     private long mFailedRequests;
// 
//     public PerfListener() {
//         mSumOfWaitTime = 0;
//         mStartedRequests = 0;
//         mSuccessfulRequests = 0;
//         mCancelledRequests = 0;
//         mFailedRequests = 0;
//     }
// 
//     /**
//      * Called whenever image request finishes successfully, that is whenever final image is set.
//      */
//     public void reportSuccess(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mSuccessfulRequests++;
//     }
// 
//     /**
//      * Called whenever image request fails, that is whenever failure drawable is set.
//      */
//     public void reportFailure(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mFailedRequests++;
//     }
// 
//     /**
//      * Called whenever image request is cancelled, that is whenever image view is reused without
//      * setting final image first
//      */
//     public void reportCancellation(long waitTime) {
//         mSumOfWaitTime += waitTime;
//         mCancelledRequests++;
//     }
// 
//     /**
//      * Called whenver new request is started.
//      */
//     public void reportStart() {
//         mStartedRequests++;
//     }
// 
//     /**
//      * @return average wait time, that is sum of reported wait times divided by number of completed
//      * requests
//      */
//     public long getAverageWaitTime() {
//         final long completedRequests = getCompletedRequests();
//         return completedRequests > 0 ? mSumOfWaitTime / completedRequests : 0;
//     }
// 
//     /**
//      * @return difference between number of started requests and number of completed requests
//      */
//     public long getOutstandingRequests() {
//         return mStartedRequests - getCompletedRequests();
//     }
// 
//     /**
//      * @return number of cancelled requests
//      */
//     public long getCancelledRequests() {
//         return mCancelledRequests;
//     }
// 
//     /**
//      * @return number of completed requests, either by seting final image, failure or cancellation
//      */
//     public long getCompletedRequests() {
//         return mSuccessfulRequests + mCancelledRequests + mFailedRequests;
//     }
// }


// Path: app/src/main/java/com/choices/imagecompare/adapters/ImageListAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import com.choices.imagecompare.holders.BaseViewHolder;
import com.choices.imagecompare.instrumentation.PerfListener;
import java.util.LinkedList;
import java.util.List;

/*
 * This file provided by Facebook is for non-commercial testing and evaluation
 * purposes only.  Facebook reserves all rights not expressly granted.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package com.choices.imagecompare.adapters;




/**
 * Base class for RecyclerView Adapters
 */
public abstract class ImageListAdapter extends RecyclerView.Adapter<BaseViewHolder<?>> {

    private final PerfListener mPerfListener;

    private final Context mContext;

    private List<String> mModel;

    public ImageListAdapter(final Context context, final PerfListener perfListener) {
        this.mContext = context;
        this.mPerfListener = perfListener;
        this.mModel = new LinkedList<String>();
    }

    public void addUrl(final String url) {
        mModel.add(url);
    }

    protected PerfListener getPerfListener() {
        return mPerfListener;
    }

    protected String getItem(final int position) {
        return mModel.get(position);
    }

    @Override
    public int getItemCount() {
        return mModel.size();