Search in sources :

Example 1 with StoreHouseHeader

use of in.srain.cube.views.ptr.header.StoreHouseHeader in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class StoreHouseUsingPointList method createView.

@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHeaderTitle(R.string.ptr_demo_storehouse_header_using_point_list);
    View view = inflater.inflate(R.layout.fragment_storehouse_header, null);
    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);
    // header
    final StoreHouseHeader header = new StoreHouseHeader(getContext());
    header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);
    header.initWithPointList(getPointList());
    frame.setDurationToCloseHeader(3000);
    frame.setHeaderView(header);
    frame.addPtrUIHandler(header);
    frame.postDelayed(new Runnable() {

        @Override
        public void run() {
            frame.autoRefresh(false);
        }
    }, 100);
    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) PtrHandler(in.srain.cube.views.ptr.PtrHandler) StoreHouseHeader(in.srain.cube.views.ptr.header.StoreHouseHeader) CubeImageView(in.srain.cube.image.CubeImageView) ImageLoader(in.srain.cube.image.ImageLoader) CubeImageView(in.srain.cube.image.CubeImageView) View(android.view.View)

Example 2 with StoreHouseHeader

use of in.srain.cube.views.ptr.header.StoreHouseHeader in project android-Ultra-Pull-To-Refresh by liaohuqiu.

the class StoreHouseUsingString method createView.

@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_storehouse_header, null);
    mTitlePre = getString(R.string.ptr_demo_storehouse_header_using_string_in_title);
    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);
    // header
    final StoreHouseHeader header = new StoreHouseHeader(getContext());
    header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);
    /**
     * using a string, support: A-Z 0-9 - .
     * you can add more letters by {@link in.srain.cube.views.ptr.header.StoreHousePath#addChar}
     */
    header.initWithString(mStringList[0]);
    setHeaderTitle(mTitlePre + mStringList[0]);
    // for changing string
    frame.addPtrUIHandler(new PtrUIHandler() {

        private int mLoadTime = 0;

        @Override
        public void onUIReset(PtrFrameLayout frame) {
            mLoadTime++;
            String string = mStringList[mLoadTime % mStringList.length];
            header.initWithString(string);
        }

        @Override
        public void onUIRefreshPrepare(PtrFrameLayout frame) {
            String string = mStringList[mLoadTime % mStringList.length];
            setHeaderTitle(mTitlePre + string);
        }

        @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.setDurationToCloseHeader(3000);
    frame.setHeaderView(header);
    frame.addPtrUIHandler(header);
    frame.postDelayed(new Runnable() {

        @Override
        public void run() {
            frame.autoRefresh(false);
        }
    }, 100);
    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)

Example 3 with StoreHouseHeader

use of in.srain.cube.views.ptr.header.StoreHouseHeader in project UltimateRecyclerView by cymcsg.

the class PullToRefreshActivity method refreshingString.

void refreshingString() {
    storeHouseHeader = new StoreHouseHeader(this);
    // header.setPadding(0, 15, 0, 0);
    storeHouseHeader.initWithString("XCode Big Air");
    // header.initWithStringArray(R.array.akta);
    ultimateRecyclerView.mPtrFrameLayout.removePtrUIHandler(materialHeader);
    ultimateRecyclerView.mPtrFrameLayout.setHeaderView(storeHouseHeader);
    ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(storeHouseHeader);
    ultimateRecyclerView.mPtrFrameLayout.autoRefresh(false);
    ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() {

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
            boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
            return canbePullDown;
        }

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

                @Override
                public void run() {
                    onFireRefresh();
                }
            }, 1800);
        }
    });
}
Also used : PtrHandler(in.srain.cube.views.ptr.PtrHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) StoreHouseHeader(in.srain.cube.views.ptr.header.StoreHouseHeader) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 4 with StoreHouseHeader

use of in.srain.cube.views.ptr.header.StoreHouseHeader in project UltimateRecyclerView by cymcsg.

the class PullToRefreshActivity method refreshingStringArray.

