1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/com/squareup/picasso/Action.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,83 @@ 1.4 +/* 1.5 + * Copyright (C) 2013 Square, Inc. 1.6 + * 1.7 + * Licensed under the Apache License, Version 2.0 (the "License"); 1.8 + * you may not use this file except in compliance with the License. 1.9 + * You may obtain a copy of the License at 1.10 + * 1.11 + * http://www.apache.org/licenses/LICENSE-2.0 1.12 + * 1.13 + * Unless required by applicable law or agreed to in writing, software 1.14 + * distributed under the License is distributed on an "AS IS" BASIS, 1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.16 + * See the License for the specific language governing permissions and 1.17 + * limitations under the License. 1.18 + */ 1.19 +package com.squareup.picasso; 1.20 + 1.21 +import android.graphics.Bitmap; 1.22 +import android.graphics.drawable.Drawable; 1.23 +import java.lang.ref.ReferenceQueue; 1.24 +import java.lang.ref.WeakReference; 1.25 + 1.26 +abstract class Action<T> { 1.27 + static class RequestWeakReference<T> extends WeakReference<T> { 1.28 + final Action action; 1.29 + 1.30 + public RequestWeakReference(Action action, T referent, ReferenceQueue<? super T> q) { 1.31 + super(referent, q); 1.32 + this.action = action; 1.33 + } 1.34 + } 1.35 + 1.36 + final Picasso picasso; 1.37 + final Request data; 1.38 + final WeakReference<T> target; 1.39 + final boolean skipCache; 1.40 + final boolean noFade; 1.41 + final int errorResId; 1.42 + final Drawable errorDrawable; 1.43 + final String key; 1.44 + 1.45 + boolean cancelled; 1.46 + 1.47 + Action(Picasso picasso, T target, Request data, boolean skipCache, boolean noFade, 1.48 + int errorResId, Drawable errorDrawable, String key) { 1.49 + this.picasso = picasso; 1.50 + this.data = data; 1.51 + this.target = new RequestWeakReference<T>(this, target, picasso.referenceQueue); 1.52 + this.skipCache = skipCache; 1.53 + this.noFade = noFade; 1.54 + this.errorResId = errorResId; 1.55 + this.errorDrawable = errorDrawable; 1.56 + this.key = key; 1.57 + } 1.58 + 1.59 + abstract void complete(Bitmap result, Picasso.LoadedFrom from); 1.60 + 1.61 + abstract void error(); 1.62 + 1.63 + void cancel() { 1.64 + cancelled = true; 1.65 + } 1.66 + 1.67 + Request getData() { 1.68 + return data; 1.69 + } 1.70 + 1.71 + T getTarget() { 1.72 + return target.get(); 1.73 + } 1.74 + 1.75 + String getKey() { 1.76 + return key; 1.77 + } 1.78 + 1.79 + boolean isCancelled() { 1.80 + return cancelled; 1.81 + } 1.82 + 1.83 + Picasso getPicasso() { 1.84 + return picasso; 1.85 + } 1.86 +}