use of com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource in project MVCHelper by LuckyJayce.
the class JellyHeaderFragment method onCreateViewLazy.
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);
setContentView(R.layout.fragment_recyclerview);
coolRefreshView = (CoolRefreshView) findViewById(R.id.recyclerview_funnyRefreshView);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview_recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
//这个header要白色才能突出效果
coolRefreshView.setBackgroundColor(Color.WHITE);
JellyHeader jellyHeader = new JellyHeader(getContext());
jellyHeader.setDragLayoutColor(ContextCompat.getColor(getContext(), R.color.primary));
jellyHeader.setLoadingView(R.layout.layout_jelley_header);
coolRefreshView.setPullHeader(jellyHeader);
mvcHelper = new MVCCoolHelper<>(coolRefreshView);
mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
mvcHelper.setAdapter(new ReBooksAdapter(getContext()));
mvcHelper.refresh();
}
use of com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource 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();
}
use of com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource in project MVCHelper by LuckyJayce.
the class MaterialHeaderFragment method onCreateViewLazy.
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);
setContentView(R.layout.fragment_recyclerview);
coolRefreshView = (CoolRefreshView) findViewById(R.id.recyclerview_funnyRefreshView);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview_recyclerView);
coolRefreshView.setPullHeader(new MaterialHeader(getContext()));
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mvcHelper = new MVCCoolHelper<>(coolRefreshView);
mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
mvcHelper.setAdapter(new ReBooksAdapter(getContext()));
mvcHelper.refresh();
}
use of com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource in project MVCHelper by LuckyJayce.
the class PinContentMaterialHeaderFragment method onCreateViewLazy.
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);
setContentView(R.layout.fragment_recyclerview);
coolRefreshView = (CoolRefreshView) findViewById(R.id.recyclerview_funnyRefreshView);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview_recyclerView);
coolRefreshView.setPullHeader(new MaterialHeader(getContext()), true);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mvcHelper = new MVCCoolHelper<>(coolRefreshView);
mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
mvcHelper.setAdapter(new ReBooksAdapter(getContext()));
mvcHelper.refresh();
}
use of com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource in project MVCHelper by LuckyJayce.
the class StateHeaderFragment method onCreateViewLazy.
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);
setContentView(R.layout.fragment_recyclerview);
coolRefreshView = (CoolRefreshView) findViewById(R.id.recyclerview_funnyRefreshView);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview_recyclerView);
coolRefreshView.setPullHeader(new DefaultHeader());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
mvcHelper = new MVCCoolHelper<>(coolRefreshView);
mvcHelper.setDataSource(new BooksOkHttp_AsyncDataSource());
// mvcHelper.setAdapter(adapter = new ReBooksAdapter(getContext()));
//这里模拟viewAdapter 和 dataAdapter不是同一个的情况
mvcHelper.setAdapter2(adapter = new ReBooksAdapter(getContext()), new IDataAdapter<List<Book>>() {
@Override
public void notifyDataChanged(List<Book> books, boolean isRefresh) {
if (books.size() > 5) {
adapter.notifyDataChanged(books.subList(0, 5), isRefresh);
} else {
adapter.notifyDataChanged(books, isRefresh);
}
}
@Override
public List<Book> getData() {
return adapter.getData();
}
@Override
public boolean isEmpty() {
return adapter.isEmpty();
}
});
mvcHelper.refresh();
}
Aggregations