Search in sources :

Example 6 with CubeImageView

use of in.srain.cube.image.CubeImageView in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class StoreHouseUsingStringArray method createView.

@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_storehouse_header, null);
    mTitlePre = getString(R.string.ptr_demo_storehouse_header_using_string_array_in_title);
    setHeaderTitle(mTitlePre + "R.array.storehouse");
    // loading image
    CubeImageView imageView = (CubeImageView) view.findViewById(R.id.store_house_ptr_image);
    ImageLoader imageLoader = ImageLoaderFactory.create(getContext());
    String pic = "http://img5.duitang.com/uploads/item/201406/28/20140628122218_fLQyP.thumb.jpeg";
    imageView.loadImage(imageLoader, pic);
    final PtrFrameLayout frame = (PtrFrameLayout) view.findViewById(R.id.store_house_ptr_frame);
    final StoreHouseHeader header = new StoreHouseHeader(getContext());
    header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);
    // using string array from resource xml file
    header.initWithStringArray(R.array.storehouse);
    frame.setDurationToCloseHeader(1500);
    frame.setHeaderView(header);
    frame.addPtrUIHandler(header);
    frame.postDelayed(new Runnable() {

        @Override
        public void run() {
            frame.autoRefresh(false);
        }
    }, 100);
    // change header after loaded
    frame.addPtrUIHandler(new PtrUIHandler() {

        private int mLoadTime = 0;

        @Override
        public void onUIReset(PtrFrameLayout frame) {
            mLoadTime++;
            if (mLoadTime % 2 == 0) {
                header.setScale(1);
                header.initWithStringArray(R.array.storehouse);
            } else {
                header.setScale(0.5f);
                header.initWithStringArray(R.array.akta);
            }
        }

        @Override
        public void onUIRefreshPrepare(PtrFrameLayout frame) {
            if (mLoadTime % 2 == 0) {
                setHeaderTitle(mTitlePre + "R.array.storehouse");
            } else {
                setHeaderTitle(mTitlePre + "R.array.akta");
            }
        }

        @Override
        public void onUIRefreshBegin(PtrFrameLayout frame) {
        }

        @Override
        public void onUIRefreshComplete(PtrFrameLayout frame) {
        }

        @Override
        public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, PtrIndicator ptrIndicator) {
        }
    });
    frame.setPtrHandler(new PtrHandler() {

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return true;
        }

        @Override
        public void onRefreshBegin(final PtrFrameLayout frame) {
            frame.postDelayed(new Runnable() {

                @Override
                public void run() {
                    frame.refreshComplete();
                }
            }, 2000);
        }
    });
    return view;
}
Also used : PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) PtrUIHandler(in.srain.cube.views.ptr.PtrUIHandler) PtrHandler(in.srain.cube.views.ptr.PtrHandler) CubeImageView(in.srain.cube.image.CubeImageView) View(android.view.View) StoreHouseHeader(in.srain.cube.views.ptr.header.StoreHouseHeader) CubeImageView(in.srain.cube.image.CubeImageView) PtrIndicator(in.srain.cube.views.ptr.indicator.PtrIndicator) ImageLoader(in.srain.cube.image.ImageLoader)

Aggregations

View (android.view.View)6 CubeImageView (in.srain.cube.image.CubeImageView)6 ImageLoader (in.srain.cube.image.ImageLoader)5 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)5 PtrHandler (in.srain.cube.views.ptr.PtrHandler)5 StoreHouseHeader (in.srain.cube.views.ptr.header.StoreHouseHeader)3 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 TransitionDrawable (android.graphics.drawable.TransitionDrawable)2 ImageTask (in.srain.cube.image.ImageTask)2 ImageLoadHandler (in.srain.cube.image.iface.ImageLoadHandler)2 PtrUIHandler (in.srain.cube.views.ptr.PtrUIHandler)2 PtrIndicator (in.srain.cube.views.ptr.indicator.PtrIndicator)2 ImageView (android.widget.ImageView)1 RentalsSunHeaderView (in.srain.cube.views.ptr.demo.ui.header.RentalsSunHeaderView)1 MaterialHeader (in.srain.cube.views.ptr.header.MaterialHeader)1