Search in sources :

Example 1 with PtrFrameLayout

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

the class PullToRefreshActivity method refreshingMaterial.

//    void refreshingRental() {
//        rentalsSunHeaderView = new RentalsSunHeaderView(this);
//        rentalsSunHeaderView.setUp(ultimateRecyclerView.mPtrFrameLayout);
//
//        ultimateRecyclerView.mPtrFrameLayout.removePtrUIHandler(materialHeader);
//        ultimateRecyclerView.mPtrFrameLayout.removePtrUIHandler(storeHouseHeader);
//        ultimateRecyclerView.mPtrFrameLayout.setHeaderView(rentalsSunHeaderView);
//        ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(rentalsSunHeaderView);
//        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() {
//                        simpleRecyclerViewAdapter.insert("Refresh things", 0);
//                        //   ultimateRecyclerView.scrollBy(0, -50);
//                        linearLayoutManager.scrollToPosition(0);
//                        ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
//                        changeHeaderHandler.sendEmptyMessageDelayed(3, 500);
//                    }
//                }, 1800);
//            }
//        });
//
//    }
void refreshingMaterial() {
    materialHeader = new MaterialHeader(this);
    int[] colors = getResources().getIntArray(R.array.google_colors);
    materialHeader.setColorSchemeColors(colors);
    materialHeader.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
    materialHeader.setPadding(0, 15, 0, 10);
    materialHeader.setPtrFrameLayout(ultimateRecyclerView.mPtrFrameLayout);
    ultimateRecyclerView.mPtrFrameLayout.autoRefresh(false);
    ultimateRecyclerView.mPtrFrameLayout.removePtrUIHandler(storeHouseHeader);
    ultimateRecyclerView.mPtrFrameLayout.setHeaderView(materialHeader);
    ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(materialHeader);
    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() {
                    //  simpleRecyclerViewAdapter.insertLast("Refresh things");
                    //   ultimateRecyclerView.scrollBy(0, -50);
                    //   linearLayoutManager.scrollToPosition(0);
                    ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
                //   changeHeaderHandler.sendEmptyMessageDelayed(2, 500);
                }
            }, 1800);
        }
    });
}
Also used : MaterialHeader(in.srain.cube.views.ptr.header.MaterialHeader) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) PtrHandler(in.srain.cube.views.ptr.PtrHandler) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View)

Example 2 with PtrFrameLayout

use of in.srain.cube.views.ptr.PtrFrameLayout 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 3 with PtrFrameLayout

use of in.srain.cube.views.ptr.PtrFrameLayout 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 4 with PtrFrameLayout

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

the class RentalsStyleFragment method createView.

@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_materail_style, null);
    setHeaderTitle(R.string.ptr_demo_rentals_style);
    final CubeImageView imageView = (CubeImageView) view.findViewById(R.id.material_style_image_view);
    final ImageLoader imageLoader = ImageLoaderFactory.create(getContext());
    final PtrFrameLayout frame = (PtrFrameLayout) view.findViewById(R.id.material_style_ptr_frame);
    // header
    final RentalsSunHeaderView header = new RentalsSunHeaderView(getContext());
    header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
    header.setPadding(0, LocalDisplay.dp2px(15), 0, LocalDisplay.dp2px(10));
    header.setUp(frame);
    frame.setLoadingMinTime(1000);
    frame.setDurationToCloseHeader(1500);
    frame.setHeaderView(header);
    frame.addPtrUIHandler(header);
    // frame.setPullToRefresh(true);
    frame.postDelayed(new Runnable() {

        @Override
        public void run() {
            frame.autoRefresh(true);
        }
    }, 100);
    frame.setPtrHandler(new PtrHandler() {

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

        @Override
        public void onRefreshBegin(final PtrFrameLayout frame) {
            if (mImageHasLoaded) {
                long delay = 1500;
                frame.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        frame.refreshComplete();
                    }
                }, delay);
            } else {
                mStartLoadingTime = System.currentTimeMillis();
                imageView.loadImage(imageLoader, mUrl);
            }
        }
    });
    ImageLoadHandler imageLoadHandler = new ImageLoadHandler() {

        @Override
        public void onLoading(ImageTask imageTask, CubeImageView cubeImageView) {
        }

        @Override
        public void onLoadFinish(ImageTask imageTask, final CubeImageView cubeImageView, final BitmapDrawable bitmapDrawable) {
            mImageHasLoaded = true;
            long delay = 1500;
            frame.postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (cubeImageView != null && bitmapDrawable != null) {
                        TransitionDrawable w1 = new TransitionDrawable(new Drawable[] { new ColorDrawable(Color.WHITE), (Drawable) bitmapDrawable });
                        imageView.setImageDrawable(w1);
                        w1.startTransition(200);
                    }
                    frame.refreshComplete();
                }
            }, delay);
        }

        @Override
        public void onLoadError(ImageTask imageTask, CubeImageView cubeImageView, int i) {
        }
    };
    imageLoader.setImageLoadHandler(imageLoadHandler);
    return view;
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) PtrHandler(in.srain.cube.views.ptr.PtrHandler) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) TransitionDrawable(android.graphics.drawable.TransitionDrawable) ImageLoadHandler(in.srain.cube.image.iface.ImageLoadHandler) BitmapDrawable(android.graphics.drawable.BitmapDrawable) CubeImageView(in.srain.cube.image.CubeImageView) RentalsSunHeaderView(in.srain.cube.views.ptr.demo.ui.header.RentalsSunHeaderView) View(android.view.View) ColorDrawable(android.graphics.drawable.ColorDrawable) CubeImageView(in.srain.cube.image.CubeImageView) ImageTask(in.srain.cube.image.ImageTask) ImageLoader(in.srain.cube.image.ImageLoader) RentalsSunHeaderView(in.srain.cube.views.ptr.demo.ui.header.RentalsSunHeaderView)

Example 5 with PtrFrameLayout

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

the class EvenOnlyATextView method createView.

public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHeaderTitle(R.string.ptr_demo_block_only_text_view);
    final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_textview, container, false);
    final PtrClassicFrameLayout ptrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.fragment_rotate_header_with_text_view_frame);
    ptrFrame.setLastUpdateTimeRelateObject(this);
    ptrFrame.setPtrHandler(new PtrDefaultHandler() {

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

                @Override
                public void run() {
                    ptrFrame.refreshComplete();
                }
            }, 1500);
        }

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return true;
        }
    });
    return contentView;
}
Also used : PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) View(android.view.View) PtrDefaultHandler(in.srain.cube.views.ptr.PtrDefaultHandler)

Aggregations

View (android.view.View)20 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)20 PtrHandler (in.srain.cube.views.ptr.PtrHandler)17 CubeImageView (in.srain.cube.image.CubeImageView)9 StoreHouseHeader (in.srain.cube.views.ptr.header.StoreHouseHeader)7 ImageLoader (in.srain.cube.image.ImageLoader)5 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)3 UltimateRecyclerView (com.marshalchen.ultimaterecyclerview.UltimateRecyclerView)3 JsonData (in.srain.cube.request.JsonData)3 PtrDefaultHandler (in.srain.cube.views.ptr.PtrDefaultHandler)3 PtrUIHandler (in.srain.cube.views.ptr.PtrUIHandler)3 MaterialStyleFragment (in.srain.cube.views.ptr.demo.ui.MaterialStyleFragment)3 PtrIndicator (in.srain.cube.views.ptr.indicator.PtrIndicator)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 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2