本文整理匯總了Java中android.graphics.Region.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java Region.contains方法的具體用法?Java Region.contains怎麽用?Java Region.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.Region
的用法示例。
在下文中一共展示了Region.contains方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isTouch
import android.graphics.Region; //導入方法依賴的package包/類
/**
* 是否點擊的省份
* 點擊時間
* @param x
* @param y
*/
public boolean isTouch(int x,int y){
RectF rectF = new RectF();
path.computeBounds(rectF,true);
Region region = new Region();
region.setPath(path,new Region((int)rectF.left,(int)rectF.top,(int)rectF.right,(int)rectF.bottom));
return region.contains(x,y);
}
示例2: onTouchEvent
import android.graphics.Region; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(final MotionEvent event) {
if (mDrawCompleted) {
Point point = new Point();
point.x = (int) event.getX();
point.y = (int) event.getY();
int count = 0;
Region r = new Region();
for (PieSlice slice : mSlices) {
r.setPath(slice.getPath(), slice.getRegion());
switch (event.getAction()) {
default:
break;
case MotionEvent.ACTION_DOWN:
if (r.contains(point.x, point.y)) {
mSelectedIndex = count;
postInvalidate();
}
break;
case MotionEvent.ACTION_UP:
if (count == mSelectedIndex
&& mListener != null
&& r.contains(point.x, point.y)) {
mListener.onSliceClick(mSelectedIndex);
}
break;
}
count++;
}
}
// Case we click somewhere else, also get feedback!
if(MotionEvent.ACTION_UP == event.getAction()
&& mSelectedIndex == -1
&& mListener != null) {
mListener.onSliceClick(mSelectedIndex);
}
// Reset selection
if (MotionEvent.ACTION_UP == event.getAction()
|| MotionEvent.ACTION_CANCEL == event.getAction()) {
mSelectedIndex = -1;
postInvalidate();
}
return true;
}