Java 类android.view.View.DragShadowBuilder 实例源码

项目:charminder    文件:CircleLayoutSettingActivity.java   
@Override
public void onLongPress(MotionEvent e) {
    for (int i = 0; i < C.NUM_CIRCLE_ITEMS; i++) {
        boolean bUsed = false;
        for (int j = 0; j < G.settings.mCircleSection.length; j++) {
            if(G.settings.mCircleSection[j] == i){
                bUsed = true;
                break;
            }
        }
        if (!bUsed){
            if (ViewBase.isPointInsideRect(e.getX(), e.getY(), 
                    mCircleItems[i].getX(), mCircleItems[i].getY(),
                    mCircleItems[i].getWidth(), mCircleItems[i].getHeight())) {
                Drawable oldDrawable = mCircleItems[i].getDrawable();
                mCircleItems[i].setBackgroundResource(R.drawable.light_circle_wrapper);
                DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(mCircleItems[i]);
                ClipData data = ClipData.newPlainText(DRAG_FROM_UNUSED_TAG, String.valueOf(i));
                mCircleItems[i].startDrag(data, shadowBuilder, mCircleItems[i], 0);
                mCircleItems[i].setVisibility(View.INVISIBLE);
                mCircleItems[i].setImageDrawable(oldDrawable);
                break;
            }
        }
    }
}
项目:charminder    文件:CircleLayoutSettingActivity.java   
@Override
public void onLongPress(MotionEvent e) {
    for (int i = 0; i < G.settings.mCircleSection.length; i++) {
        final int RADIUS_COMPLEMENT = 8;
        int iconSize = (int) getResources().getDimension(
                R.dimen.circle_item_size);
        int item = G.settings.mCircleSection[i];
        if (ViewBase.isPointInsideCircle((int)e.getX(), (int)e.getY(), 
                (int)(mCircleItems[item].getX() + mCircleItems[item].getWidth() / 2),
                (int)(mCircleItems[item].getY() + mCircleItems[item].getHeight() / 2),
                (int)(iconSize/2 + ViewBase.dpToPx(RADIUS_COMPLEMENT)))) {
            Drawable oldDrawable = mCircleItems[item].getDrawable();
            mCircleItems[item].setBackgroundResource(R.drawable.light_circle_wrapper);
            DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(mCircleItems[item]);
            ClipData data = ClipData.newPlainText(DRAG_FROM_CIRCLE_TAG, String.valueOf(i));
            mCircleItems[item].startDrag(data, shadowBuilder, mCircleItems[item], 0);
            mCircleItems[item].setVisibility(View.INVISIBLE);
            mCircleItems[item].setImageDrawable(oldDrawable);
            break;
        }
    }
}
项目:ClubHelperAndroid    文件:PersonListFragment.java   
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View childView,
        int position, long id) {

    Person person = controller.getPersonAt(position);

    String text = person.toString();
    ClipData.Item item = new ClipData.Item(text);
    String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN};
    ClipData data = new ClipData(text, mimeTypes, item);
    DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(childView);

    childView.startDrag(data, shadowBuilder, childView, 0);
    childView.setVisibility(View.INVISIBLE);
    filter.setVisibility(View.GONE);

    buttonBarDropTarget.setVisibility(View.VISIBLE);
    return true;
}
项目:ClubHelperAndroid    文件:PersonDetailFragment.java   
@Override
public boolean onLongClick(View v) {
    Object tag = v.getTag();
    long contactId = (Long) tag;
    PersonContact contact = controller.findContactWithId(contactId);
    String text = contact.getType() + " - " + contact.getValue();
    ClipData.Item item = new ClipData.Item(text);
    String[] mimeTypes = { ClipDescription.MIMETYPE_TEXT_PLAIN };
    ClipData data = new ClipData(text, mimeTypes, item);
    DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);

    v.startDrag(data, shadowBuilder, v, 0);
    v.setVisibility(View.INVISIBLE);

    buttonBarMain.setVisibility(View.GONE);
    buttonBarDropContact.setVisibility(View.VISIBLE);
    txtFullNameView.setEnabled(false);
    return true;
}
项目:rpgpack-android    文件:MapGridElementAdapter.java   
private View addImagetoContainer(View inputView, final int position,
        Drawable drawable) {

    final ImageView pieceView = (ImageView) inputView
            .findViewById(R.id.map_piece);
    pieceView.setImageDrawable(drawable);
    pieceView.setTag(position);
    pieceView.setContentDescription("grid");
    pieceView.setOnTouchListener(new View.OnTouchListener() {
        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            final ClipData data = ClipData.newPlainText("position",
                    position + "");
            final DragShadowBuilder pieceDragShadowBuilder = new DragShadowBuilder(
                    pieceView);
            trash.setVisibility(View.VISIBLE);
            startClickTime = Calendar.getInstance()
                    .getTimeInMillis();
            v.setVisibility(View.INVISIBLE);
            v.startDrag(data, pieceDragShadowBuilder, v, 0);
            return true;
        }
    });
    return inputView;
}
项目:HallMonitor    文件:CallTouchListener.java   
public boolean onTouch(View view, MotionEvent motionEvent) {
      if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
          switch(view.getId()){
          case R.id.pickup_button:
              ClipData data = ClipData.newPlainText("Pickup", "Call");
              DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
              view.startDrag(data, shadowBuilder, view, 0);
              view.setVisibility(View.INVISIBLE);
          break;
          case R.id.hangup_button:
              ClipData data2 = ClipData.newPlainText("Hang", "Call");
              DragShadowBuilder shadowBuilder2 = new View.DragShadowBuilder(view);
              view.startDrag(data2, shadowBuilder2, view, 0);
              view.setVisibility(View.INVISIBLE);
          }
        return true;
      } else {
        return false;
      }
}
项目:boilr    文件:SwipeAndMoveTouchListener.java   
@Override
public void run() {
     view.post(new Runnable() {
     @Override
     public void run() {
            mPointToPosition = -1;
            mSwiping = false;
            mItemPressed = false;
            ClipData data = ClipData.newPlainText("", "");
            DragShadowBuilder sb = new View.DragShadowBuilder(view);
            view.startDrag(data, sb, new Reference<View>(view), 0);
        }
    });
}
项目:amddviews    文件:DragDropDelegate.java   
@Override
public DragShadowBuilder generateDragShadow(AdaptableDragDropView dragSource) {
    if (mCurrentDragSession.dragBuddies == null) {
        return new DragShadowBuilder(dragSource);
    } else {
        // Get dragging image view for generating drag shadow
        ImageView draggingView = dragSource.getDragInfo().draggingView;

        return new DragShadowBuilder((draggingView != null) ? draggingView
                : dragSource);
    }
}
项目:jukefox    文件:ViewFactory.java   
private DragShadowBuilder createDragShadowBuilderImpl(String text) {
    View view = layoutInflater.inflate(R.layout.tablet_overlay_droparea, null);
    view.setBackgroundResource(R.drawable.d171_box_background_highlight);
    ((TextView) view.findViewById(R.id.text)).setText(text);
    return new TabletDragShadowBuilder(view, (int) (DRAG_SHADOW_WIDTH * densityScale),
            (int) (DRAG_SHADOW_HEIGHT * densityScale));
}
项目:jukefox    文件:DragManager.java   
private void startDraggingImpl(View view,
        DragDataContainer<PlaylistSong<BaseArtist, BaseAlbum>> dragDataContainer,
        DragShadowBuilder dragShadowBuilder) {
    tabletPresenter.highlight();
    view.startDrag(EMPTY_CLIP_DATA, dragShadowBuilder,
            dragDataContainer, 0);
}
项目:codeexamples-android    文件:DragActivity.java   
public boolean onTouch(View view, MotionEvent motionEvent) {
    if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
        ClipData data = ClipData.newPlainText("", "");
        DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(
                view);
        view.startDrag(data, shadowBuilder, view, 0);
        view.setVisibility(View.INVISIBLE);
        return true;
    } else {
        return false;
    }
}
项目:codeexamples-android    文件:DragActivity.java   
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    // start move on a touch event
    if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
        ClipData data = ClipData.newPlainText("", "");
        DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
        view.startDrag(data, shadowBuilder, view, 0);
        view.setVisibility(View.INVISIBLE);
        return true;
    }
    return false;

}
项目:codeexamples-android    文件:DragActivity.java   
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
    // start move on a touch event
    if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
        ClipData data = ClipData.newPlainText("", "");
        DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
        view.startDrag(data, shadowBuilder, view, 0);
        view.setVisibility(View.INVISIBLE);
        return true;
    }
    return false;

}
项目:sw606f13    文件:MainActivity.java   
public boolean onTouch(View view, MotionEvent motionEvent) {

  if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
    ClipData data = ClipData.newPlainText("", "");
    DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
    view.startDrag(data, shadowBuilder, view, 0);
    view.setVisibility(View.INVISIBLE);
        return true;
   } 
  else {
    return false;
  }
}
项目:sw606f13    文件:MainActivity.java   
public boolean onTouch(View view, MotionEvent motionEvent) {
  if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
    ClipData data = ClipData.newPlainText("", "");
    DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(view);
    view.startDrag(data, shadowBuilder, view, 0);
    view.setVisibility(View.INVISIBLE);
    return true;
  } else {
    return false;
  }
}
项目:LaunchEnr    文件:AddItemActivity.java   
@Override
public boolean onLongClick(View view) {
    // Find the position of the preview relative to the touch location.
    WidgetImageView img = mWidgetCell.getWidgetView();

    // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
    // we abort the drag.
    if (img.getBitmap() == null) {
        return false;
    }

    Rect bounds = img.getBitmapBounds();
    bounds.offset(img.getLeft() - (int) mLastTouchPos.x, img.getTop() - (int) mLastTouchPos.y);

    // Start home and pass the draw request params
    PinItemDragListener listener = new PinItemDragListener(mRequest, bounds,
            img.getBitmap().getWidth(), img.getWidth());
    Intent homeIntent = new Intent(Intent.ACTION_MAIN)
            .addCategory(Intent.CATEGORY_HOME)
            .setPackage(getPackageName())
            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            .putExtra(PinItemDragListener.EXTRA_PIN_ITEM_DRAG_LISTENER, listener);

    if (!PreferencesState.isAllowRotationPrefEnabled(this) &&
            (getResources().getConfiguration().orientation ==
                    Configuration.ORIENTATION_LANDSCAPE && !isInMultiWindowMode())) {
        // If we are starting the drag in landscape even though home is locked in portrait,
        // restart the home activity to temporarily allow rotation.
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    }

    startActivity(homeIntent,
            ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out).toBundle());

    // Start a system drag and drop. We use a transparent bitmap as preview for system drag
    // as the preview is handled internally by launcher.
    ClipDescription description = new ClipDescription("", new String[]{listener.getMimeType()});
    ClipData data = new ClipData(description, new ClipData.Item(""));
    view.startDragAndDrop(data, new DragShadowBuilder(view) {

        @Override
        public void onDrawShadow(Canvas canvas) { }

        @Override
        public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) {
            outShadowSize.set(SHADOW_SIZE, SHADOW_SIZE);
            outShadowTouchPoint.set(SHADOW_SIZE / 2, SHADOW_SIZE / 2);
        }
    }, null, View.DRAG_FLAG_GLOBAL);
    return false;
}
项目:freeotp-android    文件:BaseReorderableAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        int type = getItemViewType(position);
        convertView = createView(parent, type);

        convertView.setOnDragListener(new OnDragListener() {
            @Override
            @SuppressWarnings("unchecked")
            //unavoidable generic type problems -> Reference<View>
            public boolean onDrag(View dstView, DragEvent event) {
                Reference<View> ref = (Reference<View>) event.getLocalState();
                final View srcView = ref.reference;

                switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    srcView.setVisibility(View.VISIBLE);
                    dstView.setVisibility(View.INVISIBLE);

                    move(((Integer) srcView.getTag(R.id.reorder_key)),
                         ((Integer) dstView.getTag(R.id.reorder_key)));
                    ref.reference = dstView;
                    break;

                case DragEvent.ACTION_DRAG_ENDED:
                    srcView.post(new Runnable() {
                        @Override
                        public void run() {
                            srcView.setVisibility(View.VISIBLE);
                        }
                    });
                    break;
                }

                return true;
            }
        });

        convertView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(final View view) {
                // Force a reset of any states
                notifyDataSetChanged();

                // Start the drag on the main loop to allow
                // the above state reset to settle.
                view.post(new Runnable() {
                    @Override
                    @SuppressWarnings("deprecation")
                    //startDrag() --> suppress deprecation because startDragAndDrop() requires minSdkVersion 24
                    public void run() {
                        ClipData data = ClipData.newPlainText("", "");
                        DragShadowBuilder sb = new View.DragShadowBuilder(view);
                        view.startDrag(data, sb, new Reference<>(view), 0);
                    }
                });

                return true;
            }
        });
    }

    convertView.setTag(R.id.reorder_key, position);
    bindView(convertView, position);
    return convertView;
}
项目:freeotp    文件:BaseReorderableAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        int type = getItemViewType(position);
        convertView = createView(parent, type);

        convertView.setOnDragListener(new OnDragListener() {
            @Override
            public boolean onDrag(View dstView, DragEvent event) {
                Reference<View> ref = (Reference<View>) event.getLocalState();
                final View srcView = ref.reference;

                switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    srcView.setVisibility(View.VISIBLE);
                    dstView.setVisibility(View.INVISIBLE);

                    move(((Integer) srcView.getTag(R.id.reorder_key)).intValue(),
                         ((Integer) dstView.getTag(R.id.reorder_key)).intValue());
                    ref.reference = dstView;
                    break;

                case DragEvent.ACTION_DRAG_ENDED:
                    srcView.post(new Runnable() {
                        @Override
                        public void run() {
                            srcView.setVisibility(View.VISIBLE);
                        }
                    });
                    break;
                }

                return true;
            }
        });

        convertView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(final View view) {
                // Force a reset of any states
                notifyDataSetChanged();

                // Start the drag on the main loop to allow
                // the above state reset to settle.
                view.post(new Runnable() {
                    @Override
                    public void run() {
                        ClipData data = ClipData.newPlainText("", "");
                        DragShadowBuilder sb = new View.DragShadowBuilder(view);
                        view.startDrag(data, sb, new Reference<View>(view), 0);
                    }
                });

                return true;
            }
        });
    }

    convertView.setTag(R.id.reorder_key, Integer.valueOf(position));
    bindView(convertView, position);
    return convertView;
}
项目:FreeOTP-Android    文件:ReorderableBaseAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        int type = getItemViewType(position);
        convertView = createView(parent, type);

        convertView.setOnDragListener(new OnDragListener() {
            @Override
            public boolean onDrag(View dstView, DragEvent event) {
                Reference<View> ref = (Reference<View>) event.getLocalState();
                final View srcView = ref.reference;

                switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    srcView.setVisibility(View.VISIBLE);
                    dstView.setVisibility(View.INVISIBLE);

                    move(((Integer) srcView.getTag(KEY)).intValue(),
                         ((Integer) dstView.getTag(KEY)).intValue());
                    ref.reference = dstView;
                    break;

                case DragEvent.ACTION_DRAG_ENDED:
                    srcView.post(new Runnable() {
                        @Override
                        public void run() {
                            srcView.setVisibility(View.VISIBLE);
                        }
                    });
                    break;
                }

                return true;
            }
        });

        convertView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(final View view) {
                // Force a reset of any states
                notifyDataSetChanged();

                // Start the drag on the main loop to allow
                // the above state reset to settle.
                view.post(new Runnable() {
                    @Override
                    public void run() {
                        ClipData data = ClipData.newPlainText("", "");
                        DragShadowBuilder sb = new View.DragShadowBuilder(view);
                        view.startDrag(data, sb, new Reference<View>(view), 0);
                    }
                });

                return true;
            }
        });
    }

    convertView.setTag(KEY, Integer.valueOf(position));
    bindView(convertView, position);
    return convertView;
}
项目:rpgpack-android    文件:MapGridElementAdapter.java   
public View getView(final int position, View convertView, ViewGroup parent) {

        View squareContainerView = convertView;

        if (squareContainerView == null) {
            squareContainerView = mInflater.inflate(
                    R.layout.activity_game_toolbox_map_cell, null);

            squareContainerView.setOnDragListener(new MyDragListener(
                    this.mContext));

            final ImageView pieceView = (ImageView) squareContainerView
                    .findViewById(R.id.map_piece);
            if (dotsList.get(position) != null) {
                pieceView.setImageDrawable(dotsList.get(position));
                pieceView.setTag(position);
                pieceView.setContentDescription(tag);

                pieceView.setOnTouchListener(new View.OnTouchListener() {
                    @SuppressLint("ClickableViewAccessibility")
                    @Override
                    public boolean onTouch(View v, MotionEvent event) {
                        final ClipData data = ClipData.newPlainText("position",
                                position + "");
                        final DragShadowBuilder pieceDragShadowBuilder = new DragShadowBuilder(
                                pieceView);
                        if (tag == "grid"){
                            v.setVisibility(View.INVISIBLE);
                            trash.setVisibility(View.VISIBLE);
                        }
                        startClickTime = Calendar.getInstance()
                                .getTimeInMillis();
                        v.startDrag(data, pieceDragShadowBuilder, v, 0);
                        return true;
                    }
                });

            }
        }

        return squareContainerView;
    }
