Search in sources :

Example 1 with BooksDataSource

use of com.shizhefei.test.models.datasource.BooksDataSource in project MVCHelper by LuckyJayce.

the class SwipeRefreshActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swiperefresh);
    // PullToRefreshListView refreshListView = (PullToRefreshListView)
    // findViewById(R.id.pullToRefreshListView);
    ListView listView = (ListView) findViewById(R.id.listView);
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    mvcHelper = new MVCSwipeRefreshHelper<>(swipeRefreshLayout);
    // 设置数据源
    mvcHelper.setDataSource(new BooksDataSource());
    // 设置适配器
    mvcHelper.setAdapter(new BooksAdapter(this));
    // 加载数据
    mvcHelper.refresh();
    listView.setOnItemClickListener(onItemClickListener);
}
Also used : BooksAdapter(com.shizhefei.test.view.adapters.BooksAdapter) ListView(android.widget.ListView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) BooksDataSource(com.shizhefei.test.models.datasource.BooksDataSource)

Example 2 with BooksDataSource

use of com.shizhefei.test.models.datasource.BooksDataSource in project MVCHelper by LuckyJayce.

the class PullrefshActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pullrefsh);
    PullToRefreshListView refreshListView = (PullToRefreshListView) findViewById(R.id.pullToRefreshListView);
    mvcHelper = new MVCPullrefshHelper<>(refreshListView);
    // 设置数据源
    mvcHelper.setDataSource(DataSources.concatWith(new InitTokenTask(), new BooksDataSource()));
    // 设置适配器
    mvcHelper.setAdapter(new BooksAdapter(this));
    // 加载数据
    mvcHelper.refresh();
}
Also used : BooksAdapter(com.shizhefei.test.view.adapters.BooksAdapter) PullToRefreshListView(com.handmark.pulltorefresh.library.PullToRefreshListView) InitTokenTask(com.shizhefei.test.models.task.InitTokenTask) BooksDataSource(com.shizhefei.test.models.datasource.BooksDataSource)

Example 3 with BooksDataSource

use of com.shizhefei.test.models.datasource.BooksDataSource 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 BooksDataSource

use of com.shizhefei.test.models.datasource.BooksDataSource 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)

Aggregations

BooksDataSource (com.shizhefei.test.models.datasource.BooksDataSource)4 BooksAdapter (com.shizhefei.test.view.adapters.BooksAdapter)3 PtrClassicFrameLayout (in.srain.cube.views.ptr.PtrClassicFrameLayout)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ListView (android.widget.ListView)1 PullToRefreshListView (com.handmark.pulltorefresh.library.PullToRefreshListView)1 InitTokenTask (com.shizhefei.test.models.task.InitTokenTask)1 ReBooksAdapter (com.shizhefei.test.view.adapters.ReBooksAdapter)1 PtrFrameLayout (in.srain.cube.views.ptr.PtrFrameLayout)1 MaterialHeader (in.srain.cube.views.ptr.header.MaterialHeader)1 List (java.util.List)1