Exemplo n.º 1
0
 /**
  * 根据当前ListView的滚动状态来设定 {@link #ableToPull}
  * 的值,每次都需要在onTouch中第一个执行,这样可以判断出当前应该是滚动ListView,还是应该进行下拉。
  *
  * @param event
  */
 private void setIsAbleToPull(View view, MotionEvent event) {
   boolean oldVal = this.ableToPull;
   this.ableToPull = this.pullableView.isPullable(view, event);
   if (this.ableToPull) {
     if (oldVal == false) {
       yDown = event.getRawY();
     }
   } else if (headerLayoutParams.topMargin != hideHeaderHeight) {
     headerLayoutParams.topMargin = hideHeaderHeight;
     header.setLayoutParams(headerLayoutParams);
   }
   if (pullableView.getView() instanceof ListView) {
     View firstChild = ((ListView) pullableView.getView()).getChildAt(0);
     if (firstChild != null) {
       int firstVisiblePos = ((ListView) pullableView.getView()).getFirstVisiblePosition();
       if (firstVisiblePos == 0 && firstChild.getTop() == 0) {
         if (!ableToPull) {
           yDown = event.getRawY();
         }
         // 如果首个元素的上边缘,距离父布局值为0,就说明ListView滚动到了最顶部,此时应该允许下拉刷新
         ableToPull = true;
       } else {
         if (headerLayoutParams.topMargin != hideHeaderHeight) {
           headerLayoutParams.topMargin = hideHeaderHeight;
           header.setLayoutParams(headerLayoutParams);
         }
         ableToPull = false;
       }
     } else {
       // 如果ListView中没有元素,也应该允许下拉刷新
       ableToPull = true;
     }
   }
 }
Exemplo n.º 2
0
  protected void updateMargins() {
    //noinspection ConstantConditions
    final int margin = getResources().getDimensionPixelSize(R.dimen.space_normal);

    final boolean titleVisible = title_TV.getVisibility() == VISIBLE;
    final boolean secondaryTitleVisible = secondaryTitle_TV.getVisibility() == VISIBLE;
    final boolean subTitleVisible = subTitle_TV.getVisibility() == VISIBLE;
    final boolean contentVisible = content_FL.getVisibility() == VISIBLE;
    final boolean iconVisible = icon_IV.getVisibility() == VISIBLE;

    MarginLayoutParams lp = (MarginLayoutParams) subTitle_TV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) content_FL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) icon_IV.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin = titleVisible || secondaryTitleVisible || subTitleVisible ? margin : 0;

    lp = (MarginLayoutParams) listContainer_LL.getLayoutParams();
    //noinspection ConstantConditions
    lp.topMargin =
        titleVisible || secondaryTitleVisible || subTitleVisible || contentVisible || iconVisible
            ? margin
            : 0;
  }
  private void setHeaderPadding(int padding) {
    headerPadding = padding;

    MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) header.getLayoutParams();
    mlp.setMargins(0, Math.round(padding), 0, 0);
    header.setLayoutParams(mlp);
  }
Exemplo n.º 4
0
  public List<TextView> buildSpannable(List<Tag> tags) {
    List<TextView> views = new ArrayList<TextView>();
    for (Tag g : tags) {
      TextView view = new TextView(getContext());
      view.setText("#" + g.content);
      view.setTag(g);
      MarginLayoutParams params =
          new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      final int margin = U.dp2px(4);
      params.setMargins(margin * 2, margin, margin * 2, margin);
      view.setLayoutParams(params);

      view.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              FeedsSearchActivity.start(getContext(), ((Tag) v.getTag()).content);
            }
          });

      final int padding = U.dp2px(8);
      view.setPadding(padding * 2, padding, padding * 2, padding);

      view.setBackgroundDrawable(
          new RoundRectDrawable(
              U.dp2px(4),
              getContext().getResources().getColorStateList(R.color.apptheme_primary_white_btn)));
      views.add(view);
    }
    return views;
  }
  protected void setupTitle(Context context, String title) {
    titleView = new TextView(context);
    titleView.setText(title);
    titleView.setCompoundDrawablePadding(0);
    if (mExpanded) {

      titleView.setCompoundDrawablesWithIntrinsicBounds(
          null, null, getResources().getDrawable(R.drawable.ic_collapse), null);
    } else {
      titleView.setCompoundDrawablesWithIntrinsicBounds(
          null, null, getResources().getDrawable(R.drawable.ic_expand), null);
    }
    MarginLayoutParams params =
        new MarginLayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            titleView.getCompoundDrawables()[2].getIntrinsicHeight());
    params.setMargins(
        0, 0, 0, getResources().getDimensionPixelSize(R.dimen.card_expandable_title_bottom_margin));
    titleView.setLayoutParams(params);
    titleView.setOnClickListener(expandClick);
    titleView.setTextSize(
        TypedValue.COMPLEX_UNIT_PX,
        getResources().getDimension(R.dimen.card_expandable_title_text_size));
    Utils.setRobotoThin(context, titleView, Typeface.BOLD);
    titleView.setTypeface(null, Typeface.BOLD);
    addContentView(titleView);
  }
