nostra13/Android-Universal-Image-Loader — Issue #19: Using from Fragment raises : ERROR_IMAGEVIEW_CONTEXT
Author: funkyspider
Created: 2012-02-13 13:00:40+00:00
State: open

Using universal-image-loader-1.1.1.jar
Using android support package

Main activity is a FragmentActivity containing a ViewPager.
ViewPager contains Fragments. Fragment contains ListView.

When I attempt to use ImageLoader from the Fragment ListViews Adapter I receive the logged exception
ImageView context must be of Activity type

from
public class ImageLoader ...

private void tryRunOnUiThread(Runnable runnable) {
Context context = imageLoadingInfo.imageView.getContext();
if (context instanceof Activity) {
((Activity) context).runOnUiThread(runnable);
} else {
Log.e(TAG, ERROR_IMAGEVIEW_CONTEXT);
imageLoadingInfo.listener.onLoadingFailed(FailReason.WRONG_CONTEXT);
}
}