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); }
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; }
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); } }
private final void a(View paramView, View.OnDragListener paramOnDragListener) { if ((paramView instanceof ViewGroup)) { for (int j = 0; j < ((ViewGroup)paramView).getChildCount(); j++) { a(((ViewGroup)paramView).getChildAt(j), paramOnDragListener); } } if ((paramView instanceof EditText)) { paramView.setOnDragListener(paramOnDragListener); } }
/** * @see View#setOnDragListener(OnDragListener) */ public W setOnDragListener(OnDragListener l) { mView.setOnDragListener(l); return (W)this; }
@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; }
public Disposable onDrag(final OnDragListener onNext) { return onDrag(onNext, Fu.ON_ERROR_MISSING); }
public Disposable onDrag(final OnDragListener onNext, final Consumer<? super Exception> onError) { return onDrag(onNext, onError, Fu.EMPTY_ACTION); }
@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; }
@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; }