Search in sources :

Example 6 with RecyclerView

use of carbon.widget.RecyclerView in project Carbon by ZieIony.

the class GuidelinesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.guidelinesActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(ButtonsUsageActivity.class, getString(R.string.buttonsUsageActivity_title)), new ViewModel(ToolbarsUsageActivity.class, getString(R.string.toolbarsUsageActivity_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(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 7 with RecyclerView

use of carbon.widget.RecyclerView in project Carbon by ZieIony.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Samples.initToolbar(this, getString(R.string.app_name));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(AnimationsActivity.class, getString(R.string.animationsActivity_title)), new ViewModel(AppsLibrariesActivity.class, getString(R.string.appsLibrariesActivity_title)), new ViewModel(ColorsActivity.class, getString(R.string.colorsActivity_title)), new ViewModel(ComponentsActivity.class, getString(R.string.componentsActivity_title)), new ViewModel(DemosActivity.class, getString(R.string.demosActivity_title)), new ViewModel(FeaturesActivity.class, getString(R.string.featuresActivity_title)), new ViewModel(GuidelinesActivity.class, getString(R.string.guidelinesActivity_title)), new ViewModel(WidgetsActivity.class, getString(R.string.widgetsActivity_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(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 8 with RecyclerView

use of carbon.widget.RecyclerView in project Carbon by ZieIony.

the class ScrollFlagsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrollflags);
    RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
    recycler.setLayoutManager(new LinearLayoutManager(this));
/*RowListAdapter<AvatarTextListItemActivity.SampleItem> adapter = new RowListAdapter<>(AvatarTextListItemActivity.SampleItem.class, AvatarTextRow::new);
        recycler.setAdapter(adapter);
        adapter.setItems(Stream.generate(AvatarTextListItemActivity.SampleItem::new).limit(10).collect(Collectors.toList()));
*/
}
Also used : RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 9 with RecyclerView

use of carbon.widget.RecyclerView in project Carbon by ZieIony.

the class QuickReturnActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quickreturn);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new FruitAdapter(fruits, null));
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    recyclerView.addOnScrollListener(new android.support.v7.widget.RecyclerView.OnScrollListener() {

        int yscroll = 0;

        @Override
        public void onScrolled(android.support.v7.widget.RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            if (fab.getVisibility() == View.VISIBLE && fab.getAnimator() == null && yscroll > 50 * Carbon.getDip(getApplicationContext())) {
                yscroll = 0;
                fab.setVisibility(View.GONE);
                toolbar.setVisibility(View.GONE);
            }
            if (fab.getVisibility() != View.VISIBLE && fab.getAnimator() == null && yscroll < -50 * Carbon.getDip(getApplicationContext())) {
                yscroll = 0;
                fab.setVisibility(View.VISIBLE);
                toolbar.setVisibility(View.VISIBLE);
            }
            if (Math.signum(dy) != Math.signum(yscroll))
                yscroll = 0;
            yscroll += dy;
        }
    });
}
Also used : FruitAdapter(tk.zielony.carbonsamples.applibrary.FruitAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) FloatingActionButton(carbon.widget.FloatingActionButton) RecyclerView(carbon.widget.RecyclerView) Toolbar(carbon.widget.Toolbar)

Example 10 with RecyclerView

use of carbon.widget.RecyclerView in project Carbon by ZieIony.

the class DemosActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.demosActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(PowerMenuActivity.class, getString(R.string.powerMenuActivity_title)), new ViewModel(ShareToolbarActivity.class, getString(R.string.shareToolbarActivity_title), true), new ViewModel(AutoCompleteDemo.class, getString(R.string.autoCompleteActivity_title), false), new ViewModel(QuickReturnActivity.class, getString(R.string.quickReturenActivity_title), false) };
    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(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

RecyclerView (carbon.widget.RecyclerView)14 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)4 RowListAdapter (carbon.recycler.RowListAdapter)4 Drawable (android.graphics.drawable.Drawable)2 VectorDrawable (carbon.drawable.VectorDrawable)2 FruitAdapter (tk.zielony.carbonsamples.applibrary.FruitAdapter)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Bundle (android.os.Bundle)1 Nullable (android.support.annotation.Nullable)1 Carbon (carbon.Carbon)1 DefaultAvatarTextItem (carbon.component.DefaultAvatarTextItem)1 DefaultHeaderItem (carbon.component.DefaultHeaderItem)1 DefaultIconDropDownItem (carbon.component.DefaultIconDropDownItem)1 DefaultIconEditTextItem (carbon.component.DefaultIconEditTextItem)1 DefaultIconPasswordItem (carbon.component.DefaultIconPasswordItem)1 DefaultIconSearchItem (carbon.component.DefaultIconSearchItem)1 DefaultIconTextItem (carbon.component.DefaultIconTextItem)1 DefaultImageTextSubtextDateItem (carbon.component.DefaultImageTextSubtextDateItem)1 DividerItem (carbon.component.DividerItem)1