Search in sources :

Example 1 with PtrClassicFrameLayout

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

the class WithTextViewInFrameLayoutFragment method createView.

@Override
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHeaderTitle(R.string.ptr_demo_block_frame_layout);
    final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_viewgroup, container, false);
    final PtrClassicFrameLayout ptrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.fragment_rotate_header_with_view_group_frame);
    ptrFrame.setPtrHandler(new PtrHandler() {

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

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

        @Override
        public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
            return true;
        }
    });
    ptrFrame.setLastUpdateTimeRelateObject(this);
    // the following are default settings
    ptrFrame.setResistance(1.7f);
    ptrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
    ptrFrame.setDurationToClose(200);
    ptrFrame.setDurationToCloseHeader(1000);
    // default is false
    ptrFrame.setPullToRefresh(false);
    // default is true
    ptrFrame.setKeepHeaderWhenRefresh(true);
    // scroll then refresh
    // comment in base fragment
    ptrFrame.postDelayed(new Runnable() {

        @Override
        public void run() {
        // ptrFrame.autoRefresh();
        }
    }, 150);
    setupViews(ptrFrame);
    return contentView;
}
Also used : PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) PtrHandler(in.srain.cube.views.ptr.PtrHandler) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) View(android.view.View)

Example 2 with PtrClassicFrameLayout

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

use of in.srain.cube.views.ptr.PtrClassicFrameLayout in project MVCHelper by LuckyJayce.

the class UltraActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ultra);
    /*
		 * 配置PtrClassicFrameLayout的刷新样式
		 */
    PtrClassicFrameLayout mPtrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
    final MaterialHeader header = new MaterialHeader(this);
    header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
    header.setPadding(0, dipToPix(this, 15), 0, dipToPix(this, 10));
    header.setPtrFrameLayout(mPtrFrameLayout);
    mPtrFrameLayout.setLoadingMinTime(800);
    mPtrFrameLayout.setDurationToCloseHeader(800);
    mPtrFrameLayout.setHeaderView(header);
    mPtrFrameLayout.addPtrUIHandler(header);
    mvcHelper = new MVCUltraHelper<List<Book>>(mPtrFrameLayout);
    // 设置数据源
    mvcHelper.setDataSource(new BooksDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new BooksAdapter(this));
    // 加载数据
    mvcHelper.refresh();
}
Also used : BooksAdapter(com.shizhefei.test.view.adapters.BooksAdapter) PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) MaterialHeader(in.srain.cube.views.ptr.header.MaterialHeader) PtrFrameLayout(in.srain.cube.views.ptr.PtrFrameLayout) List(java.util.List) BooksDataSource(com.shizhefei.test.models.datasource.BooksDataSource)

Example 4 with PtrClassicFrameLayout

use of in.srain.cube.views.ptr.PtrClassicFrameLayout in project MVCHelper by LuckyJayce.

the class UltraRecyclerViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ultrarecyclerview);
    PtrClassicFrameLayout mPtrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    mvcHelper = new MVCUltraHelper<>(mPtrFrameLayout);
    // 设置数据源
    mvcHelper.setDataSource(new BooksDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new ReBooksAdapter(this));
    // 加载数据
    mvcHelper.refresh();
}
Also used : PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) ReBooksAdapter(com.shizhefei.test.view.adapters.ReBooksAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BooksDataSource(com.shizhefei.test.models.datasource.BooksDataSource)

Example 5 with PtrClassicFrameLayout

use of in.srain.cube.views.ptr.PtrClassicFrameLayout in project MVCHelper by LuckyJayce.

the class ListTaskActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ultrarecyclerview);
    PtrClassicFrameLayout mPtrFrameLayout = (PtrClassicFrameLayout) findViewById(R.id.rotate_header_list_view_frame);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    taskHelper = new TaskHelper<>(new MemoryCacheStore(200));
    // 注册全局的task执行回调
    taskHelper.registerCallBack(new ICallback<MovieAmount>() {

        @Override
        public void onPreExecute(Object task) {
            Log.d("pppp", "task:" + task);
        }

        @Override
        public void onProgress(Object task, int percent, long current, long total, Object extraData) {
        }

        @Override
        public void onPostExecute(Object task, Code code, Exception exception, MovieAmount movieAmount) {
            Log.d("pppp", "task:" + task + " code:" + code);
        }
    });
    mvcHelper = new MVCUltraHelper<>(mPtrFrameLayout);
    // 设置数据源
    mvcHelper.setDataSource(new MoviesDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new MoviesAdapter(taskHelper));
    // 加载数据
    mvcHelper.refresh();
}
Also used : MemoryCacheStore(com.shizhefei.task.imp.MemoryCacheStore) MoviesAdapter(com.shizhefei.test.view.adapters.MoviesAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Code(com.shizhefei.task.Code) MoviesDataSource(com.shizhefei.test.models.datasource.MoviesDataSource) PtrClassicFrameLayout(in.srain.cube.views.ptr.PtrClassicFrameLayout) MovieAmount(com.shizhefei.test.models.enties.MovieAmount) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

PtrClassicFrameLayout (in.srain.cube.views.ptr.PtrClassicFrameLayout)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)3 View (android.view.View)2 BooksDataSource (com.shizhefei.test.models.datasource.BooksDataSource)2 Data3 (com.shizhefei.mvc.data.Data3)1 Code (com.shizhefei.task.Code)1 MemoryCacheStore (com.shizhefei.task.imp.MemoryCacheStore)1 BookDetailDataSource (com.shizhefei.test.models.datasource.BookDetailDataSource)1 MovieDetailDataSource (com.shizhefei.test.models.datasource.MovieDetailDataSource)1 MoviesDataSource (com.shizhefei.test.models.datasource.MoviesDataSource)1 Book (com.shizhefei.test.models.enties.Book)1 Discuss (com.shizhefei.test.models.enties.Discuss)1 Movie (com.shizhefei.test.models.enties.Movie)1 MovieAmount (com.shizhefei.test.models.enties.MovieAmount)1 BooksAdapter (com.shizhefei.test.view.adapters.BooksAdapter)1 MovieDetailAdapter (com.shizhefei.test.view.adapters.MovieDetailAdapter)1 MoviesAdapter (com.shizhefei.test.view.adapters.MoviesAdapter)1 ReBooksAdapter (com.shizhefei.test.view.adapters.ReBooksAdapter)1