Search in sources :

Example 71 with RecyclerView

use of android.support.v7.widget.RecyclerView 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)

Example 72 with RecyclerView

use of android.support.v7.widget.RecyclerView in project Carbon by ZieIony.

the class ImageTextSubtextDateListItemActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listcomponent);
    Samples.initToolbar(this, getString(R.string.imageTextSubtextDateListItemActivity_title));
    RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
    recycler.setLayoutManager(new LinearLayoutManager(this));
    RowListAdapter adapter = new RowListAdapter<>(DefaultImageTextSubtextDateItem.class, ImageTextSubtextDateRow::new);
    adapter.addFactory(DefaultHeaderItem.class, PaddedHeaderRow.FACTORY);
    recycler.setAdapter(adapter);
    Drawable drawable = getResources().getDrawable(R.drawable.watermelon);
    String date = format.format(new Date().getTime());
    adapter.setItems(Arrays.asList(new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date)));
}
Also used : DefaultHeaderItem(carbon.component.DefaultHeaderItem) ImageTextSubtextDateRow(carbon.component.ImageTextSubtextDateRow) Drawable(android.graphics.drawable.Drawable) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) DefaultImageTextSubtextDateItem(carbon.component.DefaultImageTextSubtextDateItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Date(java.util.Date)

Example 73 with RecyclerView

use of android.support.v7.widget.RecyclerView in project Carbon by ZieIony.

the class WidgetsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.widgetsActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(CheckBoxRadioActivity.class, getString(R.string.checkBoxRadioActivity_title)), new ViewModel(ButtonsActivity.class, getString(R.string.buttonsActivity_title)), new ViewModel(CircularProgressActivity.class, getString(R.string.circularProgressActivity_title)), new ViewModel(ProgressBarsActivity.class, getString(R.string.progressBarsActivity_title)), new ViewModel(SnackbarActivity.class, getString(R.string.snackbarActivity_title)), new ViewModel(SVGActivity.class, getString(R.string.svgActivity_title)), new ViewModel(TextFieldsActivity.class, getString(R.string.textFieldsActivity_title)), new ViewModel(TabsActivity.class, getString(R.string.tabsActivity_title)), new ViewModel(ScrollViewActivity.class, getString(R.string.scrollViewActivity_title)), new ViewModel(RecyclerActivity.class, getString(R.string.recyclerViewActivity_title)), new ViewModel(ExpandableRecyclerActivity.class, getString(R.string.expandableRecyclerActivity_title)), new ViewModel(DropDownActivity.class, getString(R.string.dropDownActivityActivity_title)), new ViewModel(NavigationViewActivity.class, getString(R.string.navigationViewActivity_title)), new ViewModel(SeekBarActivity.class, getString(R.string.seekBarActivity_title)), new ViewModel(ToolbarActivity.class, getString(R.string.toolbarActivity_title)), new ViewModel(FlowLayoutActivity.class, getString(R.string.flowLayoutActivity_title)), new ViewModel(TableLayoutActivity.class, getString(R.string.tableLayoutActivity_title)), new ViewModel(FloatingActionMenuActivity.class, getString(R.string.floatingActionMenuActivity_title)), new ViewModel(BottomBarActivity.class, getString(R.string.bottomBarActivity_title), true), new ViewModel(BottomSheetActivity.class, getString(R.string.bottomSheetActivity_title), true) };
    recyclerView.setLayoutManager(getResources().getBoolean(R.bool.tablet) ? new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false) : new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new MainListAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 74 with RecyclerView

use of android.support.v7.widget.RecyclerView in project Carbon by ZieIony.

the class DrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawerMenu = (LinearLayout) findViewById(R.id.drawerMenu);
    RecyclerView drawerList = (RecyclerView) findViewById(R.id.drawerList);
    drawerList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    FruitAdapter adapter = new FruitAdapter(fruits, null);
    drawerList.setAdapter(adapter);
    adapter.setOnItemClickedListener(position -> {
        setTitle(fruits.get(position));
        drawerLayout.closeDrawer(drawerMenu);
    });
}
Also used : RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 75 with RecyclerView

use of android.support.v7.widget.RecyclerView in project Carbon by ZieIony.

the class AnimationsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.animationsActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(WidgetAnimationsActivity.class, getString(R.string.widgetAnimationsActivity_title)), new ViewModel(ImageFadeActivity.class, getString(R.string.imageFadeActivity_title)), new ViewModel(ListRippleActivity.class, getString(R.string.listRippleActivity_title)), new ViewModel(RippleComparisonActivity.class, getString(R.string.rippleComparisonActivity_title), false, true), new ViewModel(RippleActivity.class, getString(R.string.rippleActivity_title)) };
    recyclerView.setLayoutManager(getResources().getBoolean(R.bool.tablet) ? new GridLayoutManager(this, 2, LinearLayoutManager.VERTICAL, false) : new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new MainListAdapter(items));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1778 View (android.view.View)1237 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1106 TextView (android.widget.TextView)384 GridLayoutManager (android.support.v7.widget.GridLayoutManager)234 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)225 ImageView (android.widget.ImageView)210 ArrayList (java.util.ArrayList)190 Toolbar (android.support.v7.widget.Toolbar)137 Intent (android.content.Intent)117 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)102 ViewGroup (android.view.ViewGroup)101 Nullable (android.support.annotation.Nullable)99 Context (android.content.Context)96 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)96 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)93 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)93 Bundle (android.os.Bundle)92 Test (org.junit.Test)90 Paint (android.graphics.Paint)80