Exemplo n.º 6
0
  static {
    COLUMN_PARAMS =
        new TableRow.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    COLUMN_PARAMS.setMargins(0, 0, 32, 0);

    MARGIN_PARAMS =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    MARGIN_PARAMS.setMargins(0, 16, 0, 16);
  }
Exemplo n.º 7
0
 /** 初始化标题图片 */
 private void initTitleImage() {
   int padLeft = DisplayUtil.dip2px(mContext, 20);
   int h = mTitleImage.getMinimumHeight();
   ImageView imageView = new ImageView(mContext);
   imageView.setImageDrawable(mTitleImage);
   MarginLayoutParams mp = new MarginLayoutParams(h, h); // item的宽高
   mp.setMargins(padLeft, 0, 0, 0);
   RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mp);
   params.addRule(RelativeLayout.CENTER_VERTICAL);
   imageView.setLayoutParams(params);
   title.addView(imageView);
 }
 // Wrapper around setting the header offset in different ways depending on
 // the API version
 @SuppressLint("NewApi")
 private void setHeaderOffet(int offset) {
   if (mHeaderOffset == null || mHeaderOffset != offset) {
     mHeaderOffset = offset;
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
       mHeader.setTranslationY(mHeaderOffset);
     } else {
       MarginLayoutParams params = (MarginLayoutParams) mHeader.getLayoutParams();
       params.topMargin = mHeaderOffset;
       mHeader.setLayoutParams(params);
     }
   }
 }
Exemplo n.º 9
0
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   if (log.isDebugEnabled()) {
     log.debug("onLayout ...");
   }
   super.onLayout(changed, l, t, r, b);
   if (changed && (headerLayoutParams == null)) {
     hideHeaderHeight = -header.getHeight();
     if (log.isDebugEnabled()) {
       log.debug("init Layout params, hideHeaderHeight :" + hideHeaderHeight);
     }
     headerLayoutParams = (MarginLayoutParams) header.getLayoutParams();
     headerLayoutParams.topMargin = hideHeaderHeight;
     if (!this.pendingTasks.isEmpty()) {
       for (AsyncTask<Void, Integer, Integer> task : this.pendingTasks) {
         task.execute();
       }
       this.pendingTasks.clear();
     }
   } else {
     if (log.isDebugEnabled()) {
       log.debug("onLayout, hideHeaderHeight :" + headerLayoutParams.topMargin);
     }
     // header.setLayoutParams(headerLayoutParams);
   }
 }
Exemplo n.º 10
0
  /** 初始化标题题目 */
  private void initTitleText() {
    int padLeft = DisplayUtil.dip2px(mContext, 25);
    int h = 0;
    if (mTitleImage != null) {
      h = mTitleImage.getMinimumHeight();
    }
    TextView tv = new TextView(mContext);
    tv.setTextSize(title_size);
    tv.setTextColor(title_color);
    tv.setText(mTitlt);
    int padTop = DisplayUtil.dip2px(mContext, 10);
    tv.setPadding(padLeft + h, padTop, 0, padTop);
    title.addView(tv);
    mButton = new ImageButton(mContext);
    mButton.setImageDrawable(mCollapsed ? mExpandDrawable : mCollapseDrawable);
    h = mExpandDrawable.getMinimumHeight();
    MarginLayoutParams mp = new MarginLayoutParams(h, h); // item的宽高
    mp.setMargins(0, 0, padLeft, 0); // 分别是margin_top那四个属性
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(mp);
    params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    params.addRule(RelativeLayout.CENTER_VERTICAL);
    mButton.setLayoutParams(params);
    title.addView(mButton);
    //        title.measure(0, 0);

    View line = new View(mContext);
    line.setBackgroundColor(line_color);
    h = DisplayUtil.dip2px(mContext, 1);
    MarginLayoutParams mpLine = new MarginLayoutParams(LayoutParams.MATCH_PARENT, h); // item的宽高
    title.measure(0, 0);
    h = title.getMeasuredHeight() - h;
    mpLine.setMargins(0, h, 0, 0); // 分别是margin_top那四个属性
    RelativeLayout.LayoutParams mpLineparams = new RelativeLayout.LayoutParams(mpLine);
    line.setLayoutParams(mpLineparams);
    title.addView(line);

    View line1 = new View(mContext);
    line1.setBackgroundColor(line_color);
    h = DisplayUtil.dip2px(mContext, 1);
    MarginLayoutParams mpLine1 = new MarginLayoutParams(LayoutParams.MATCH_PARENT, h); // item的宽高
    RelativeLayout.LayoutParams mpLineparams1 = new RelativeLayout.LayoutParams(mpLine1);
    line1.setLayoutParams(mpLineparams1);
    title.addView(line1);

    mMinHeight = title.getMeasuredHeight();
    addView(title);
  }
