Retrieves the task associated with the given ImageView . - Android User Interface

Android examples for User Interface:ImageView

Description

Retrieves the task associated with the given ImageView .

Demo Code


import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;

public class Main{
    /**//from  w ww.j  a v a  2s.  c  om
     * Retrieves the task associated with the given {@link ImageView}.
     * @param imageView The view to get the task from.
     * @return The task associated with the view or null if none exists.
     */
    public static AsyncDrawableTask<?> getTask(ImageView imageView) {
        if (imageView != null) {
            final Drawable drawable = imageView.getDrawable();
            if (drawable instanceof AsyncDrawable<?>) {
                return ((AsyncDrawable<?>) drawable).getTask();
            }
        }
        return null;
    }
    /**
     * Retrieves the task associated with the given {@link View}.
     * @param view The view to get the task from.
     * @return The task associated with the view or null if none exists.
     */
    public static AsyncDrawableTask<?> getTask(View view) {
        if (view != null) {
            final Drawable drawable = view.getBackground();
            if (drawable instanceof AsyncDrawable<?>) {
                return ((AsyncDrawable<?>) drawable).getTask();
            }
        }
        return null;
    }
}

Related Tutorials