mirror of
https://github.com/jamessanford/kegs.git
synced 2024-09-30 12:56:27 +00:00
Add some safety checks around action bar update.
This commit is contained in:
parent
ee2814b689
commit
f557787e81
@ -27,9 +27,8 @@ class BitmapSize {
|
||||
if (mScaleFactorY != 1.0f && mScaleFactorX != mScaleFactorY) {
|
||||
return false;
|
||||
} else if (mHeight < getViewHeight()) {
|
||||
// TODO: FIXME: This could possibly cause the action bar to turn on and off repeatedly, so be careful about when saying it's safe to turn on or off.
|
||||
// One way would be if we have turned it off for a certain height,
|
||||
// and a new height is within 20% of that height, keep it off.
|
||||
// However, beware that disabling the action bar may increase
|
||||
// the space enough to think that we should reenable it.
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -38,6 +38,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset {
|
||||
|
||||
private PopupMenu mSettingsMenu;
|
||||
private boolean mModeMouse = true;
|
||||
private int mLastActionBar = 0; // window height at last ActionBar change.
|
||||
|
||||
private View.OnClickListener mButtonClick = new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@ -194,6 +195,19 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateActionBar(boolean showActionBar) {
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (showActionBar) {
|
||||
if (actionBar != null && !actionBar.isShowing()) {
|
||||
actionBar.show();
|
||||
}
|
||||
} else {
|
||||
if (actionBar != null && actionBar.isShowing()) {
|
||||
actionBar.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScreenSize(boolean quick) {
|
||||
int width;
|
||||
int height;
|
||||
@ -216,15 +230,11 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset {
|
||||
|
||||
mKegsView.updateScreenSize(bitmapSize);
|
||||
|
||||
final ActionBar actionBar = getActionBar();
|
||||
if (bitmapSize.showActionBar()) {
|
||||
if (actionBar != null && !actionBar.isShowing()) {
|
||||
actionBar.show();
|
||||
}
|
||||
} else {
|
||||
if (actionBar != null && actionBar.isShowing()) {
|
||||
actionBar.hide();
|
||||
}
|
||||
// Only change action bar if the window height is significantly
|
||||
// different from the last time we changed the action bar.
|
||||
if (height < (mLastActionBar * 0.85) || height > (mLastActionBar * 1.15)) {
|
||||
mLastActionBar = height;
|
||||
updateActionBar(bitmapSize.showActionBar());
|
||||
}
|
||||
|
||||
// Force another redraw of the bitmap into the canvas. Bug workaround.
|
||||
|
Loading…
Reference in New Issue
Block a user