// Path: app/src/main/java/com/choices/imagecompare/Drawables.java
// public class Drawables {
//     public static Drawable sPlaceholderDrawable;
//     public static Drawable sErrorDrawable;
//     private Drawables() {
//     }
// 
//     public static void init(final Resources resources) {
//         if (sPlaceholderDrawable == null) {
//             sPlaceholderDrawable = resources.getDrawable(R.color.placeholder);
//         }
//         if (sErrorDrawable == null) {
//             sErrorDrawable = resources.getDrawable(R.color.error);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/choices/imagecompare/instrumentation/InstrumentedImageView.java
// public class InstrumentedImageView extends ImageView implements Instrumented {
// 
//     private final Instrumentation mInstrumentation;
// 
//     public InstrumentedImageView(final Context context) {
//         super(context);
//         mInstrumentation = new Instrumentation(this);
//     }
// 
//     @Override
//     public void initInstrumentation(final String tag, PerfListener perfListener) {
//         mInstrumentation.init(tag, perfListener);
//         // we don't have a better estimate on when to call onStart, so do it here.
//         mInstrumentation.onStart();
//     }
// 
//     @Override
//     public void onDraw(final Canvas canvas) {
//         super.onDraw(canvas);
//         mInstrumentation.onDraw(canvas);
//     }
// 
//     @Override
//     public void setImageDrawable(final Drawable drawable) {
//         Preconditions.checkNotNull(drawable);
//         if (drawable == Drawables.sPlaceholderDrawable) {
//             // ignore
//         } else if (drawable == Drawables.sErrorDrawable) {
//             mInstrumentation.onFailure();
//         } else {
//             mInstrumentation.onSuccess();
//         }
//         super.setImageDrawable(drawable);
//     }
// 
//     /**
//      * Throws UnsupportedOperationException
//      */
//     @Override
//     public void setImageResource(int resourceId) {
//         throw new UnsupportedOperationException();
//     }
// 
//     /**
//      * Throws UnsupportedOperationException
//      */
//     @Override
//     public void setImageURI(Uri uri) {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// 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.view.View;
import com.choices.imagecompare.Drawables;
import com.choices.imagecompare.instrumentation.InstrumentedImageView;
import com.choices.imagecompare.instrumentation.PerfListener;
import com.squareup.picasso.Picasso;
/*
 * 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.holders;



/**
 * This is the Holder class for the RecycleView to use with Picasso
 */
public class PicassoHolder extends BaseViewHolder<InstrumentedImageView> {

    private final Picasso mPicasso;

    public PicassoHolder(
            Context context, Picasso picasso, View parent,
// Path: app/src/main/java/com/choices/imagecompare/Drawables.java
// public class Drawables {
//     public static Drawable sPlaceholderDrawable;
//     public static Drawable sErrorDrawable;
//     private Drawables() {
//     }
// 
//     public static void init(final Resources resources) {
//         if (sPlaceholderDrawable == null) {
//             sPlaceholderDrawable = resources.getDrawable(R.color.placeholder);
//         }
//         if (sErrorDrawable == null) {
//             sErrorDrawable = resources.getDrawable(R.color.error);
//         }
//     }
// }
// 
// Path: app/src/main/java/com/choices/imagecompare/instrumentation/InstrumentedImageView.java
// public class InstrumentedImageView extends ImageView implements Instrumented {
// 
//     private final Instrumentation mInstrumentation;
// 
//     public InstrumentedImageView(final Context context) {
//         super(context);
//         mInstrumentation = new Instrumentation(this);
//     }
// 
//     @Override
//     public void initInstrumentation(final String tag, PerfListener perfListener) {
//         mInstrumentation.init(tag, perfListener);
//         // we don't have a better estimate on when to call onStart, so do it here.
//         mInstrumentation.onStart();
//     }
// 
//     @Override
//     public void onDraw(final Canvas canvas) {
//         super.onDraw(canvas);
//         mInstrumentation.onDraw(canvas);
//     }
// 
//     @Override
//     public void setImageDrawable(final Drawable drawable) {
//         Preconditions.checkNotNull(drawable);
//         if (drawable == Drawables.sPlaceholderDrawable) {
//             // ignore
//         } else if (drawable == Drawables.sErrorDrawable) {
//             mInstrumentation.onFailure();
//         } else {
//             mInstrumentation.onSuccess();
//         }
//         super.setImageDrawable(drawable);
//     }
// 
//     /**
//      * Throws UnsupportedOperationException
//      */
//     @Override
//     public void setImageResource(int resourceId) {
//         throw new UnsupportedOperationException();
//     }
// 
//     /**
//      * Throws UnsupportedOperationException
//      */
//     @Override
//     public void setImageURI(Uri uri) {
//         throw new UnsupportedOperationException();
//     }
// }
// 
// 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/holders/PicassoHolder.java
import android.content.Context;
import android.view.View;
import com.choices.imagecompare.Drawables;
import com.choices.imagecompare.instrumentation.InstrumentedImageView;
import com.choices.imagecompare.instrumentation.PerfListener;
import com.squareup.picasso.Picasso;

/*
 * 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.holders;



/**
 * This is the Holder class for the RecycleView to use with Picasso
 */
public class PicassoHolder extends BaseViewHolder<InstrumentedImageView> {

    private final Picasso mPicasso;

    public PicassoHolder(
            Context context, Picasso picasso, View parent,
            InstrumentedImageView view, PerfListener perfListener) {