Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /*
2 * Copyright (C) 2013 Square, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.squareup.picasso;
18 import android.graphics.Bitmap;
19 import android.graphics.drawable.Drawable;
20 import java.lang.ref.ReferenceQueue;
21 import java.lang.ref.WeakReference;
23 abstract class Action<T> {
24 static class RequestWeakReference<T> extends WeakReference<T> {
25 final Action action;
27 public RequestWeakReference(Action action, T referent, ReferenceQueue<? super T> q) {
28 super(referent, q);
29 this.action = action;
30 }
31 }
33 final Picasso picasso;
34 final Request data;
35 final WeakReference<T> target;
36 final boolean skipCache;
37 final boolean noFade;
38 final int errorResId;
39 final Drawable errorDrawable;
40 final String key;
42 boolean cancelled;
44 Action(Picasso picasso, T target, Request data, boolean skipCache, boolean noFade,
45 int errorResId, Drawable errorDrawable, String key) {
46 this.picasso = picasso;
47 this.data = data;
48 this.target = new RequestWeakReference<T>(this, target, picasso.referenceQueue);
49 this.skipCache = skipCache;
50 this.noFade = noFade;
51 this.errorResId = errorResId;
52 this.errorDrawable = errorDrawable;
53 this.key = key;
54 }
56 abstract void complete(Bitmap result, Picasso.LoadedFrom from);
58 abstract void error();
60 void cancel() {
61 cancelled = true;
62 }
64 Request getData() {
65 return data;
66 }
68 T getTarget() {
69 return target.get();
70 }
72 String getKey() {
73 return key;
74 }
76 boolean isCancelled() {
77 return cancelled;
78 }
80 Picasso getPicasso() {
81 return picasso;
82 }
83 }