Ejemplo n.º 1
0
 @Override
 public boolean onDrag(View v, DragEvent event) {
   int action = event.getAction();
   switch (event.getAction()) {
     case DragEvent.ACTION_DRAG_STARTED:
       break;
     case DragEvent.ACTION_DRAG_ENTERED:
       break;
     case DragEvent.ACTION_DRAG_EXITED:
       break;
     case DragEvent.ACTION_DROP:
       statsSelected++;
       if (statsSelected == 6) {
         proceed.setEnabled(true);
       }
       View view = (View) event.getLocalState();
       view.setVisibility(View.INVISIBLE);
       wisdomVal.setText(selected + "");
     case DragEvent.ACTION_DRAG_ENDED:
       break;
     default:
       break;
   }
   return true;
 }
Ejemplo n.º 2
0
 @Override
 public boolean onDrag(View v, DragEvent event) {
   Cursor c = mDragAdapter.getItemForView(v);
   BookmarkDragState state = (BookmarkDragState) event.getLocalState();
   switch (event.getAction()) {
     case DragEvent.ACTION_DRAG_STARTED:
       return true;
     case DragEvent.ACTION_DROP:
       long id = c.getLong(BookmarksLoader.COLUMN_INDEX_ID);
       if (id == state.id) {
         // We dropped onto ourselves, show the context menu
         v.showContextMenu();
         return false;
       }
       long parent = c.getLong(BookmarksLoader.COLUMN_INDEX_PARENT);
       if (isFolder(c)) {
         parent = c.getLong(BookmarksLoader.COLUMN_INDEX_ID);
       }
       if (parent != state.parent) {
         ContentResolver cr = mActivity.getContentResolver();
         ContentValues values = new ContentValues();
         values.put(BrowserContract.Bookmarks.PARENT, parent);
         Uri uri = event.getClipData().getItemAt(0).getUri();
         cr.update(uri, values, null, null);
       }
       break;
   }
   return false;
 }
Ejemplo n.º 3
0
        public boolean onDrag(View v, DragEvent event) {
          int dragEvent = event.getAction();

          switch (dragEvent) {
            case DragEvent.ACTION_DRAG_STARTED:
              View draggedView = (View) event.getLocalState();
              draggedView.setVisibility(View.INVISIBLE);
              break;
            case DragEvent.ACTION_DRAG_ENTERED:
              Log.i("Drag Event", "Entered");
              break;
            case DragEvent.ACTION_DRAG_EXITED:
              Log.i("Drag Event", "Exited");
              break;
            case DragEvent.ACTION_DROP:
              Log.i("Drag Event", "Dropped");
              ImageView view = (ImageView) event.getLocalState();
              ViewGroup owner = (ViewGroup) view.getParent();
              FrameLayout container = (FrameLayout) v;
              if ((container.getChildCount() > 0)) {
                Log.d("V", "Already stone in spot");
                view.setVisibility(view.VISIBLE);
              } else {
                owner.removeView(view);
                Stone thisstone = (Stone) view.getTag();
                int id = thisstone.get_id();
                int spot = container.getId();
                dbHandler.update(id, spot);
                container.addView(view);
                view.setVisibility(View.VISIBLE);
                Log.d("V", "drop success");
              }
              break;
            case DragEvent.ACTION_DRAG_ENDED:
              ImageView oldview = (ImageView) event.getLocalState();
              oldview.setVisibility(oldview.VISIBLE);
              break;
            default:
              break;
          }
          return true;
        }
  @Override
  public boolean onDrag(View layoutview, DragEvent dragevent) {
    // TODO Auto-generated method stub
    int action = dragevent.getAction();
    switch (action) {
      case DragEvent.ACTION_DRAG_STARTED:
        Log.d(LOGCAT, "Drag event started");
        break;
      case DragEvent.ACTION_DRAG_ENTERED:
        Log.d(LOGCAT, "Drag event entered into " + layoutview.toString());
        break;
      case DragEvent.ACTION_DRAG_EXITED:
        Log.d(LOGCAT, "Drag event exited from " + layoutview.toString());
        break;
      case DragEvent.ACTION_DROP:
        int layId = layoutview.getId();
        if (flag == 1 && layId == R.id.layout_stackItem) {
          Toast.makeText(StackInteractive.this, "Stack Overflow...", Toast.LENGTH_SHORT).show();
        } else {
          Log.d(LOGCAT, "Dropped");
          View view = (View) dragevent.getLocalState();
          ViewGroup owner = (ViewGroup) view.getParent();
          owner.removeView(view);
          LinearLayout container = (LinearLayout) layoutview;
          container.addView(view);
          view.setVisibility(View.VISIBLE);
          // btnId[i] = view.getId();
          if (container == owner) {

          } else {
            view.setOnTouchListener(null);
            view.setOnClickListener(this);
            vId[i] = view;
            i--;
            if (i < 0) {
              btnPop.setEnabled(true);
              al = 0;
              i = 6;
              flag = 1;
            }
          }
        }
        break;
      case DragEvent.ACTION_DRAG_ENDED:
        Log.d(LOGCAT, "Drag ended");
        break;
      default:
        break;
    }
    return true;
  }