// RentalsSunHeaderView rentalsSunHeaderView;
private void refreshingStringArray() {
    storeHouseHeader = new StoreHouseHeader(this);
    storeHouseHeader.setPadding(0, 15, 0, 0);
    // using string array from resource xml file
    storeHouseHeader.initWithStringArray(R.array.storehouse);
    ultimateRecyclerView.mPtrFrameLayout.setDurationToCloseHeader(1500);
    ultimateRecyclerView.mPtrFrameLayout.removePtrUIHandler(materialHeader);
    ultimateRecyclerView.mPtrFrameLayout.setHeaderView(storeHouseHeader);
    ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(storeHouseHeader);
    ultimateRecyclerView.mPtrFrameLayout.autoRefresh(false);
    // change header after loaded
    ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(new PtrUIHandler() {

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

        @Override
        public void onUIRefreshPrepare(PtrFrameLayout frame) {
        }

        @Override
        public void onUIRefreshBegin(PtrFrameLayout frame) {
        }

        @Override
        public void onUIRefreshComplete(PtrFrameLayout frame) {
        }

        @Override
        public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, PtrIndicator ptrIndicator) {
        }
    });
    ultimateRecyclerView.mPtrFrameLayout.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();
                    // simpleRecyclerViewAdapter.insertLast("Refresh things");
                    // ultimateRecyclerView.scrollBy(0, -50);
                    linearLayoutManager.scrollToPosition(0);
                    ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
                    if (mLoadTime % 2 == 0)
                        changeHeaderHandler.sendEmptyMessageDelayed(1, 500);
                }
            }, 2000);
        }
    });
}
Also used : PtrUIHandler(in.srain.cube.views.ptr.PtrUIHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) PtrHandler(in.srain.cube.views.ptr.PtrHandler) StoreHouseHeader(in.srain.cube.views.ptr.header.StoreHouseHeader) PtrIndicator(in.srain.cube.views.ptr.indicator.PtrIndicator) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 5 with StoreHouseHeader

use of in.srain.cube.views.ptr.header.StoreHouseHeader in project UltimateAndroid by cymcsg.

the class UltraPullToRefreshStoreHouseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //  setContentView(R.layout);
    setContentView(R.layout.ultra_pull_refresh_store_house_activity_main);
    mPtrFrameLayout = (PtrFrameLayout) findViewById(R.id.store_house_ptr_frame);
    // the following are default settings
    mPtrFrameLayout.setResistance(1.7f);
    mPtrFrameLayout.setRatioOfHeaderHeightToRefresh(1.2f);
    mPtrFrameLayout.setDurationToClose(200);
    mPtrFrameLayout.setDurationToCloseHeader(1000);
    // default is false
    mPtrFrameLayout.setPullToRefresh(false);
    // default is true
    mPtrFrameLayout.setKeepHeaderWhenRefresh(true);
    final StoreHouseHeader header = new StoreHouseHeader(this);
    header.setPadding(0, BasicUiUtils.dip2px(this, 15.0f), 0, 0);
    /**
 * using a string, support: A-Z 0-9 - .
 * you can add more letters by {@link in.srain.cube.views.ptr.header.StoreHousePath#addChar}
 */
    header.initWithString("Marshal Chen");
    //  header.initWithStringArray(R.array.akta);
    mPtrFrameLayout.setHeaderView(header);
    mPtrFrameLayout.addPtrUIHandler(header);
    //        mPtrFrameLayout.postDelayed(new Runnable() {
    //            @Override
    //            public void run() {
    //                // ptrFrame.autoRefresh();
    //            }
    //        }, 150);
    mPtrFrameLayout.setPtrHandler(new PtrHandler() {

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
            boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
            Logs.d("canbepull----" + canbePullDown);
            return canbePullDown;
        }

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

                @Override
                public void run() {
                    mPtrFrameLayout.refreshComplete();
                }
            }, 1800);
        }
    });
}
Also used : PtrHandler(in.srain.cube.views.ptr.PtrHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) StoreHouseHeader(in.srain.cube.views.ptr.header.StoreHouseHeader) View(android.view.View)

Aggregations

View (android.view.View)7 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)7 PtrHandler (in.srain.cube.views.ptr.PtrHandler)7 StoreHouseHeader (in.srain.cube.views.ptr.header.StoreHouseHeader)7 CubeImageView (in.srain.cube.image.CubeImageView)3 ImageLoader (in.srain.cube.image.ImageLoader)3 PtrUIHandler (in.srain.cube.views.ptr.PtrUIHandler)3 PtrIndicator (in.srain.cube.views.ptr.indicator.PtrIndicator)3 UltimateRecyclerView (com.marshalchen.ultimaterecyclerview.UltimateRecyclerView)2