Search in sources :

Example 1 with BooksAdapter

use of com.shizhefei.test.view.adapters.BooksAdapter 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 BooksAdapter

use of com.shizhefei.test.view.adapters.BooksAdapter 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 BooksAdapter

use of com.shizhefei.test.view.adapters.BooksAdapter 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 BooksAdapter

use of com.shizhefei.test.view.adapters.BooksAdapter in project MVCHelper by LuckyJayce.

the class Volley_OKHttp_GridViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_girdview);
    // PullToRefreshListView refreshListView = (PullToRefreshListView)
    // findViewById(R.id.pullToRefreshListView);
    SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    // GridViewWithHeaderAndFooter gridViewWithHeaderAndFooter =
    // (GridViewWithHeaderAndFooter) findViewById(R.id.girdView);
    mvcHelper = new MVCSwipeRefreshHelper<List<Book>>(swipeRefreshLayout);
    /**
     *     设置数据源
     */
    // 用okhttp 普通请求的例子
    // mvcHelper.setDataSource(new BooksOkHttpNormal_DataSource());
    // 用mvcelper-okhttp  异步执行的例子
    mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
    // 用mvcelper-okhttp  同步执行的例子
    // mvcHelper.setDataSource(new BooksOkHttp_SyncDataSource());
    // 用volley 例子
    // mvcHelper.setDataSource(new BooksVolleyDataSource());
    // 设置AsyncHttpClient 作为网络请求的数据源
    // listViewHelper.setDataSource(new BooksOkHttpNormal_DataSource());
    // 设置适配器
    mvcHelper.setAdapter(new BooksAdapter(this), new GridViewHandler());
    // 加载数据
    mvcHelper.refresh();
}
Also used : BooksOkHttp_AsyncDataSource(com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource) BooksAdapter(com.shizhefei.test.view.adapters.BooksAdapter) List(java.util.List) GridViewHandler(in.srain.cube.views.GridViewHandler) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout)

Aggregations

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