Ejemplo n.º 1
0
 @Override
 public void onBindViewHolder(final ItemViewHolder holder, final int position) {
   Log.d(TAG, "onBindViewHolder ");
   Item item = mItems.get(position);
   String message;
   switch (item.getState()) {
     case Item.STATE.LEFT:
       {
         message = "swiped left";
         break;
       }
     case Item.STATE.RIGHT:
       {
         message = "swiped right";
         break;
       }
     default:
       {
         message = "not swiped";
         break;
       }
   }
   String text = item.getText() + " " + message;
   holder.offerTitle.setText(text);
   if (views[position] == null) views[position] = holder.itemView;
   //        holder.itemView.setOnTouchListener(new View.OnTouchListener() {
   //            @Override
   //            public boolean onTouch(View v, MotionEvent event) {
   //                views[position] = holder.itemView;
   //                return false;
   //            }
   //        });
 }
Ejemplo n.º 2
0
 @Override
 public void onItemMove(int fromPosition, int toPosition) {
   Log.d(TAG, "onItemMove ");
   int state = mItems.get(fromPosition).getState();
   String prev = mItems.remove(fromPosition).getText();
   Item item = new Item(prev);
   item.setState(state);
   mItems.add(toPosition > fromPosition ? toPosition - 1 : toPosition, item);
   notifyItemMoved(fromPosition, toPosition);
 }
Ejemplo n.º 3
0
  @Override
  public void onItemSwiped(int position, boolean isSwipedLeft) {
    Log.d(TAG, "onItemSwiped ");
    Item item = mItems.get(position);
    if (isSwipedLeft) {
      item.onSwipeLeft();
    } else {
      item.onSwipeRight();
    }
    //        if (views[position] != null) {
    //            setAnimation(views[position], position);
    //            views[position] = null;
    //        }

    notifyDataSetChanged();
  }