1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/mobile/android/thirdparty/com/squareup/picasso/TargetAction.java Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 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 + 1.23 +final class TargetAction extends Action<Target> { 1.24 + 1.25 + TargetAction(Picasso picasso, Target target, Request data, boolean skipCache, String key) { 1.26 + super(picasso, target, data, skipCache, false, 0, null, key); 1.27 + } 1.28 + 1.29 + @Override void complete(Bitmap result, Picasso.LoadedFrom from) { 1.30 + if (result == null) { 1.31 + throw new AssertionError( 1.32 + String.format("Attempted to complete action with no result!\n%s", this)); 1.33 + } 1.34 + Target target = getTarget(); 1.35 + if (target != null) { 1.36 + target.onBitmapLoaded(result, from); 1.37 + if (result.isRecycled()) { 1.38 + throw new IllegalStateException("Target callback must not recycle bitmap!"); 1.39 + } 1.40 + } 1.41 + } 1.42 + 1.43 + @Override void error() { 1.44 + Target target = getTarget(); 1.45 + if (target != null) { 1.46 + target.onBitmapFailed(errorDrawable); 1.47 + } 1.48 + } 1.49 +}