use of com.dexafree.materialList.listeners.OnDismissCallback in project MaterialList by dexafree.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Save a reference to the context
mContext = this;
// Bind the MaterialListView to a variable
mListView = (MaterialListView) findViewById(R.id.material_listview);
mListView.setItemAnimator(new SlideInLeftAnimator());
mListView.getItemAnimator().setAddDuration(300);
mListView.getItemAnimator().setRemoveDuration(300);
final ImageView emptyView = (ImageView) findViewById(R.id.imageView);
emptyView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mListView.setEmptyView(emptyView);
Picasso.with(this).load("https://www.skyverge.com/wp-content/uploads/2012/05/github-logo.png").resize(100, 100).centerInside().into(emptyView);
// Fill the array withProvider mock content
fillArray();
// Set the dismiss listener
mListView.setOnDismissCallback(new OnDismissCallback() {
@Override
public void onDismiss(@NonNull Card card, int position) {
// Show a toast
Toast.makeText(mContext, "You have dismissed a " + card.getTag(), Toast.LENGTH_SHORT).show();
}
});
// Add the ItemTouchListener
mListView.addOnItemTouchListener(new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(@NonNull Card card, int position) {
Log.d("CARD_TYPE", "" + card.getTag());
}
@Override
public void onItemLongClick(@NonNull Card card, int position) {
Log.d("LONG_CLICK", "" + card.getTag());
}
});
}
Aggregations