Java Code Examples for android.view.View.setOnTouchListener()

The following are Jave code examples for showing how to use setOnTouchListener() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: VirtualHook   File: CardStackAdapter.java   Source Code and License Vote up 9 votes
void addView(final int position) {
	View root = createView(position, mParent);
	root.setOnTouchListener(this);
	root.setTag(R.id.cardstack_internal_position_tag, position);
	root.setLayerType(View.LAYER_TYPE_HARDWARE, null);

	mCardPaddingInternal = root.getPaddingTop();

	FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
	root.setLayoutParams(lp);
	if (mShowInitAnimation) {
		root.setY(getCardFinalY(position));
		setScreenTouchable(false);
	} else {
		root.setY(getCardOriginalY(position) - mParentPaddingTop);
		setScreenTouchable(true);
	}

	mCardViews[position] = root;

	mParent.addView(root);
}
 
Example 2
Project: decoy   File: BaseItemDraggableAdapter.java   Source Code and License Vote up 6 votes
/**
 * To bind different types of holder and solve different the bind events
 *
 * @param holder
 * @param positions
 * @see #getDefItemViewType(int)
 */
@Override
public void onBindViewHolder(K holder, int positions) {
    super.onBindViewHolder(holder, positions);
    int viewType = holder.getItemViewType();

    if (mItemTouchHelper != null && itemDragEnabled && viewType != LOADING_VIEW && viewType != HEADER_VIEW
            && viewType != EMPTY_VIEW && viewType != FOOTER_VIEW) {
        if (mToggleViewId != NO_TOGGLE_VIEW) {
            View toggleView = ((BaseViewHolder) holder).getView(mToggleViewId);
            if (toggleView != null) {
                toggleView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
                if (mDragOnLongPress) {
                    toggleView.setOnLongClickListener(mOnToggleViewLongClickListener);
                } else {
                    toggleView.setOnTouchListener(mOnToggleViewTouchListener);
                }
            }
        } else {
            holder.itemView.setTag(R.id.BaseQuickAdapter_viewholder_support, holder);
            holder.itemView.setOnLongClickListener(mOnToggleViewLongClickListener);
        }
    }
}
 
Example 3
Project: decoy   File: PagerSlidingTabStrip.java   Source Code and License Vote up 6 votes
private void addTabDoubleTapListener(final int position, View tab) {
    final GestureDetector gd = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            if (onTabDoubleTapListener != null)
                onTabDoubleTapListener.onCurrentTabDoubleTap(position);

            return true;
        }
    });

    tab.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gd.onTouchEvent(event);
        }
    });
}
 
Example 4
Project: DMS   File: FacilityReportAdapter.java   Source Code and License Vote up 6 votes
public ItemViewHolder(View itemView) {
    super(itemView);

    mTitleTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_title);
    mWriterTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_writer);
    mWriteDateTV = (TextView) itemView.findViewById(R.id.tv_facilityreport_writedate);

    itemView.setOnTouchListener(Listeners.changeTextColorOnTouchListener(mContext, mTitleTV));
    itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FacilityReport facilityReport = mFacilityReportList.get(getAdapterPosition());
            viewArticle(facilityReport);
        }
    });
}
 
Example 5
Project: photo-editor-android   File: PhotoEditorSDK.java   Source Code and License Vote up 6 votes
public void addImage(Bitmap desiredImage) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View imageRootView = inflater.inflate(R.layout.photo_editor_sdk_image_item_list, null);
    ImageView imageView = (ImageView) imageRootView.findViewById(R.id.photo_editor_sdk_image_iv);
    imageView.setImageBitmap(desiredImage);
    imageView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT));
    MultiTouchListener multiTouchListener = new MultiTouchListener(deleteView,
            parentView, this.imageView, onPhotoEditorSDKListener);
    multiTouchListener.setOnMultiTouchListener(this);
    imageRootView.setOnTouchListener(multiTouchListener);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
    parentView.addView(imageRootView, params);
    addedViews.add(imageRootView);
    if (onPhotoEditorSDKListener != null)
        onPhotoEditorSDKListener.onAddViewListener(ViewType.IMAGE, addedViews.size());
}
 
Example 6
Project: civify-app   File: CreateIssueActivity.java   Source Code and License Vote up 6 votes
private void setupCloseKeyboard(final View view) {
    if (!(view instanceof EditText)) {
        view.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                hideSoftKeyboard();
                view.requestFocus();
                return false;
            }
        });
    }

    if (view instanceof ViewGroup) {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
            View innerView = ((ViewGroup) view).getChildAt(i);
            setupCloseKeyboard(innerView);
        }
    }
}
 
Example 7
Project: ElephantAsia   File: KeyboardHelpers.java   Source Code and License Vote up 6 votes
/**
 * Attach a listener that hide keyboard to all View and nested View except EditText
 * It allows the soft keyboard to get hidden automatically when EditText is not focus
 *
 * @param view     Current view
 * @param activity Current activity
 */