Exemplo n.º 11
0
  private void changeAdapter() {
    removeAllViews();
    TagAdapter adapter = mTagAdapter;
    TagView tagViewContainer = null;
    HashSet preCheckedList = mTagAdapter.getPreCheckedList();
    for (int i = 0; i < adapter.getCount(); i++) {
      View tagView = adapter.getView(this, i, adapter.getItem(i));

      tagViewContainer = new TagView(getContext());
      //            ViewGroup.MarginLayoutParams clp = (ViewGroup.MarginLayoutParams)
      // tagView.getLayoutParams();
      //            ViewGroup.MarginLayoutParams lp = new ViewGroup.MarginLayoutParams(clp);
      //            lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
      //            lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
      //            lp.topMargin = clp.topMargin;
      //            lp.bottomMargin = clp.bottomMargin;
      //            lp.leftMargin = clp.leftMargin;
      //            lp.rightMargin = clp.rightMargin;
      tagView.setDuplicateParentStateEnabled(true);
      if (tagView.getLayoutParams() != null) {
        tagViewContainer.setLayoutParams(tagView.getLayoutParams());
      } else {
        MarginLayoutParams lp =
            new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(
            dip2px(getContext(), 5),
            dip2px(getContext(), 5),
            dip2px(getContext(), 5),
            dip2px(getContext(), 5));
        tagViewContainer.setLayoutParams(lp);
      }
      tagViewContainer.addView(tagView);
      addView(tagViewContainer);

      if (preCheckedList.contains(i)) {
        tagViewContainer.setChecked(true);
      }

      if (mTagAdapter.setSelected(i, adapter.getItem(i))) {
        mSelectedView.add(i);
        tagViewContainer.setChecked(true);
        Log.e("selected or no", "" + i + " = " + adapter.getItem(i) + " | ");
      }
    }
    mSelectedView.addAll(preCheckedList);
  }
Exemplo n.º 12
0
 /** 当ListView被触摸时调用,其中处理了各种下拉刷新的具体逻辑。 */
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   setIsAbleToPull(event);
   if (ableToPull) {
     switch (event.getAction()) {
       case MotionEvent.ACTION_DOWN:
         yDown = event.getRawY();
         break;
       case MotionEvent.ACTION_MOVE:
         float yMove = event.getRawY();
         int distance = (int) (yMove - yDown);
         // 如果手指是下滑状态,并且下拉头是完全隐藏的,就屏蔽下拉事件
         if (distance <= 0 && headerLayoutParams.topMargin <= hideHeaderHeight) {
           return false;
         }
         if (distance < touchSlop) {
           return false;
         }
         if (currentStatus != STATUS_REFRESHING) {
           if (headerLayoutParams.topMargin > 0) {
             currentStatus = STATUS_RELEASE_TO_REFRESH;
           } else {
             currentStatus = STATUS_PULL_TO_REFRESH;
           }
           // 通过偏移下拉头的topMargin值,来实现下拉效果
           headerLayoutParams.topMargin = (distance / 2) + hideHeaderHeight;
           header.setLayoutParams(headerLayoutParams);
         }
         break;
       case MotionEvent.ACTION_UP:
       default:
         if (currentStatus == STATUS_RELEASE_TO_REFRESH) {
           // 松手时如果是释放立即刷新状态,就去调用正在刷新的任务
           new RefreshingTask().execute();
         } else if (currentStatus == STATUS_PULL_TO_REFRESH) {
           // 松手时如果是下拉状态,就去调用隐藏下拉头的任务
           new HideHeaderTask().execute();
         }
         break;
     }
     // 时刻记得更新下拉头中的信息
     if (currentStatus == STATUS_PULL_TO_REFRESH || currentStatus == STATUS_RELEASE_TO_REFRESH) {
       updateHeaderView();
       // 当前正处于下拉或释放状态,要让ListView失去焦点,否则被点击的那一项会一直处于选中状态
       listView.setPressed(false);
       listView.setFocusable(false);
       listView.setFocusableInTouchMode(false);
       lastStatus = currentStatus;
       // 当前正处于下拉或释放状态,通过返回true屏蔽掉ListView的滚动事件
       return true;
     }
   }
   return false;
 }
