本文整理汇总了Java中android.support.wearable.complications.rendering.ComplicationDrawable.getBounds方法的典型用法代码示例。如果您正苦于以下问题:Java ComplicationDrawable.getBounds方法的具体用法?Java ComplicationDrawable.getBounds怎么用?Java ComplicationDrawable.getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.wearable.complications.rendering.ComplicationDrawable
的用法示例。
在下文中一共展示了ComplicationDrawable.getBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTappedComplicationId
import android.support.wearable.complications.rendering.ComplicationDrawable; //导入方法依赖的package包/类
/**
* Determines if a tap was inside a complication area
*
* @param x coordinate of tap
* @param y coordinate of tap
* @return the id of the complication that was tapped; if no complication was tapped,
* return -1
*/
private int getTappedComplicationId(int x, int y) {
long currentTimeMillis = System.currentTimeMillis();
for (int COMPLICATION_ID : COMPLICATION_IDS) {
final ComplicationData complicationData
= mActiveComplicationDataSparseArray.get(COMPLICATION_ID);
if ((complicationData != null)
&& (complicationData.isActive(currentTimeMillis))
&& (complicationData.getType() != ComplicationData.TYPE_NOT_CONFIGURED)
&& (complicationData.getType() != ComplicationData.TYPE_EMPTY)) {
final ComplicationDrawable complicationDrawable
= mComplicationDrawableSparseArray.get(COMPLICATION_ID);
final Rect complicationBoundingRect = complicationDrawable.getBounds();
if (complicationBoundingRect.width() > 0) {
if (complicationBoundingRect.contains(x, y)) {
return COMPLICATION_ID;
}
} else {
Log.e(TAG, "Not a recognized complication id.");
}
}
}
return -1;
}
示例2: getTappedComplicationId
import android.support.wearable.complications.rendering.ComplicationDrawable; //导入方法依赖的package包/类
private int getTappedComplicationId(int x, int y) {
int complicationId;
ComplicationData complicationData;
ComplicationDrawable complicationDrawable;
long currentTimeMillis = System.currentTimeMillis();
for (int i = 0; i < COMPLICATION_IDS.length; i++) {
complicationId = COMPLICATION_IDS[i];
complicationData = mActiveComplicationDataSparseArray.get(complicationId);
if ((complicationData != null)
&& (complicationData.isActive(currentTimeMillis))
&& (complicationData.getType() != ComplicationData.TYPE_NOT_CONFIGURED)
&& (complicationData.getType() != ComplicationData.TYPE_EMPTY)) {
complicationDrawable = mComplicationDrawableSparseArray.get(complicationId);
Rect complicationBoundingRect = complicationDrawable.getBounds();
if (complicationBoundingRect.width() > 0) {
if (complicationBoundingRect.contains(x, y)) {
return complicationId;
}
} else {
Log.e(TAG, "Not a recognized complication id.");
}
}
}
return -1;
}