mirror of
https://github.com/jamessanford/kegs.git
synced 2024-06-17 03:29:26 +00:00
Update ActionBar visibility immediately.
This commit is contained in:
parent
bee5a9ac04
commit
8d8653ab21
|
@ -1,5 +1,6 @@
|
|||
package com.froop.app.kegs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
@ -29,6 +30,20 @@ class BitmapSize {
|
|||
calculateScale(width, height);
|
||||
}
|
||||
|
||||
|
||||
// Next method provides a rough estimate based on the total display size.
|
||||
public static BitmapSize quick(Context context) {
|
||||
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
int width = metrics.widthPixels;
|
||||
int height = metrics.heightPixels;
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
// NOTE: 48 is a guess at the System Bar obstruction.
|
||||
// These are 'visible insets' into the display from the window manager.
|
||||
height -= 48;
|
||||
}
|
||||
return new BitmapSize(width, height, metrics);
|
||||
}
|
||||
|
||||
private boolean isLargeScreen(DisplayMetrics display) {
|
||||
float a_side = (display.widthPixels / display.xdpi);
|
||||
float b_side = (display.heightPixels / display.ydpi);
|
||||
|
|
|
@ -238,14 +238,10 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
|||
|
||||
private void updateActionBar(boolean showActionBar) {
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (showActionBar) {
|
||||
if (actionBar != null && !actionBar.isShowing()) {
|
||||
actionBar.show();
|
||||
}
|
||||
} else {
|
||||
if (actionBar != null && actionBar.isShowing()) {
|
||||
actionBar.hide();
|
||||
}
|
||||
if (actionBar != null && showActionBar) {
|
||||
actionBar.show();
|
||||
} else if (actionBar != null && !showActionBar) {
|
||||
actionBar.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,16 +275,9 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
|||
|
||||
// Fire off a guess at a new size during this request,
|
||||
// it makes the animation transition look better.
|
||||
int width = getResources().getDisplayMetrics().widthPixels;
|
||||
int height = getResources().getDisplayMetrics().heightPixels;
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
// NOTE: 48 is a guess at the System Bar obstruction.
|
||||
// These are 'visible insets' into the display from the window manager.
|
||||
height -= 48;
|
||||
}
|
||||
final BitmapSize bitmapSize = new BitmapSize(width, height, getResources().getDisplayMetrics());
|
||||
updateActionBar(bitmapSize.showActionBar());
|
||||
mKegsView.updateScreenSize(bitmapSize);
|
||||
final BitmapSize quickSize = BitmapSize.quick(this);
|
||||
updateActionBar(quickSize.showActionBar());
|
||||
mKegsView.updateScreenSize(quickSize);
|
||||
getThread().updateScreen();
|
||||
}
|
||||
|
||||
|
@ -364,6 +353,8 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
updateActionBar(BitmapSize.quick(this).showActionBar());
|
||||
|
||||
mKegsView = (KegsViewGL)findViewById(R.id.kegsview);
|
||||
|
||||
mConfigFile = new ConfigFile(this);
|
||||
|
|
Loading…
Reference in New Issue
Block a user