Ejemplo n.º 5
0
 // method for dragging object
 @Override
 public boolean onDrag(View v, DragEvent event) {
   int action = event.getAction();
   switch (action) {
     case DragEvent.ACTION_DROP:
       View view = (View) event.getLocalState();
       ViewGroup group = (ViewGroup) view.getParent();
       group.removeView(view);
       LinearLayout target = (LinearLayout) v;
       target.addView(view);
       view.setVisibility(View.VISIBLE);
       break;
   }
   return true;
 }
Ejemplo n.º 6
0
 @Override
 public boolean onDrag(View v, DragEvent event) {
   BookmarkDragState state = (BookmarkDragState) event.getLocalState();
   switch (event.getAction()) {
     case DragEvent.ACTION_DRAG_STARTED:
       return true;
     case DragEvent.ACTION_DROP:
       mDragController.actionItemClicked(v, state);
       // fall through
     case DragEvent.ACTION_DRAG_ENDED:
       if (mActionMode != null) {
         mActionMode.finish();
         mActionMode = null;
       }
       return true;
   }
   return false;
 }
Ejemplo n.º 7
0
    @Override
    public boolean onDrag(View v, DragEvent event) {
      switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
          // no action necessary
          break;
        case DragEvent.ACTION_DRAG_ENTERED:
          // no action necessary
          break;
        case DragEvent.ACTION_DRAG_EXITED:
          // no action necessary
          break;
        case DragEvent.ACTION_DROP:
          // handle the dragged view being dropped over a drop view
          View view = (View) event.getLocalState();
          // stop displaying the view where it was before it was dragged
          // view.setVisibility(View.INVISIBLE);
          // view dragged item is being dropped on
          ImageView dropTarget = (ImageView) v;
          // view being dragged and dropped
          ImageView dropped = (ImageView) view;
          // update the text in the target view to reflect the data being dropped

          switch (dropTarget.getId()) {
            case R.id.myanswer5:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  s = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  s = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  s = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  s = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  s = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  s = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  s = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  s = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  s = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  s = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  s = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  s = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  s = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  s = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  s = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  s = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  s = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  s = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  s = true;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  s = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  s = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  s = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  s = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  s = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  s = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  s = false;
                  break;
              }
              break;
            case R.id.myanswer6:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  i = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  i = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  i = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  i = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  i = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  i = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  i = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  i = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  i = true;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  i = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  i = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  i = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  i = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  i = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  i = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  i = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  i = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  i = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  i = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  i = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  i = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  i = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  i = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  i = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  i = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  i = false;
                  break;
              }
              break;
            case R.id.myanswer7:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  n = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  n = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  n = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  n = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  n = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  n = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  n = false;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  n = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  n = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  n = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  n = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  n = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  n = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  n = true;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  n = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  n = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  n = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  n = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  n = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  n = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  n = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  n = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  n = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  n = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  n = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  n = false;
                  break;
              }
              break;
            case R.id.myanswer8:
              switch (dropped.getId()) {
                case R.id.myimage1:
                  dropTarget.setImageResource(R.drawable.a);
                  g = false;
                  break;
                case R.id.myimage2:
                  dropTarget.setImageResource(R.drawable.b);
                  g = false;
                  break;
                case R.id.myimage3:
                  dropTarget.setImageResource(R.drawable.c);
                  g = false;
                  break;
                case R.id.myimage4:
                  dropTarget.setImageResource(R.drawable.d);
                  g = false;
                  break;
                case R.id.myimage5:
                  dropTarget.setImageResource(R.drawable.e);
                  g = false;
                  break;
                case R.id.myimage6:
                  dropTarget.setImageResource(R.drawable.f);
                  g = false;
                  break;
                case R.id.myimage7:
                  dropTarget.setImageResource(R.drawable.g);
                  g = true;
                  break;
                case R.id.myimage8:
                  dropTarget.setImageResource(R.drawable.h);
                  g = false;
                  break;
                case R.id.myimage9:
                  dropTarget.setImageResource(R.drawable.i);
                  g = false;
                  break;
                case R.id.myimage10:
                  dropTarget.setImageResource(R.drawable.j);
                  g = false;
                  break;
                case R.id.myimage11:
                  dropTarget.setImageResource(R.drawable.k);
                  g = false;
                  break;
                case R.id.myimage12:
                  dropTarget.setImageResource(R.drawable.l);
                  g = false;
                  break;
                case R.id.myimage13:
                  dropTarget.setImageResource(R.drawable.m);
                  g = false;
                  break;
                case R.id.myimage14:
                  dropTarget.setImageResource(R.drawable.n);
                  g = false;
                  break;
                case R.id.myimage15:
                  dropTarget.setImageResource(R.drawable.o);
                  g = false;
                  break;
                case R.id.myimage16:
                  dropTarget.setImageResource(R.drawable.p);
                  g = false;
                  break;
                case R.id.myimage17:
                  dropTarget.setImageResource(R.drawable.q);
                  g = false;
                  break;
                case R.id.myimage18:
                  dropTarget.setImageResource(R.drawable.r);
                  g = false;
                  break;
                case R.id.myimage19:
                  dropTarget.setImageResource(R.drawable.s);
                  g = false;
                  break;
                case R.id.myimage20:
                  dropTarget.setImageResource(R.drawable.t);
                  g = false;
                  break;
                case R.id.myimage21:
                  dropTarget.setImageResource(R.drawable.u);
                  g = false;
                  break;
                case R.id.myimage22:
                  dropTarget.setImageResource(R.drawable.v);
                  g = false;
                  break;
                case R.id.myimage23:
                  dropTarget.setImageResource(R.drawable.w);
                  g = false;
                  break;
                case R.id.myimage24:
                  dropTarget.setImageResource(R.drawable.x);
                  g = false;
                  break;
                case R.id.myimage25:
                  dropTarget.setImageResource(R.drawable.y);
                  g = false;
                  break;
                case R.id.myimage26:
                  dropTarget.setImageResource(R.drawable.z);
                  g = false;
                  break;
              }
              break;
          }

          // dropTarget.setImageResource(dropped.getId());
          // make it bold to highlight the fact that an item has been dropped
          // dropTarget.setTypeface(Typeface.DEFAULT_BOLD);
          // if an item has already been dropped here, there will be a tag
          Object tag = dropTarget.getTag();
          // if there is already an item here, set it back visible in its original place
          if (tag != null) { //
            // the tag is the view id already dropped here
            int existingID = (Integer) tag;
            // set the original view visible again
            findViewById(existingID).setVisibility(View.VISIBLE);
          }
          // set the tag in the target view being dropped on - to the ID of the view being dropped
          dropTarget.setTag(dropped.getId());

          if (s && i && n && g) {
            nextGame();
          }

          break;
        case DragEvent.ACTION_DRAG_ENDED:
          // no action necessary
          break;
        default:
          break;
      }
      return true;
    }
