Android TouchDelegate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TouchDelegate class.

This code example shows how to use the following methods:
            setTouchDelegate(mTouchDelegateGroup);
        } 
    } 
 
    private void addTouchDelegate(Rect rect, int color, View delegateView) {
        mTouchDelegateGroup.addTouchDelegate(new TouchDelegate(rect, delegateView));
        mTouchDelegateRecords.add(new TouchDelegateRecord(rect, color));
    } 
 
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        for (TouchDelegateRecord record : mTouchDelegateRecords) {
            mPaint.setColor(record.color);
            canvas.drawRect(record.rect, mPaint);
        } 
        super.dispatchDraw(canvas);
    } 
 
    /** 
     * Register a listener to be notified of changes on this item view. 
6
CodeRank
This code example shows how to use the following methods:setTouchDelegate
				delegate.getHitRect(delegateArea);
				delegateArea.top -= 600;
				delegateArea.bottom += 600;
				delegateArea.left -= 600;
				delegateArea.right += 600;
				TouchDelegate expandedArea = new TouchDelegate(delegateArea,
						delegate);
				// give the delegate to an ancestor of the view we're 
				// delegating the 
				// area to 
				if (View.class.isInstance(delegate.getParent())) {
					((View) delegate.getParent())
							.setTouchDelegate(expandedArea);
				} 
			}; 
		}); 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:setTouchDelegate
				delegate.getHitRect(delegateArea);
				delegateArea.top -= 600;
				delegateArea.bottom += 600;
				delegateArea.left -= 600;
				delegateArea.right += 600;
				TouchDelegate expandedArea = new TouchDelegate(delegateArea,
						delegate);
				// give the delegate to an ancestor of the view we're 
				// delegating the 
				// area to 
				if (View.class.isInstance(delegate.getParent())) {
					((View) delegate.getParent())
							.setTouchDelegate(expandedArea);
				} 
			}; 
		}); 
	} 
 
	public void onClick(View view) {
		Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show();
6
CodeRank
This code example shows how to use the following methods:
	@Override 
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		//Apply the whole area of this view as the delegate area 
		Rect bounds = new Rect(0, 0, getMeasuredWidth(), getMeasuredHeight());
		TouchDelegate delegate = new TouchDelegate(bounds, mButton);
		setTouchDelegate(delegate);
	} 
} 
5
CodeRank
This code example shows how to use the following methods:onTouchEvent
			cancelAllTouchTargets(event);
 
			boolean consumed = false;
 
			if (checkBoxDelegate != null) {
				consumed = checkBoxDelegate.onTouchEvent(event);
				// l("cb touch delegate", event, consumed); 
				if (consumed) {
					inTouchCheckBoxDelegate = true;
					return true; 
				} 
			} 
 
			consumed = gestureDetector.onTouchEvent(event);
			// l("gesture detector", event, consumed); 
			if (consumed) {
				inGestureDetector = true;
				return true; 
			} 
 

5
CodeRank
This code example shows how to use the following methods:
                touchRect.bottom+=Math.max(0, bottomPadding);
                touchRect.left-=Math.max(0, leftPadding);
                touchRect.right+=Math.max(0, rightPadding);
                 
                //Now we are going to construct the TouchDelegate 
                TouchDelegate touchDelegate = new TouchDelegate(touchRect, delegate);
                 
                //And set it on the parent 
                parent.setTouchDelegate(touchDelegate);
                 
            } 
        }; 
    } 
	 
	public static int getSourceFontsize(Context context) {
		try { 
			int fontSize = Integer.parseInt(PreferenceManager
					.getDefaultSharedPreferences(context).getString(
							"sourceFontSize", "15")); 
 
3
CodeRank
This code example shows how to use the following methods:
                final Rect r = new Rect();
                r.top = 0;
                r.bottom = maphoneLockscreenBottombar.getHeight();
                r.left = 0;
                r.right = mButtonImageView.getRight();
                maphoneLockscreenBottombar.setTouchDelegate(new TouchDelegate(r, mButtonImageView));
            } 
        }); 
 
        // mChargerImageView.setImageBitmap(drawReflection(R.drawable.batterybg_11)); 
        // mChargerImageView.setBackgroundDrawable(); 
        mStatusBarHeight = 38;
        mHandler = new ShineHandler();
        startShine(); 
 
    } 
 
    @Override 
    protected void onPause() { 
        stopShine(); 
3
CodeRank
This code example shows how to use the following methods:
				// try to make a square hit target but do not exceed a quarter 
				// of the row width 
				rect.right = Math.min(row.getHeight(), row.getWidth() / 4);
				rect.bottom = row.getHeight();
				rect.left = 0;
				row.setTouchDelegate(new TouchDelegate(rect, checkBox));
			} 
		}); 
	} 
 
	private String formatValue(int value) {
		double[] thresholds = new double[] { 1000000, 1000, 1 };
		// TODO: string resources for these? 
		String[] units = new String[] { "m", "k", "₫" };
 
		double scaled_value = 0;
		String scaled_unit = null;
 
		for (int i = 0; i < units.length; i++) {
			if (value >= thresholds[i]) {
4
CodeRank
This code example shows how to use the following methods:
    	Rect bounds = new Rect();
    	bounds.left = 0;
        bounds.right = this.getMeasuredWidth();
        bounds.top = 0;
        bounds.bottom = this.getMeasuredHeight();
        TouchDelegate touchDelegate = new TouchDelegate(bounds, mConfigImage);
        ConfigurationIconView.this.setTouchDelegate(touchDelegate);
    } 
     
    public ImageView getSwitchingGifView() {
    	if (mSwitchIngGifView == null) {
    		initSwitchingGifView(); 
    	} 
    	return mSwitchIngGifView;
    } 
} 
4
CodeRank
This code example shows how to use the following methods:

Related Android TouchDelegate Questions & Answers:

See Code Examples for Android TouchDelegate Methods: