本文整理汇总了Java中android.view.View.OnDragListener类的典型用法代码示例。如果您正苦于以下问题:Java OnDragListener类的具体用法?Java OnDragListener怎么用?Java OnDragListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OnDragListener类属于android.view.View包,在下文中一共展示了OnDragListener类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FolderToggleAdapter
import android.view.View.OnDragListener; //导入依赖的package包/类
public FolderToggleAdapter(Context context, SettingsDecoder settingDecoder, int labelColor, OnDragListener dragListener) {
super(context, R.layout.folder_item, android.R.id.text1);
mContext = context;
mShowLabels = !settingDecoder.hasValue(FolderUtils.KEY_HIDE_LABEL);
mLabelColor = labelColor;
mInflator = LayoutInflater.from(context);
mDragListener = dragListener;
mRenderSettings = new WidgetSetting(context, new AbstractTracker[]{}, settingDecoder, -420, new Bitmap[]{});
mShortNames = context.getResources().getStringArray(R.array.tracker_names_short);
mStates = context.getResources().getStringArray(R.array.tracker_states);
}
示例2: onDrag
import android.view.View.OnDragListener; //导入依赖的package包/类
public Disposable onDrag(final OnDragListener onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
N.requireNonNull(onNext, "onNext");
N.requireNonNull(onError, "onError");
N.requireNonNull(onComplete, "onComplete");
dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
@Override
public void onNext(Object param) {
final Tuple2<View, DragEvent> tmp = (Tuple2<View, DragEvent>) param;
if (Fu.isUiThread()) {
onNext.onDrag(tmp._1, tmp._2);
} else {
UIExecutor.execute(new Runnable() {
@Override
public void run() {
onNext.onDrag(tmp._1, tmp._2);
}
});
}
}
});
_view.setOnDragListener(new OnDragListener() {
@Override
public boolean onDrag(View view, DragEvent dragEvent) {
dispatcher.onNext(Tuple.of(view, dragEvent));
return true;
}
});
disposeActions.add(new Runnable() {
@Override
public void run() {
_view.setOnDragListener(null);
}
});
return this;
}
示例3: a
import android.view.View.OnDragListener; //导入依赖的package包/类
private final void a(View.OnDragListener paramOnDragListener)
{
this.a.setOnDragListener(paramOnDragListener);
for (int j = 0; j < this.a.getChildCount(); j++) {
a(this.a.getChildAt(j), paramOnDragListener);
}
}
示例4: setOnDragListener
import android.view.View.OnDragListener; //导入依赖的package包/类
/**
* @see View#setOnDragListener(OnDragListener)
*/
public W setOnDragListener(OnDragListener l) {
mView.setOnDragListener(l);
return (W)this;
}
示例5: getView
import android.view.View.OnDragListener; //导入依赖的package包/类
@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;
}
示例6: getView
import android.view.View.OnDragListener; //导入依赖的package包/类
@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;
}
示例7: getView
import android.view.View.OnDragListener; //导入依赖的package包/类
@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;
}