Ejemplo n.º 8
0
    @Override
    public boolean onDrag(View viewTarget, DragEvent event) {
      switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
          break;

        case DragEvent.ACTION_DRAG_ENTERED:
          viewTarget.setBackgroundResource(R.drawable.shape_droptarget);
          break;

        case DragEvent.ACTION_DRAG_EXITED:
          viewTarget.setBackgroundResource(R.drawable.shape);
          break;

        case DragEvent.ACTION_DRAG_LOCATION:
          Display display = getWindowManager().getDefaultDisplay();
          Point displaySize = new Point();
          display.getSize(displaySize);
          int displayMaxY = displaySize.y;

          Rect rect = new Rect();
          viewTarget.getGlobalVisibleRect(rect);
          Point touchPosition =
              new Point(rect.left + Math.round(event.getX()), rect.top + Math.round(event.getY()));

          int scrollTopThreshold =
              displayMaxY / 5 + mActionBar.getHeight() + statusBarBackground.getHeight();
          int scrollBottomThreshold = displayMaxY - (displayMaxY / 5);

          if (touchPosition.y < scrollTopThreshold) scrollView.smoothScrollBy(0, -15);
          if (touchPosition.y > scrollBottomThreshold) scrollView.smoothScrollBy(0, 15);
          break;

        case DragEvent.ACTION_DROP:
          View draggedView = (View) event.getLocalState();
          View currentView = ((LinearLayout) viewTarget).getChildAt(0);

          if (draggedView != null) {
            ViewGroup owner = (ViewGroup) draggedView.getParent();
            LinearLayout container = (LinearLayout) viewTarget;

            owner.removeView(draggedView);
            container.addView(draggedView);

            container.removeView(currentView);
            owner.addView(currentView);

            draggedView.setVisibility(View.VISIBLE);
          }
          break;

        case DragEvent.ACTION_DRAG_ENDED:
          isDragging = false;
          viewTarget.setBackgroundResource(R.drawable.shape);
          View draggedView2 = (View) event.getLocalState();
          if (draggedView2 != null) draggedView2.setVisibility(View.VISIBLE);
          break;

        default:
          break;
      }
      return true;
    }
    @Override
    public boolean onDrag(View v, DragEvent event) {
      int action = event.getAction();
      String tipo = params.getString("Tipo");

      switch (action) {
        case DragEvent.ACTION_DRAG_STARTED:
          Log.i("Script", num + " - ACTION_DRAG_STARTED");
          if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
            return (true);
          }
          return (false);

        case DragEvent.ACTION_DRAG_ENTERED:
          Log.i("Script", num + " - ACTION_DRAG_ENTERED");
          v.setBackgroundColor(getResources().getColor(R.color.amarelo_claro));
          break;

        case DragEvent.ACTION_DRAG_LOCATION:
          Log.i("Script", num + " - ACTION_DRAG_LOCATION");
          break;

        case DragEvent.ACTION_DRAG_EXITED:
          Log.i("Script", num + " - ACTION_DRAG_EXITED");
          if (tipo.equals("A")) {
            v.setBackgroundColor(getResources().getColor(R.color.iniciacao));
          } else if (tipo.equals("B")) {
            v.setBackgroundColor(getResources().getColor(R.color.planejamento));
          } else if (tipo.equals("C")) {
            v.setBackgroundColor(getResources().getColor(R.color.execucao));
          } else if (tipo.equals("D")) {
            v.setBackgroundColor(getResources().getColor(R.color.monitoramento_controle));
          } else {
            v.setBackgroundColor(getResources().getColor(R.color.encerramento));
          }

          break;

        case DragEvent.ACTION_DROP:
          Log.i("Script", num + " - ACTION_DROP");
          View view = (View) event.getLocalState();
          ViewGroup owner = (ViewGroup) view.getParent();
          owner.removeView(view);
          LinearLayout container = (LinearLayout) v;
          container.addView(view);
          view.setVisibility(View.VISIBLE);

          if (v.getId() == R.id.esquerda) {
            Button b = (Button) view;
            b.setTextColor(Color.BLACK);
          }

          break;

        case DragEvent.ACTION_DRAG_ENDED:
          Log.i("Script", num + " - ACTION_DRAG_ENDED");
          if (tipo.equals("A")) {
            v.setBackgroundColor(getResources().getColor(R.color.iniciacao));
          } else if (tipo.equals("B")) {
            v.setBackgroundColor(getResources().getColor(R.color.planejamento));
          } else if (tipo.equals("C")) {
            v.setBackgroundColor(getResources().getColor(R.color.execucao));
          } else if (tipo.equals("D")) {
            v.setBackgroundColor(getResources().getColor(R.color.monitoramento_controle));
          } else {
            v.setBackgroundColor(getResources().getColor(R.color.encerramento));
          }
          break;
      }
      return true;
    }