Exemplo n.º 13
0
 /** 设置未读消息偏移,原点为文字的右上角.当控件高度固定,消息提示位置易控制,显示效果佳 */
 public void setMsgMargin(int position, float leftPadding, float bottomPadding) {
   if (position >= mTabCount) {
     position = mTabCount - 1;
   }
   View tabView = mTabsContainer.getChildAt(position);
   MsgView tipView = (MsgView) tabView.findViewById(R.id.rtv_msg_tip);
   if (tipView != null) {
     TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
     mTextPaint.setTextSize(mTextsize);
     float textWidth = mTextPaint.measureText(tv_tab_title.getText().toString());
     float textHeight = mTextPaint.descent() - mTextPaint.ascent();
     MarginLayoutParams lp = (MarginLayoutParams) tipView.getLayoutParams();
     lp.leftMargin =
         mTabWidth >= 0
             ? (int) (mTabWidth / 2 + textWidth / 2 + dp2px(leftPadding))
             : (int) (mTabPadding + textWidth + dp2px(leftPadding));
     lp.topMargin = mHeight > 0 ? (int) (mHeight - textHeight) / 2 - dp2px(bottomPadding) : 0;
     tipView.setLayoutParams(lp);
   }
 }
Exemplo n.º 14
0
 /** 进行一些关键性的初始化操作,比如:将下拉头向上偏移进行隐藏,给ListView注册touch事件。 */
 @Override
 protected void onLayout(boolean changed, int l, int t, int r, int b) {
   super.onLayout(changed, l, t, r, b);
   if (changed && !loadOnce) {
     hideHeaderHeight = -header.getHeight();
     headerLayoutParams = (MarginLayoutParams) header.getLayoutParams();
     headerLayoutParams.topMargin = hideHeaderHeight;
     listView = (ListView) getChildAt(1);
     listView.setOnTouchListener(this);
     loadOnce = true;
   }
 }
Exemplo n.º 15
0
 private void applyMarginInsets(
     MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
   WindowInsets wi = (WindowInsets) insets;
   if (drawerGravity == Gravity.LEFT) {
     wi =
         wi.replaceSystemWindowInsets(
             wi.getSystemWindowInsetLeft(),
             wi.getSystemWindowInsetTop(),
             0,
             wi.getSystemWindowInsetBottom());
   } else if (drawerGravity == Gravity.RIGHT) {
     wi =
         wi.replaceSystemWindowInsets(
             0,
             wi.getSystemWindowInsetTop(),
             wi.getSystemWindowInsetRight(),
             wi.getSystemWindowInsetBottom());
   }
   lp.leftMargin = wi.getSystemWindowInsetLeft();
   lp.topMargin = topOnly ? 0 : wi.getSystemWindowInsetTop();
   lp.rightMargin = wi.getSystemWindowInsetRight();
   lp.bottomMargin = wi.getSystemWindowInsetBottom();
 }
Exemplo n.º 16
0
  @Override
  public void onLayoutInit() {
    // 获取右侧布局对象
    SlideContent rightLayout = (SlideContent) findViewById(CONTENT_CONTAINER_ID);
    MarginLayoutParams rightLayoutParams = (MarginLayoutParams) rightLayout.getLayoutParams();
    rightLayoutParams.width = getMeasuredWidth();
    rightLayout.setLayoutParams(rightLayoutParams);
    // 获取左侧布局对象
    LinearLayout leftLayout = (LinearLayout) findViewById(MENU_CONTAINER_ID);
    MarginLayoutParams leftLayoutParams = (MarginLayoutParams) leftLayout.getLayoutParams();
    int rightEdge = -leftLayoutParams.width;

    rightLayout.init(rightEdge, leftLayoutParams);
    loadOnce = true;
    Log.e(
        TAG,
        "initData,rightEdge : "
            + rightEdge
            + " leftWidth : "
            + leftLayoutParams.width
            + " rightWidth : "
            + rightLayout.getWidth());
  }
