private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) { int count = viewGroup.getChildCount(); Rect p = new Rect(); viewGroup.getHitRect(p); for (int i = 0; i < count; i++) { View v = viewGroup.getChildAt(i); if (v instanceof ViewGroup) { // linearlayout setIntentByViewGroup(remoteViews, (ViewGroup) v, list); } else if (v instanceof TextView || v instanceof ImageView) { // textview Rect rect = getRect(v); RectInfo next = findIntent(rect, list); if (next != null) { // VLog.d(TAG, next.rect+":setPendIntent:"+i); // remoteViews.setImageViewBitmap(v.getId(), next.testBg); remoteViews.setOnClickPendingIntent(v.getId(), next.mPendingIntent); } } } }
/** * * @param remoteViews notification's old remoteViews * @param remoteview notification's old remoteViews view * @param oldRemoteView notification's new remoteViews view */ public void setPendIntent(RemoteViews remoteViews, View remoteview, View oldRemoteView) { if (findPendIntents() > 0) { Iterator<Map.Entry<Integer, PendingIntent>> set = clickIntents.entrySet().iterator(); List<RectInfo> list = new ArrayList<>(); int index = 0; VLog.v(TAG, "start find intent"); while (set.hasNext()) { Map.Entry<Integer, PendingIntent> e = set.next(); View view = oldRemoteView.findViewById(e.getKey()); if (view != null) { Rect rect = getRect(view); list.add(new RectInfo(rect, e.getValue(), index)); index++; } } VLog.v(TAG, "find:" + list); if (remoteview instanceof ViewGroup) { setIntentByViewGroup(remoteViews, (ViewGroup) remoteview, list); } } }
public int findPendIntents() { if (clickIntents == null) { clickIntents = getClickIntents(mRemoteViews); } return clickIntents.size(); }
final PendIntentCompat pendIntentCompat = new PendIntentCompat(contentView); final int layoutId; if (!click || pendIntentCompat.findPendIntents() <= 0) { layoutId = R.layout.custom_notification_lite; } else { VLog.v(TAG, "start setPendIntent"); try { pendIntentCompat.setPendIntent(remoteViews, toView(mNotificationCompat.getHostContext(), remoteViews, isBig, systemId), cache);
private RectInfo findIntent(Rect rect, List<RectInfo> list) { int maxArea = 0; RectInfo next = null; for (RectInfo rectInfo : list) { int size = getOverlapArea(rect, rectInfo.rect); if (size > maxArea) { if (size == 0) { Log.w("PendingIntentCompat", "find two:" + rectInfo.rect); } maxArea = size; next = rectInfo; } } return next; }
private Rect getRect(View view) { Rect rect = new Rect(); rect.top = view.getTop(); rect.left = view.getLeft(); rect.right = view.getRight(); rect.bottom = view.getBottom(); ViewParent viewParent = view.getParent(); if (viewParent != null) { if (viewParent instanceof ViewGroup) { Rect prect = getRect((ViewGroup) viewParent); rect.top += prect.top; rect.left += prect.left; rect.right += prect.left; rect.bottom += prect.top; } } return rect; }
final PendIntentCompat pendIntentCompat = new PendIntentCompat(contentView); final int layoutId; if (!click || pendIntentCompat.findPendIntents() <= 0) { layoutId = R.layout.custom_notification_lite; } else { VLog.v(TAG, "start setPendIntent"); try { pendIntentCompat.setPendIntent(remoteViews, toView(mNotificationCompat.getHostContext(), remoteViews, isBig, systemId), cache);
private RectInfo findIntent(Rect rect, List<RectInfo> list) { int maxArea = 0; RectInfo next = null; for (RectInfo rectInfo : list) { int size = getOverlapArea(rect, rectInfo.rect); if (size > maxArea) { if (size == 0) { Log.w("PendingIntentCompat", "find two:" + rectInfo.rect); } maxArea = size; next = rectInfo; } } return next; }
private Rect getRect(View view) { Rect rect = new Rect(); rect.top = view.getTop(); rect.left = view.getLeft(); rect.right = view.getRight(); rect.bottom = view.getBottom(); ViewParent viewParent = view.getParent(); if (viewParent != null) { if (viewParent instanceof ViewGroup) { Rect prect = getRect((ViewGroup) viewParent); rect.top += prect.top; rect.left += prect.left; rect.right += prect.left; rect.bottom += prect.top; } } return rect; }
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) { int count = viewGroup.getChildCount(); Rect p = new Rect(); viewGroup.getHitRect(p); for (int i = 0; i < count; i++) { View v = viewGroup.getChildAt(i); if (v instanceof ViewGroup) { // linearlayout setIntentByViewGroup(remoteViews, (ViewGroup) v, list); } else if (v instanceof TextView || v instanceof ImageView) { // textview Rect rect = getRect(v); RectInfo next = findIntent(rect, list); if (next != null) { // VLog.d(TAG, next.rect+":setPendIntent:"+i); // remoteViews.setImageViewBitmap(v.getId(), next.testBg); remoteViews.setOnClickPendingIntent(v.getId(), next.mPendingIntent); } } } }
/** * * @param remoteViews notification's old remoteViews * @param remoteview notification's old remoteViews view * @param oldRemoteView notification's new remoteViews view */ public void setPendIntent(RemoteViews remoteViews, View remoteview, View oldRemoteView) { if (findPendIntents() > 0) { Iterator<Map.Entry<Integer, PendingIntent>> set = clickIntents.entrySet().iterator(); List<RectInfo> list = new ArrayList<>(); int index = 0; VLog.v(TAG, "start find intent"); while (set.hasNext()) { Map.Entry<Integer, PendingIntent> e = set.next(); View view = oldRemoteView.findViewById(e.getKey()); if (view != null) { Rect rect = getRect(view); list.add(new RectInfo(rect, e.getValue(), index)); index++; } } VLog.v(TAG, "find:" + list); if (remoteview instanceof ViewGroup) { setIntentByViewGroup(remoteViews, (ViewGroup) remoteview, list); } } }
final PendIntentCompat pendIntentCompat = new PendIntentCompat(contentView); final int layoutId; if (!click || pendIntentCompat.findPendIntents() <= 0) { layoutId = R.layout.custom_notification_lite; } else { VLog.v(TAG, "start setPendIntent"); try { pendIntentCompat.setPendIntent(remoteViews, toView(mNotificationCompat.getHostContext(), remoteViews, isBig, systemId), cache);
public int findPendIntents() { if (clickIntents == null) { clickIntents = getClickIntents(mRemoteViews); } return clickIntents.size(); }
private RectInfo findIntent(Rect rect, List<RectInfo> list) { int maxArea = 0; RectInfo next = null; for (RectInfo rectInfo : list) { int size = getOverlapArea(rect, rectInfo.rect); if (size > maxArea) { if (size == 0) { Log.w("PendingIntentCompat", "find two:" + rectInfo.rect); } maxArea = size; next = rectInfo; } } return next; }
private Rect getRect(View view) { Rect rect = new Rect(); rect.top = view.getTop(); rect.left = view.getLeft(); rect.right = view.getRight(); rect.bottom = view.getBottom(); ViewParent viewParent = view.getParent(); if (viewParent != null) { if (viewParent instanceof ViewGroup) { Rect prect = getRect((ViewGroup) viewParent); rect.top += prect.top; rect.left += prect.left; rect.right += prect.left; rect.bottom += prect.top; } } return rect; }
private void setIntentByViewGroup(RemoteViews remoteViews, ViewGroup viewGroup, List<RectInfo> list) { int count = viewGroup.getChildCount(); Rect p = new Rect(); viewGroup.getHitRect(p); for (int i = 0; i < count; i++) { View v = viewGroup.getChildAt(i); if (v instanceof ViewGroup) { // linearlayout setIntentByViewGroup(remoteViews, (ViewGroup) v, list); } else if (v instanceof TextView || v instanceof ImageView) { // textview Rect rect = getRect(v); RectInfo next = findIntent(rect, list); if (next != null) { // VLog.d(TAG, next.rect+":setPendIntent:"+i); // remoteViews.setImageViewBitmap(v.getId(), next.testBg); remoteViews.setOnClickPendingIntent(v.getId(), next.mPendingIntent); } } } }
/** * * @param remoteViews notification's old remoteViews * @param remoteview notification's old remoteViews view * @param oldRemoteView notification's new remoteViews view */ public void setPendIntent(RemoteViews remoteViews, View remoteview, View oldRemoteView) { if (findPendIntents() > 0) { Iterator<Map.Entry<Integer, PendingIntent>> set = clickIntents.entrySet().iterator(); List<RectInfo> list = new ArrayList<>(); int index = 0; VLog.v(TAG, "start find intent"); while (set.hasNext()) { Map.Entry<Integer, PendingIntent> e = set.next(); View view = oldRemoteView.findViewById(e.getKey()); if (view != null) { Rect rect = getRect(view); list.add(new RectInfo(rect, e.getValue(), index)); index++; } } VLog.v(TAG, "find:" + list); if (remoteview instanceof ViewGroup) { setIntentByViewGroup(remoteViews, (ViewGroup) remoteview, list); } } }
public int findPendIntents() { if (clickIntents == null) { clickIntents = getClickIntents(mRemoteViews); } return clickIntents.size(); }