Search in sources :

Example 1 with DemoHeaderFooterAdapter

use of com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter in project android-advancedrecyclerview by h6ah4i.

the class ExpandableWithHeaderFooterExampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_minimal);
    OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {

        @Override
        public void onItemClicked(String message) {
            View container = findViewById(R.id.container);
            Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
        }
    };
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    // Setup expandable feature and RecyclerView
    RecyclerViewExpandableItemManager expMgr = new RecyclerViewExpandableItemManager(null);
    // Create wrapped adapter:  MyItemAdapter -> expMgr.createWrappedAdapter -> MyHeaderFooterAdapter
    RecyclerView.Adapter adapter;
    adapter = new SimpleDemoExpandableItemAdapter(expMgr, clickListener);
    adapter = expMgr.createWrappedAdapter(adapter);
    adapter = new DemoHeaderFooterAdapter(adapter, clickListener);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    // NOTE: need to disable change animations to ripple effect work properly
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    expMgr.attachRecyclerView(recyclerView);
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) OnListItemClickMessageListener(com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener) SimpleDemoExpandableItemAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoExpandableItemAdapter) RecyclerView(android.support.v7.widget.RecyclerView) DemoHeaderFooterAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)

Example 2 with DemoHeaderFooterAdapter

use of com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter in project android-advancedrecyclerview by h6ah4i.

the class CompositionAllExampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_minimal);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {

        @Override
        public void onItemClicked(String message) {
            View container = findViewById(R.id.container);
            Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
        }
    };
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    RecyclerView.Adapter adapter;
    adapter = createComposedAdapter(recyclerView, clickListener);
    adapter = new DemoHeaderFooterAdapter(adapter, clickListener);
    recyclerView.setAdapter(adapter);
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) OnListItemClickMessageListener(com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DemoHeaderFooterAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 3 with DemoHeaderFooterAdapter

use of com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter in project android-advancedrecyclerview by h6ah4i.

the class MinimalHeaderFooterExampleActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo_minimal);
    OnListItemClickMessageListener clickListener = new OnListItemClickMessageListener() {

        @Override
        public void onItemClicked(String message) {
            View container = findViewById(R.id.container);
            Snackbar.make(container, message, Snackbar.LENGTH_SHORT).show();
        }
    };
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    RecyclerView.Adapter adapter;
    adapter = new SimpleDemoItemAdapter(clickListener);
    adapter = new DemoHeaderFooterAdapter(adapter, clickListener);
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
Also used : OnListItemClickMessageListener(com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener) RecyclerView(android.support.v7.widget.RecyclerView) DemoHeaderFooterAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) SimpleDemoItemAdapter(com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 DemoHeaderFooterAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.DemoHeaderFooterAdapter)3 OnListItemClickMessageListener (com.h6ah4i.android.example.advrecyclerview.common.adapter.OnListItemClickMessageListener)3 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)2 SimpleDemoExpandableItemAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoExpandableItemAdapter)1 SimpleDemoItemAdapter (com.h6ah4i.android.example.advrecyclerview.common.adapter.SimpleDemoItemAdapter)1 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)1