package cn.way.wandroid.imageloader.displayingbitmaps.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import cn.way.wandroid.R;
import cn.way.wandroid.imageloader.loader.ImageLoader;
import cn.way.wandroid.imageloader.loader.ImageWorker;

public class FocusImageFragment extends Fragment {
    private static final String IMAGE_DATA_EXTRA = "extra_image_data";
    private String mImageUrl;
    private ImageView mImageView;
    private ImageLoader imageLoader;
    private Integer layoutId;
    private OnClickListener clickListener;
    public ImageLoader getImageLoader() {
		return imageLoader;
	}

	public void setImageLoader(ImageLoader imageLoader) {
		this.imageLoader = imageLoader;
	}

    public static FocusImageFragment newInstance(int layoutId,ImageLoader imageLoader,String imageUrl,OnClickListener clickListener) {
        final FocusImageFragment f = new FocusImageFragment();
        f.setImageLoader(imageLoader);
        f.setLayoutId(layoutId);
        f.setClickListener(clickListener);
        final Bundle args = new Bundle();
        args.putString(IMAGE_DATA_EXTRA, imageUrl);
        f.setArguments(args);

        return f;
    }

    /**
     * Populate image using a url from extras, use the convenience factory method
     * {@link FocusImageFragment#newInstance(String)} to create this fragment.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mImageUrl = getArguments() != null ? getArguments().getString(IMAGE_DATA_EXTRA) : null;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate and locate the main ImageView
        final View v = inflater.inflate(getLayoutId(), container, false);
        mImageView = (ImageView) v.findViewById(R.id.imageView);
        mImageView.setOnClickListener(clickListener);
        return v;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (imageLoader!=null) {
            imageLoader.loadImage(mImageUrl, mImageView);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mImageView != null) {
            // Cancel any pending image work
            ImageWorker.cancelWork(mImageView);
            mImageView.setImageDrawable(null);
        }
    }

	
	public OnClickListener getClickListener() {
		return clickListener;
	}

	public void setClickListener(OnClickListener clickListener) {
		this.clickListener = clickListener;
	}

	public int getLayoutId() {
		return layoutId;
	}

	public void setLayoutId(int layoutId) {
		this.layoutId = layoutId;
	}
}

@@ -351,79 +351,18 @@
 der.
-loader.ImageLoader;%0Aimport cn.way.wandroid.imageloader.loader.ImageWork
+ImageManag
 er;%0A
@@ -552,45 +552,8 @@
 ew;%0A
-    private ImageLoader imageLoader;%0A
     
@@ -624,168 +624,8 @@
 ner;
-%0A    public ImageLoader getImageLoader() %7B%0A%09%09return imageLoader;%0A%09%7D%0A%0A%09public void setImageLoader(ImageLoader imageLoader) %7B%0A%09%09this.imageLoader = imageLoader;%0A%09%7D
 %0A%0A  
@@ -688,32 +688,8 @@
 tId,
-ImageLoader imageLoader,
 Stri
@@ -800,47 +800,8 @@
 ();%0A
-        f.setImageLoader(imageLoader);%0A
     
@@ -996,17 +996,16 @@
 (args);%0A
-%0A
         
@@ -1952,56 +1952,44 @@
     
-if (imageLoader!=null) %7B%0A            imageLoader
+ImageManager.instance(getActivity())
 .loa
@@ -2018,26 +2018,17 @@
 geView);
-%0A        %7D
+ 
 %0A    %7D%0A%0A
@@ -2136,101 +2136,8 @@
 ) %7B%0A
-            // Cancel any pending image work%0A            ImageWorker.cancelWork(mImageView);%0A
     

remove old image loader