Search in sources :

Example 1 with SimpleSwipeListener

use of com.daimajia.swipe.SimpleSwipeListener in project AndroidSwipeLayout by daimajia.

the class RecyclerViewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final SimpleViewHolder viewHolder, final int position) {
    String item = mDataset.get(position);
    viewHolder.swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
    viewHolder.swipeLayout.addSwipeListener(new SimpleSwipeListener() {

        @Override
        public void onOpen(SwipeLayout layout) {
            YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
        }
    });
    viewHolder.swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {

        @Override
        public void onDoubleClick(SwipeLayout layout, boolean surface) {
            Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
        }
    });
    viewHolder.buttonDelete.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mItemManger.removeShownLayouts(viewHolder.swipeLayout);
            mDataset.remove(position);
            notifyItemRemoved(position);
            notifyItemRangeChanged(position, mDataset.size());
            mItemManger.closeAllItems();
            Toast.makeText(view.getContext(), "Deleted " + viewHolder.textViewData.getText().toString() + "!", Toast.LENGTH_SHORT).show();
        }
    });
    viewHolder.textViewPos.setText((position + 1) + ".");
    viewHolder.textViewData.setText(item);
    mItemManger.bind(viewHolder.itemView, position);
}
Also used : SimpleSwipeListener(com.daimajia.swipe.SimpleSwipeListener) SwipeLayout(com.daimajia.swipe.SwipeLayout) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with SimpleSwipeListener

use of com.daimajia.swipe.SimpleSwipeListener in project AndroidSwipeLayout by daimajia.

the class ListViewAdapter method generateView.

@Override
public View generateView(int position, ViewGroup parent) {
    View v = LayoutInflater.from(mContext).inflate(R.layout.listview_item, null);
    SwipeLayout swipeLayout = (SwipeLayout) v.findViewById(getSwipeLayoutResourceId(position));
    swipeLayout.addSwipeListener(new SimpleSwipeListener() {

        @Override
        public void onOpen(SwipeLayout layout) {
            YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
        }
    });
    swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {

        @Override
        public void onDoubleClick(SwipeLayout layout, boolean surface) {
            Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
        }
    });
    v.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Toast.makeText(mContext, "click delete", Toast.LENGTH_SHORT).show();
        }
    });
    return v;
}
Also used : SimpleSwipeListener(com.daimajia.swipe.SimpleSwipeListener) SwipeLayout(com.daimajia.swipe.SwipeLayout) TextView(android.widget.TextView) View(android.view.View)

Aggregations

View (android.view.View)2 TextView (android.widget.TextView)2 SimpleSwipeListener (com.daimajia.swipe.SimpleSwipeListener)2 SwipeLayout (com.daimajia.swipe.SwipeLayout)2 RecyclerView (android.support.v7.widget.RecyclerView)1