Search in sources :

Example 1 with SpacingItemDecoration

use of com.beloo.widget.chipslayoutmanager.SpacingItemDecoration in project ChipsLayoutManager by BelooS.

the class ItemsFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    adapter = createAdapter(savedInstanceState);
    ChipsLayoutManager spanLayoutManager = ChipsLayoutManager.newBuilder(getContext()).setOrientation(ChipsLayoutManager.HORIZONTAL).build();
    rvTest.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space), getResources().getDimensionPixelOffset(R.dimen.item_space)));
    positions = new LinkedList<>();
    for (int i = 0; i < items.size(); i++) {
        positions.add(String.valueOf(i));
    }
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    ArrayAdapter<String> spinnerAdapterMoveTo = new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    spinnerPosition.setAdapter(spinnerAdapter);
    spinnerMoveTo.setAdapter(spinnerAdapterMoveTo);
    rvTest.setLayoutManager(spanLayoutManager);
    rvTest.getRecycledViewPool().setMaxRecycledViews(0, 10);
    rvTest.getRecycledViewPool().setMaxRecycledViews(1, 10);
    rvTest.setAdapter(adapter);
}
Also used : SpacingItemDecoration(com.beloo.widget.chipslayoutmanager.SpacingItemDecoration) ChipsLayoutManager(com.beloo.widget.chipslayoutmanager.ChipsLayoutManager) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with SpacingItemDecoration

use of com.beloo.widget.chipslayoutmanager.SpacingItemDecoration in project ChipsLayoutManager by BelooS.

the class TestActivity method initRv.

@UiThread
private void initRv() {
    adapter = createAdapter();
    RecyclerView.LayoutManager layoutManager = lmFactory.layoutManager(this);
    if (layoutManager == null)
        Log.e("initRv", "lm manager is null");
    rvTest.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space), getResources().getDimensionPixelOffset(R.dimen.item_space)));
    positions = new LinkedList<>();
    for (int i = 0; i < items.size(); i++) {
        positions.add(String.valueOf(i));
    }
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    ArrayAdapter<String> spinnerAdapterMoveTo = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, positions);
    spinnerPosition.setAdapter(spinnerAdapter);
    spinnerMoveTo.setAdapter(spinnerAdapterMoveTo);
    rvTest.setLayoutManager(layoutManager);
    // rvTest.setLayoutManager(new LinearLayoutManager(this));
    rvTest.getRecycledViewPool().setMaxRecycledViews(0, 10);
    rvTest.getRecycledViewPool().setMaxRecycledViews(1, 10);
    rvTest.setAdapter(adapter);
}
Also used : SpacingItemDecoration(com.beloo.widget.chipslayoutmanager.SpacingItemDecoration) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter) UiThread(android.support.annotation.UiThread)

Example 3 with SpacingItemDecoration

use of com.beloo.widget.chipslayoutmanager.SpacingItemDecoration in project ChipsLayoutManager by BelooS.

the class BottomSheetDialogFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    // LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
    ChipsLayoutManager layoutManager = ChipsLayoutManager.newBuilder(getContext()).build();
    rvBottomSheet.setLayoutManager(layoutManager);
    rvBottomSheet.setAdapter(createAdapter());
    rvBottomSheet.addItemDecoration(new SpacingItemDecoration(getResources().getDimensionPixelOffset(R.dimen.item_space), getResources().getDimensionPixelOffset(R.dimen.item_space)));
}
Also used : SpacingItemDecoration(com.beloo.widget.chipslayoutmanager.SpacingItemDecoration) ChipsLayoutManager(com.beloo.widget.chipslayoutmanager.ChipsLayoutManager)

Aggregations

SpacingItemDecoration (com.beloo.widget.chipslayoutmanager.SpacingItemDecoration)3 ArrayAdapter (android.widget.ArrayAdapter)2 ChipsLayoutManager (com.beloo.widget.chipslayoutmanager.ChipsLayoutManager)2 UiThread (android.support.annotation.UiThread)1 RecyclerView (android.support.v7.widget.RecyclerView)1