Ejemplo n.º 10
0
    /** OnDrag event actions */
    @Override
    public boolean onDrag(View v, DragEvent event) {
      switch (event.getAction()) {
        case DragEvent.ACTION_DRAG_STARTED:
          break;
        case DragEvent.ACTION_DRAG_ENTERED:
          break;
        case DragEvent.ACTION_DRAG_EXITED:
          break;
        case DragEvent.ACTION_DROP:
          View vTmp = (View) event.getLocalState();
          if (vTmp instanceof CardView) {
            CardView view = (CardView) vTmp;
            ViewGroup parent = (ViewGroup) (view.getParent());
            parent.removeViewInLayout(view);
            addView(view);
            if (parent instanceof HandView) {
              CardView card = (CardView) view;
              card.setOnDragListener(null);
              Gallery g2 =
                  (Gallery)
                      GameActivity.getActivity()
                          .findViewById(R.id.playerview_slider_board_cardgallery);
              if (g2 != null) {
                SliderbarCardGallery a2 = (SliderbarCardGallery) g2.getAdapter();
                a2.notifyDataSetChanged();
              }
            } else if (parent instanceof BoardView) {
              // Cards grouped moving
              if (cardsGroup.getTouching().size() > 1)
                cardsGroup.move(event.getX(), event.getY(), getWidth(), getHeight());
            }
            MarginLayoutParams marginParams = new MarginLayoutParams(view.getLayoutParams());
            int left = (int) (event.getX() - (view.getWidth() / 2));
            int top = (int) (event.getY() - (view.getHeight() / 2));
            int right = (int) (((View) view.getParent()).getWidth() - left + view.getWidth());
            int bottom = (int) (((View) view.getParent()).getHeight() - top + view.getHeight());
            marginParams.setMargins(left, top, right, bottom);
            view.setLayoutParams(new RelativeLayout.LayoutParams(marginParams));

            if (parent instanceof HandView) {
              Log.i(WifiDirectProperty.TAG, "1");
              MoveCardAction movecard =
                  new MoveCardAction("Player", GA.user.getId(), view.getCard(), "BoardView");
              movecard.setPourcentageX(left * 100 / ((View) view.getParent()).getWidth());
              movecard.setPourcentageY(top * 100 / ((View) view.getParent()).getHeight());
              Log.i(
                  WifiDirectProperty.TAG,
                  movecard.getPourcentageX() + " " + movecard.getPourcentageY());
              GameActivity.getActivity()
                  .getWifiDirectManager()
                  .sendEvent(new WifiDirectEventImpl(WifiDirectEvent.EVENT, movecard));

            } else if (parent instanceof DrawPileView) {
              MoveCardAction movecard =
                  new MoveCardAction("DrawPileView", "BoardView", view.getCard());
              movecard.setPourcentageX(left * 100 / ((View) view.getParent()).getWidth());
              movecard.setPourcentageY(top * 100 / ((View) view.getParent()).getHeight());
              Log.i(
                  WifiDirectProperty.TAG,
                  movecard.getPourcentageX() + " " + movecard.getPourcentageY());
              GameActivity.getActivity()
                  .getWifiDirectManager()
                  .sendEvent(new WifiDirectEventImpl(WifiDirectEvent.EVENT, movecard));
            } else if (parent instanceof DiscardPileView) {
              MoveCardAction movecard =
                  new MoveCardAction("DiscardPileView", "BoardView", view.getCard());
              movecard.setPourcentageX(left * 100 / ((View) view.getParent()).getWidth());
              movecard.setPourcentageY(top * 100 / ((View) view.getParent()).getHeight());
              Log.i(
                  WifiDirectProperty.TAG,
                  movecard.getPourcentageX() + " " + movecard.getPourcentageY());
              GameActivity.getActivity()
                  .getWifiDirectManager()
                  .sendEvent(new WifiDirectEventImpl(WifiDirectEvent.EVENT, movecard));
            }
            View tmp;
            for (int i = 0; i < getChildCount(); i++) {
              tmp = getChildAt(i);
              if (tmp instanceof CardView) tmp.setVisibility(View.VISIBLE);
            }
            vTmp.setVisibility(View.VISIBLE);
          } else {
            vTmp.setVisibility(View.VISIBLE);
          }
          cardsGroup.getTouching().clear();
          break;
        case DragEvent.ACTION_DRAG_ENDED:
          break;
        default:
          break;
      }
      return true;
    }