Search in sources :

Example 11 with RecyclerView

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

the class FeaturesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    Samples.initToolbar(this, getString(R.string.featuresActivity_title));
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    ViewModel[] items = new ViewModel[] { new ViewModel(ScrollFlagsActivity.class, getString(R.string.dependencyLayoutActivity_title)), new ViewModel(HtmlActivity.class, getString(R.string.htmlActivity_title)), new ViewModel(RobotoActivity.class, getString(R.string.robotoActivity_title)), new ViewModel(ShadowActivity.class, getString(R.string.shadowActivity_title)), new ViewModel(LargeShadowActivity.class, getString(R.string.largeShadowActivity_title)), new ViewModel(TextAppearanceActivity.class, getString(R.string.textappearanceActivity_title)), new ViewModel(ZOrderActivity.class, getString(R.string.zOrderActivity_title)), new ViewModel(RoundedCornersActivity.class, getString(R.string.roundedCornersActivity_title)), new ViewModel(AnchorActivity.class, getString(R.string.anchorsActivity_title)), new ViewModel(ContextWrapperActivity.class, getString(R.string.contextWrapperActivity_title)), new ViewModel(PercentLayoutActivity.class, getString(R.string.percentLayoutActivity_title)), new ViewModel(TextMarkerActivity.class, getString(R.string.textMarkerActivity_title)), new ViewModel(ThemeActivity.class, getString(R.string.themeActivity_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 12 with RecyclerView

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

the class ListRippleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_ripple);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    String[] items = new String[] { "Blueberry", "Lime", "Lemon", "Orange", "Strawberry" };
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new ListRippleAdapter(items));
}
Also used : RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 13 with RecyclerView

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

the class RecyclerCardsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler_cards);
    List<ViewModel> items = Arrays.asList(new ViewModel(), new ViewModel(), new ViewModel(), new ViewModel(), new ViewModel(), new ViewModel(), new ViewModel());
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(new RecyclerAdapter(items, R.layout.card));
    recyclerView.setHeader(R.layout.header_scrollview);
}
Also used : RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 14 with RecyclerView

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

the class RecyclerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler);
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {

        @Override
        public int getMovementFlags(android.support.v7.widget.RecyclerView recyclerView, android.support.v7.widget.RecyclerView.ViewHolder viewHolder) {
            int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
            int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
            return makeMovementFlags(dragFlags, swipeFlags);
        }

        @Override
        public boolean onMove(android.support.v7.widget.RecyclerView recyclerView, android.support.v7.widget.RecyclerView.ViewHolder viewHolder, android.support.v7.widget.RecyclerView.ViewHolder target) {
            Collections.swap(fruits, viewHolder.getAdapterPosition(), target.getAdapterPosition());
            fruitAdapter.notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
            return true;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            fruits.remove(viewHolder.getAdapterPosition());
            fruitAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());
        }

        @Override
        public void onSelectedChanged(android.support.v7.widget.RecyclerView.ViewHolder viewHolder, int actionState) {
            super.onSelectedChanged(viewHolder, actionState);
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    fruitAdapter = new FruitAdapter(fruits, itemTouchHelper);
    recyclerView.setAdapter(fruitAdapter);
    recyclerView.setHeader(R.layout.header_scrollview);
}
Also used : ItemTouchHelper(carbon.recycler.ItemTouchHelper) FruitAdapter(tk.zielony.carbonsamples.applibrary.FruitAdapter) 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