| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.internal.widget; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.content.Context; |
| 21 |
import android.util.AttributeSet; |
| 22 |
import android.view.View; |
| 23 |
import android.widget.FrameLayout; |
| 24 |
import android.widget.RemoteViews; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
@RemoteViews.RemoteView |
| 31 |
public class NotificationVanishingFrameLayout extends FrameLayout { |
| 32 |
public NotificationVanishingFrameLayout(Context context) { |
| 33 |
this(context, null, 0, 0); |
| 34 |
} |
| 35 |
|
| 36 |
public NotificationVanishingFrameLayout(Context context, @Nullable AttributeSet attrs) { |
| 37 |
this(context, attrs, 0, 0); |
| 38 |
} |
| 39 |
|
| 40 |
public NotificationVanishingFrameLayout(Context context, @Nullable AttributeSet attrs, |
| 41 |
int defStyleAttr) { |
| 42 |
this(context, attrs, defStyleAttr, 0); |
| 43 |
} |
| 44 |
|
| 45 |
public NotificationVanishingFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, |
| 46 |
int defStyleRes) { |
| 47 |
super(context, attrs, defStyleAttr, defStyleRes); |
| 48 |
} |
| 49 |
|
| 50 |
@Override |
| 51 |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 52 |
if (allChildrenGone()) { |
| 53 |
int zeroSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.EXACTLY); |
| 54 |
super.onMeasure(zeroSpec, zeroSpec); |
| 55 |
} else { |
| 56 |
super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
private boolean allChildrenGone() { |
| 61 |
final int childCount = getChildCount(); |
| 62 |
for (int i = 0; i < childCount; i++) { |
| 63 |
final View child = getChildAt(i); |
| 64 |
if (child != null && child.getVisibility() != GONE) { |
| 65 |
return false; |
| 66 |
} |
| 67 |
} |
| 68 |
return true; |
| 69 |
} |
| 70 |
} |