Search in sources :

Example 1 with PtrDefaultHandler

use of in.srain.cube.views.ptr.PtrDefaultHandler 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)

Example 2 with PtrDefaultHandler

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

the class HideHeader method setupViews.

@Override
protected void setupViews(final PtrClassicFrameLayout ptrFrame) {
    setHeaderTitle(R.string.ptr_demo_block_hide_header);
    ptrFrame.setKeepHeaderWhenRefresh(false);
    final View loading = Utils.createSimpleLoadingTip(getContext());
    mTitleHeaderBar.getRightViewContainer().addView(loading);
    ptrFrame.setPtrHandler(new PtrDefaultHandler() {

        @Override
        public void onRefreshBegin(PtrFrameLayout frame) {
            loading.setVisibility(View.VISIBLE);
            frame.postDelayed(new Runnable() {

                @Override
                public void run() {
                    loading.setVisibility(View.INVISIBLE);
                    ptrFrame.refreshComplete();
                }
            }, 1500);
        }

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

Example 3 with PtrDefaultHandler

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

the class WithLongPressFragment method createView.

@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mImageLoader = ImageLoaderFactory.create(getActivity());
    View view = inflater.inflate(R.layout.fragment_with_long_press, null);
    setHeaderTitle(R.string.ptr_demo_block_with_long_press);
    final PtrFrameLayout ptrFrameLayout = (PtrFrameLayout) view.findViewById(R.id.with_long_press_list_view_frame);
    ListView listView = (ListView) view.findViewById(R.id.with_long_press_list_view);
    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Toast.makeText(getContext(), "Long Pressed: " + id, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    final ListViewDataAdapter<String> listViewDataAdapter = new ListViewDataAdapter<String>();
    listViewDataAdapter.setViewHolderClass(this, ViewHolder.class);
    ptrFrameLayout.setPtrHandler(new PtrDefaultHandler() {

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

                @Override
                public void run() {
                    listViewDataAdapter.getDataList().clear();
                    listViewDataAdapter.getDataList().addAll(Arrays.asList(Images.imageUrls));
                    listViewDataAdapter.notifyDataSetChanged();
                    ptrFrameLayout.refreshComplete();
                }
            }, 2000);
        }
    });
    ptrFrameLayout.postDelayed(new Runnable() {

        @Override
        public void run() {
            ptrFrameLayout.autoRefresh();
        }
    }, 100);
    listView.setAdapter(listViewDataAdapter);
    return view;
}
Also used : PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) CubeImageView(in.srain.cube.image.CubeImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) ListViewDataAdapter(in.srain.cube.views.list.ListViewDataAdapter) AdapterView(android.widget.AdapterView) PtrDefaultHandler(in.srain.cube.views.ptr.PtrDefaultHandler)

Aggregations

View (android.view.View)3 PtrDefaultHandler (in.srain.cube.views.ptr.PtrDefaultHandler)3 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)3 AdapterView (android.widget.AdapterView)1 ListView (android.widget.ListView)1 CubeImageView (in.srain.cube.image.CubeImageView)1 ListViewDataAdapter (in.srain.cube.views.list.ListViewDataAdapter)1 PtrClassicFrameLayout (in.srain.cube.views.ptr.PtrClassicFrameLayout)1