项目:FreeOTP-fork    文件:BaseReorderableAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        int type = getItemViewType(position);
        convertView = createView(parent, type);

        convertView.setOnDragListener(new OnDragListener() {
            @Override
            public boolean onDrag(View dstView, DragEvent event) {
                Reference<View> ref = (Reference<View>) event.getLocalState();
                final View srcView = ref.reference;

                switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    srcView.setVisibility(View.VISIBLE);
                    dstView.setVisibility(View.INVISIBLE);

                    move(((Integer) srcView.getTag(KEY)).intValue(),
                         ((Integer) dstView.getTag(KEY)).intValue());
                    ref.reference = dstView;
                    break;

                case DragEvent.ACTION_DRAG_ENDED:
                    srcView.post(new Runnable() {
                        @Override
                        public void run() {
                            srcView.setVisibility(View.VISIBLE);
                        }
                    });
                    break;
                }

                return true;
            }
        });

        convertView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(final View view) {
                // Force a reset of any states
                notifyDataSetChanged();

                // Start the drag on the main loop to allow
                // the above state reset to settle.
                view.post(new Runnable() {
                    @Override
                    public void run() {
                        ClipData data = ClipData.newPlainText("", "");
                        DragShadowBuilder sb = new View.DragShadowBuilder(view);
                        view.startDrag(data, sb, new Reference<View>(view), 0);
                    }
                });

                return true;
            }
        });
    }

    convertView.setTag(KEY, Integer.valueOf(position));
    bindView(convertView, position);
    return convertView;
}
项目:safeotp    文件:ReorderableBaseAdapter.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        int type = getItemViewType(position);
        convertView = createView(parent, type);

        convertView.setOnDragListener(new OnDragListener() {
            @Override
            public boolean onDrag(View dstView, DragEvent event) {
                Reference<View> ref = (Reference<View>) event.getLocalState();
                final View srcView = ref.reference;

                switch (event.getAction()) {
                case DragEvent.ACTION_DRAG_ENTERED:
                    srcView.setVisibility(View.VISIBLE);
                    dstView.setVisibility(View.INVISIBLE);

                    move(((Integer) srcView.getTag(KEY)).intValue(),
                         ((Integer) dstView.getTag(KEY)).intValue());
                    ref.reference = dstView;
                    break;

                case DragEvent.ACTION_DRAG_ENDED:
                    srcView.post(new Runnable() {
                        @Override
                        public void run() {
                            srcView.setVisibility(View.VISIBLE);
                        }
                    });
                    break;
                }

                return true;
            }
        });

        convertView.setOnLongClickListener(new OnLongClickListener() {
            @Override
            public boolean onLongClick(final View view) {
                // Force a reset of any states
                notifyDataSetChanged();

                // Start the drag on the main loop to allow
                // the above state reset to settle.
                view.post(new Runnable() {
                    @Override
                    public void run() {
                        ClipData data = ClipData.newPlainText("", "");
                        DragShadowBuilder sb = new View.DragShadowBuilder(view);
                        view.startDrag(data, sb, new Reference<View>(view), 0);
                    }
                });

                return true;
            }
        });
    }

    convertView.setTag(KEY, Integer.valueOf(position));
    bindView(convertView, position);
    return convertView;
}
项目:jukefox    文件:ViewFactory.java   
public DragShadowBuilder createDragShadowBuilderSongs(int numberOfSongs) {
    return createDragShadowBuilderImpl(i18nManager.getNumberOfSongsText(numberOfSongs));
}
项目:jukefox    文件:ViewFactory.java   
public DragShadowBuilder createDragShadowBuilderAlbums(int numberOfAlbums) {
    return createDragShadowBuilderImpl(i18nManager.getNumberOfAlbumsText(numberOfAlbums));
}
项目:jukefox    文件:ViewFactory.java   
public DragShadowBuilder createDragShadowBuilderAllSongs() {
    return createDragShadowBuilderImpl(resources.getString(R.string.all_songs));
}
项目:jukefox    文件:ViewFactory.java   
public DragShadowBuilder createDragShadowBuilderArtist() {
    return createDragShadowBuilderImpl(resources.getString(R.string._1_artist));
}
项目:amddviews    文件:DragProgressDelegate.java   
public DragShadowBuilder generateDragShadow(AdaptableDragDropView dragSource);