Search in sources :

Example 1 with BooksOkHttp_AsyncDataSource

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();
}
Also used : BooksOkHttp_AsyncDataSource(com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource) JellyHeader(com.shizhefei.view.coolrefreshview.header.JellyHeader) ReBooksAdapter(com.shizhefei.test.view.adapters.ReBooksAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with BooksOkHttp_AsyncDataSource

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();
}
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)

Example 3 with BooksOkHttp_AsyncDataSource

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();
}
Also used : BooksOkHttp_AsyncDataSource(com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource) MaterialHeader(com.shizhefei.view.coolrefreshview.header.MaterialHeader) ReBooksAdapter(com.shizhefei.test.view.adapters.ReBooksAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 4 with BooksOkHttp_AsyncDataSource

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();
}
Also used : BooksOkHttp_AsyncDataSource(com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource) MaterialHeader(com.shizhefei.view.coolrefreshview.header.MaterialHeader) ReBooksAdapter(com.shizhefei.test.view.adapters.ReBooksAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 5 with BooksOkHttp_AsyncDataSource

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();
}
Also used : BooksOkHttp_AsyncDataSource(com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource) Book(com.shizhefei.test.models.enties.Book) DefaultHeader(com.shizhefei.view.coolrefreshview.header.DefaultHeader) ReBooksAdapter(com.shizhefei.test.view.adapters.ReBooksAdapter) List(java.util.List) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

BooksOkHttp_AsyncDataSource (com.shizhefei.test.models.datasource.okhttp.BooksOkHttp_AsyncDataSource)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 ReBooksAdapter (com.shizhefei.test.view.adapters.ReBooksAdapter)4 MaterialHeader (com.shizhefei.view.coolrefreshview.header.MaterialHeader)2 List (java.util.List)2 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 Book (com.shizhefei.test.models.enties.Book)1 BooksAdapter (com.shizhefei.test.view.adapters.BooksAdapter)1 DefaultHeader (com.shizhefei.view.coolrefreshview.header.DefaultHeader)1 JellyHeader (com.shizhefei.view.coolrefreshview.header.JellyHeader)1 GridViewHandler (in.srain.cube.views.GridViewHandler)1