Exemplo n.º 17
0
 /**
  * 根据当前ListView的滚动状态来设定 {@link #ableToPull}
  * 的值,每次都需要在onTouch中第一个执行,这样可以判断出当前应该是滚动ListView,还是应该进行下拉。
  *
  * @param event
  */
 private void setIsAbleToPull(MotionEvent event) {
   View firstChild = listView.getChildAt(0);
   if (firstChild != null) {
     int firstVisiblePos = listView.getFirstVisiblePosition();
     if (firstVisiblePos == 0 && firstChild.getTop() == 0) {
       if (!ableToPull) {
         yDown = event.getRawY();
       }
       // 如果首个元素的上边缘,距离父布局值为0,就说明ListView滚动到了最顶部,此时应该允许下拉刷新
       ableToPull = true;
     } else {
       if (headerLayoutParams.topMargin != hideHeaderHeight) {
         headerLayoutParams.topMargin = hideHeaderHeight;
         header.setLayoutParams(headerLayoutParams);
       }
       ableToPull = false;
     }
   } else {
     // 如果ListView中没有元素,也应该允许下拉刷新
     ableToPull = true;
   }
 }
Exemplo n.º 18
0
 private void setMargin(int top) {
   headerMargins.topMargin = top;
   LayoutParams params = new LayoutParams(headerMargins);
   header.setLayoutParams(params);
 }
Exemplo n.º 19
0
 public void setOffset(float offset) {
   int parallaxOffset = (int) (offset * mParallaxValue);
   mLayoutParams.leftMargin = parallaxOffset;
   mLayoutParams.rightMargin = -parallaxOffset;
   requestLayout();
 }
Exemplo n.º 20
0
 /** 当ListView被触摸时调用,其中处理了各种下拉刷新的具体逻辑。 */
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   setIsAbleToPull(v, event);
   boolean retVal = false;
   if (ableToPull) {
     switch (event.getAction()) {
       case MotionEvent.ACTION_DOWN:
         yDown = event.getRawY();
         // if(log.isDebugEnabled()){
         // log.debug("Touch down, y position :"+yDown);
         // }
         break;
       case MotionEvent.ACTION_MOVE:
         float yMove = event.getRawY();
         int distance = (int) (yMove - yDown);
         // if(log.isDebugEnabled()){
         // log.debug("Touch down and move, y position :"+yMove+", move distance :"+distance);
         // }
         // 如果手指是下滑状态,并且下拉头是完全隐藏的,就屏蔽下拉事件
         if (distance <= 0 && headerLayoutParams.topMargin <= hideHeaderHeight) {
           return false;
         }
         if (distance < touchSlop) {
           return false;
         }
         if (!pullStarted) {
           // if(log.isDebugEnabled()){
           // log.debug("Pull started, touchSlop = "+touchSlop);
           // }
           pullableView.pullStarted(v);
           pullStarted = true;
         }
         retVal = true;
         if (currentStatus != STATUS_REFRESHING) {
           if (headerLayoutParams.topMargin > 0) {
             currentStatus = STATUS_RELEASE_TO_REFRESH;
           } else {
             currentStatus = STATUS_PULL_TO_REFRESH;
           }
           // 通过偏移下拉头的topMargin值,来实现下拉效果
           headerLayoutParams.topMargin = (distance / 2) + hideHeaderHeight;
           header.setLayoutParams(headerLayoutParams);
         }
         break;
       case MotionEvent.ACTION_UP:
       default:
         if (pullStarted) {
           pullableView.pullEnded(v);
           pullStarted = false;
           retVal = true;
         }
         if (currentStatus == STATUS_RELEASE_TO_REFRESH) {
           // 松手时如果是释放立即刷新状态,就去调用正在刷新的任务
           setOnRefreshing(true);
         } else if (currentStatus == STATUS_PULL_TO_REFRESH) {
           // 松手时如果是下拉状态,就去调用隐藏下拉头的任务
           hideHeader();
         }
         break;
     }
     // 时刻记得更新下拉头中的信息
     if (currentStatus == STATUS_PULL_TO_REFRESH || currentStatus == STATUS_RELEASE_TO_REFRESH) {
       updateHeaderView();
       // 当前正处于下拉或释放状态,要让ListView失去焦点,否则被点击的那一项会一直处于选中状态
       pullableView.getView().setPressed(false);
       pullableView.getView().setFocusable(false);
       pullableView.getView().setFocusableInTouchMode(false);
       lastStatus = currentStatus;
       // 当前正处于下拉或释放状态,通过返回true屏蔽掉ListView的滚动事件
     }
   }
   return retVal;
 }
Exemplo n.º 21
0
package com.chang.news.util;
Exemplo n.º 22
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;
    }