Search in sources :

Example 1 with ReBooksAdapter

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

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

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

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

Example 5 with ReBooksAdapter

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

Aggregations

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