Merge "Make invalidateOptionsMenu asynchronous" into jb-mr1-dev
This commit is contained in:
@@ -89,6 +89,13 @@ public abstract class Window {
|
||||
* If overlay is enabled, the action mode UI will be allowed to cover existing window content.
|
||||
*/
|
||||
public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
|
||||
|
||||
/**
|
||||
* Max value used as a feature ID
|
||||
* @hide
|
||||
*/
|
||||
public static final int FEATURE_MAX = FEATURE_ACTION_MODE_OVERLAY;
|
||||
|
||||
/** Flag for setting the progress bar's visibility to VISIBLE */
|
||||
public static final int PROGRESS_VISIBILITY_ON = -1;
|
||||
/** Flag for setting the progress bar's visibility to GONE */
|
||||
|
||||
@@ -192,6 +192,20 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
|
||||
private int mUiOptions = 0;
|
||||
|
||||
private boolean mInvalidatePanelMenuPosted;
|
||||
private int mInvalidatePanelMenuFeatures;
|
||||
private final Runnable mInvalidatePanelMenuRunnable = new Runnable() {
|
||||
@Override public void run() {
|
||||
for (int i = 0; i <= FEATURE_MAX; i++) {
|
||||
if ((mInvalidatePanelMenuFeatures & 1 << i) != 0) {
|
||||
doInvalidatePanelMenu(i);
|
||||
}
|
||||
}
|
||||
mInvalidatePanelMenuPosted = false;
|
||||
mInvalidatePanelMenuFeatures = 0;
|
||||
}
|
||||
};
|
||||
|
||||
static class WindowManagerHolder {
|
||||
static final IWindowManager sWindowManager = IWindowManager.Stub.asInterface(
|
||||
ServiceManager.getService("window"));
|
||||
@@ -722,6 +736,15 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
|
||||
@Override
|
||||
public void invalidatePanelMenu(int featureId) {
|
||||
mInvalidatePanelMenuFeatures |= 1 << featureId;
|
||||
|
||||
if (!mInvalidatePanelMenuPosted && mDecor != null) {
|
||||
mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
|
||||
mInvalidatePanelMenuPosted = true;
|
||||
}
|
||||
}
|
||||
|
||||
void doInvalidatePanelMenu(int featureId) {
|
||||
PanelFeatureState st = getPanelState(featureId, true);
|
||||
Bundle savedActionViewStates = null;
|
||||
if (st.menu != null) {
|
||||
@@ -2842,6 +2865,9 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
mDecor.setIsRootNamespace(true);
|
||||
mDecor.setLayoutDirection(
|
||||
getContext().getResources().getConfiguration().getLayoutDirection());
|
||||
if (!mInvalidatePanelMenuPosted && mInvalidatePanelMenuFeatures != 0) {
|
||||
mDecor.postOnAnimation(mInvalidatePanelMenuRunnable);
|
||||
}
|
||||
}
|
||||
if (mContentParent == null) {
|
||||
mContentParent = generateLayout(mDecor);
|
||||
|
||||
Reference in New Issue
Block a user