mirror of
https://github.com/jamessanford/kegs.git
synced 2024-06-26 06:29:33 +00:00
Update ActionBar visibility immediately.
This commit is contained in:
parent
bee5a9ac04
commit
8d8653ab21
|
@ -1,5 +1,6 @@
|
||||||
package com.froop.app.kegs;
|
package com.froop.app.kegs;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -29,6 +30,20 @@ class BitmapSize {
|
||||||
calculateScale(width, height);
|
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) {
|
private boolean isLargeScreen(DisplayMetrics display) {
|
||||||
float a_side = (display.widthPixels / display.xdpi);
|
float a_side = (display.widthPixels / display.xdpi);
|
||||||
float b_side = (display.heightPixels / display.ydpi);
|
float b_side = (display.heightPixels / display.ydpi);
|
||||||
|
|
|
@ -238,14 +238,10 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
||||||
|
|
||||||
private void updateActionBar(boolean showActionBar) {
|
private void updateActionBar(boolean showActionBar) {
|
||||||
final ActionBar actionBar = getSupportActionBar();
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
if (showActionBar) {
|
if (actionBar != null && showActionBar) {
|
||||||
if (actionBar != null && !actionBar.isShowing()) {
|
actionBar.show();
|
||||||
actionBar.show();
|
} else if (actionBar != null && !showActionBar) {
|
||||||
}
|
actionBar.hide();
|
||||||
} else {
|
|
||||||
if (actionBar != null && actionBar.isShowing()) {
|
|
||||||
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,
|
// Fire off a guess at a new size during this request,
|
||||||
// it makes the animation transition look better.
|
// it makes the animation transition look better.
|
||||||
int width = getResources().getDisplayMetrics().widthPixels;
|
final BitmapSize quickSize = BitmapSize.quick(this);
|
||||||
int height = getResources().getDisplayMetrics().heightPixels;
|
updateActionBar(quickSize.showActionBar());
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
mKegsView.updateScreenSize(quickSize);
|
||||||
// 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);
|
|
||||||
getThread().updateScreen();
|
getThread().updateScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +353,8 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
|
updateActionBar(BitmapSize.quick(this).showActionBar());
|
||||||
|
|
||||||
mKegsView = (KegsViewGL)findViewById(R.id.kegsview);
|
mKegsView = (KegsViewGL)findViewById(R.id.kegsview);
|
||||||
|
|
||||||
mConfigFile = new ConfigFile(this);
|
mConfigFile = new ConfigFile(this);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user