public static void hideKeyboardListener(View view, final Activity activity) {
  // Set up touch listener for non-text box views to hide keyboard.
  if (!(view instanceof EditText)) {
    view.setOnTouchListener(new View.OnTouchListener() {
      public boolean onTouch(View v, MotionEvent event) {
        hideSoftKeyboard(activity);
        return false;
      }
    });
  }

  //If a layout container, iterate over children and seed recursion.
  if (view instanceof ViewGroup) {
    for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
      View innerView = ((ViewGroup) view).getChildAt(i);
      hideKeyboardListener(innerView, activity);
    }
  }
}
 
Example 8
Project: MyFire   File: ViewHolderHelper.java   Source Code and License Vote up 5 votes
public ViewHolderHelper setOnTouchListener(int viewId,
                                           View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 9
Project: Tasks   File: TaskViewHolder.java   Source Code and License Vote up 5 votes
public TaskViewHolder(View itemView, ItemActions actions,
                      Context context, List<Task> taskList, TaskPref pref) {
  super(itemView);

  taskTitle = itemView.findViewById(R.id.task_title);
  taskDate = itemView.findViewById(R.id.task_time);
  isDone = itemView.findViewById(R.id.task_done);

  itemView.setOnTouchListener(new SwipeTouchListener(context, this));
  this.actions = actions;
  this.context = context;
  this.taskList = taskList;
  this.pref = pref;
}
 
Example 10
Project: XFrame   File: XViewHolder.java   Source Code and License Vote up 5 votes
public XViewHolder setOnTouchListener(@IdRes int viewId,
                                      View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 11
Project: CFAlertDialog   File: ViewUtil.java   Source Code and License Vote up 5 votes
public static void addBounceEffect(View view) {
    view.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return onButtonTouch(v, event);
        }
    });
}
 
Example 12
Project: PeSanKita-android   File: MicrophoneRecorderView.java   Source Code and License Vote up 5 votes
@Override
public void onFinishInflate() {
  super.onFinishInflate();

  ImageView recordButtonFab = ViewUtil.findById(this, R.id.quick_audio_fab);
  this.floatingRecordButton = new FloatingRecordButton(getContext(), recordButtonFab);

  View recordButton = ViewUtil.findById(this, R.id.quick_audio_toggle);
  recordButton.setOnTouchListener(this);
}
 
Example 13
Project: weex-uikit   File: WXComponent.java   Source Code and License Vote up 5 votes
private void setActiveTouchListener(){
  boolean hasActivePesudo = mDomObj.getStyles().getPesudoStyles().containsKey(Constants.PESUDO.ACTIVE);
  View view;
  if(hasActivePesudo && (view = getRealView()) != null) {
    boolean hasTouchConsumer = (mHostClickListeners != null && mHostClickListeners.size() > 0) || wxGesture != null;
    view.setOnTouchListener(new TouchActivePseudoListener(this,!hasTouchConsumer));
  }
}
 
Example 14
Project: CXJPadProject   File: RvHolder.java   Source Code and License Vote up 4 votes
public RvHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 15
Project: RxJava2RetrofitDemo   File: MartianViewHolder.java   Source Code and License Vote up 4 votes
@Override
public MartianViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 16
Project: SmartChart   File: ViewHolder.java   Source Code and License Vote up 4 votes
public ViewHolder setOnTouchListener(int viewId,
                                     View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 17
Project: GitHub   File: BaseViewHolder.java   Source Code and License Vote up 3 votes
/**
 * Sets the on touch listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The on touch listener;
 * @return The BaseViewHolder for chaining.
 */
@Deprecated
public BaseViewHolder setOnTouchListener(@IdRes int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 18
Project: Selector   File: QuickOptionDialog.java   Source Code and License Vote up 3 votes
private QuickOptionDialog(Context context, int theme) {

    super(context, theme);

    View contentView = getLayoutInflater().inflate(R.layout.quick_option_dialog, null);

    mShare = (LinearLayout) contentView.findViewById(R.id.share_friend);
    saveLocal = (LinearLayout) contentView.findViewById(R.id.save_phone);
    collection = (LinearLayout) contentView.findViewById(R.id.collection);


    mOperatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.quick_option_close);

    LinearInterpolator lin = new LinearInterpolator();

    mOperatingAnim.setInterpolator(lin);

    contentView.setOnTouchListener(new View.OnTouchListener() {

      @Override

      public boolean onTouch(View v, MotionEvent event) {

        QuickOptionDialog.this.dismiss();

        return true;

      }

    });

    super.setContentView(contentView);

  }
 
Example 19
Project: ShaddockVideoPlayer   File: BaseViewHolder.java   Source Code and License Vote up 2 votes
/**
 * Sets the on touch listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The on touch listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}
 
Example 20
Project: ThreeExpandItem   File: BaseViewHolder.java   Source Code and License Vote up 2 votes
/**
 * Sets the on touch listener of the view.
 *
 * @param viewId   The view id.
 * @param listener The on touch listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnTouchListener(int viewId, View.OnTouchListener listener) {
    View view = getView(viewId);
    view.setOnTouchListener(listener);
    return this;
}