Search in sources :

Example 1 with DefaultIconTextItem

use of carbon.component.DefaultIconTextItem in project Carbon by ZieIony.

the class IconTextListItemActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listcomponent);
    Samples.initToolbar(this, getString(R.string.iconTextListItemActivity_title));
    RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
    recycler.setLayoutManager(new LinearLayoutManager(this));
    RowListAdapter adapter = new RowListAdapter<>(DefaultIconTextItem.class, IconTextRow::new);
    adapter.addFactory(DefaultIconSearchItem.class, parent -> new IconSearchRow(parent, new ArraySearchDataProvider(new String[] {}), filterResults -> {
    }));
    recycler.setAdapter(adapter);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(new ColorDrawable(Carbon.getThemeColor(this, R.attr.carbon_dividerColor)), getResources().getDimensionPixelSize(R.dimen.carbon_1dip));
    dividerItemDecoration.setDrawRules(position -> position == 0);
    recycler.addItemDecoration(dividerItemDecoration);
    VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.ic_face_24px);
    adapter.setItems(Arrays.asList(new DefaultIconSearchItem(this), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text")));
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) IconSearchRow(carbon.component.IconSearchRow) DividerItemDecoration(carbon.recycler.DividerItemDecoration) IconTextRow(carbon.component.IconTextRow) ColorDrawable(android.graphics.drawable.ColorDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultIconTextItem(carbon.component.DefaultIconTextItem) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) Carbon(carbon.Carbon) RecyclerView(carbon.widget.RecyclerView) SamplesActivity(tk.zielony.carbonsamples.SamplesActivity) VectorDrawable(carbon.drawable.VectorDrawable) R(tk.zielony.carbonsamples.R) RowListAdapter(carbon.recycler.RowListAdapter) Nullable(android.support.annotation.Nullable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider) Samples(tk.zielony.carbonsamples.Samples) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) ColorDrawable(android.graphics.drawable.ColorDrawable) IconTextRow(carbon.component.IconTextRow) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(carbon.recycler.DividerItemDecoration) DefaultIconTextItem(carbon.component.DefaultIconTextItem) IconSearchRow(carbon.component.IconSearchRow) VectorDrawable(carbon.drawable.VectorDrawable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Carbon (carbon.Carbon)1 DefaultIconSearchItem (carbon.component.DefaultIconSearchItem)1 DefaultIconTextItem (carbon.component.DefaultIconTextItem)1 IconSearchRow (carbon.component.IconSearchRow)1 IconTextRow (carbon.component.IconTextRow)1 VectorDrawable (carbon.drawable.VectorDrawable)1 DividerItemDecoration (carbon.recycler.DividerItemDecoration)1 RowListAdapter (carbon.recycler.RowListAdapter)1 ArraySearchDataProvider (carbon.widget.ArraySearchDataProvider)1 RecyclerView (carbon.widget.RecyclerView)1 Arrays (java.util.Arrays)1 R (tk.zielony.carbonsamples.R)1 Samples (tk.zielony.carbonsamples.Samples)1 SamplesActivity (tk.zielony.carbonsamples.SamplesActivity)1