use of android.support.v7.widget.DefaultItemAnimator in project FastAdapter by mikepenz.
the class SortActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sort);
ButterKnife.bind(this);
// Handle Toolbar
setSupportActionBar(toolbar);
//style our ui
new MaterializeBuilder().withActivity(this).build();
//create our FastAdapter which will manage everything
fastItemAdapter = new FastItemAdapter<>();
fastItemAdapter.withSelectable(true);
//configure our fastAdapter
fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<SimpleItem>() {
@Override
public boolean onClick(View v, IAdapter<SimpleItem> adapter, SimpleItem item, int position) {
Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
return false;
}
});
//get our recyclerView and do basic setup
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(fastItemAdapter);
if (savedInstanceState != null) {
//Retrieve the previous sorting strategy from the instance state
sortingStrategy = toSortingStrategy(savedInstanceState.getInt("sorting_strategy"));
} else {
//Set the default so
sortingStrategy = SORT_NONE;
}
//we sort the list
fastItemAdapter.getItemAdapter().withComparator(getComparator());
//initial filling of the list
fastItemAdapter.setNewList(generateUnsortedList());
//restore selections (this has to be done after the items were added
fastItemAdapter.withSavedInstanceState(savedInstanceState);
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
use of android.support.v7.widget.DefaultItemAnimator in project FastAdapter by mikepenz.
the class ImageListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(R.string.sample_image_list);
//style our ui
new MaterializeBuilder().withActivity(this).build();
//create our FastAdapter which will manage everything
mFastItemAdapter = new FastItemAdapter<>();
//init the ClickListenerHelper which simplifies custom click listeners on views of the Adapter
mClickListenerHelper = new ClickListenerHelper<>(mFastItemAdapter);
//configure our fastAdapter
mFastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<ImageItem>() {
@Override
public boolean onClick(View v, IAdapter<ImageItem> adapter, ImageItem item, int position) {
Toast.makeText(v.getContext(), item.mName, Toast.LENGTH_SHORT).show();
return false;
}
});
//get our recyclerView and do basic setup
RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
//find out how many columns we display
int columns = getResources().getInteger(R.integer.wall_splash_columns);
if (columns == 1) {
//linearLayoutManager for one column
rv.setLayoutManager(new LinearLayoutManager(this));
} else {
//gridLayoutManager for more than one column ;)
rv.setLayoutManager(new GridLayoutManager(this, columns));
}
rv.setItemAnimator(new DefaultItemAnimator());
rv.setAdapter(mFastItemAdapter);
//fill with some sample data
mFastItemAdapter.add(ImageDummyData.getImageItems());
//restore selections (this has to be done after the items were added
mFastItemAdapter.withSavedInstanceState(savedInstanceState);
//a custom OnCreateViewHolder listener class which is used to create the viewHolders
//we define the listener for the imageLovedContainer here for better performance
//you can also define the listener within the items bindView method but performance is better if you do it like this
mFastItemAdapter.withItemEvent(new ImageItem.ImageItemHeartClickEvent());
//set the back arrow in the toolbar
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(false);
}
use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.
the class HeaderTypesFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.recycleview_layout, container, false);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
createAdapter(mRecyclerView);
return v;
}
use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.
the class ListenerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.recycleview_layout, container, false);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
createAdapter(mRecyclerView);
return v;
}
use of android.support.v7.widget.DefaultItemAnimator in project AdvancedMaterialDrawer by madcyph3r.
the class MenuFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.recycleview_layout, container, false);
mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
createAdapter(mRecyclerView);
return v;
}
Aggregations