use of android.view.Display in project cw-omnibus by commonsguy.
the class MainActivity method handleRoute.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void handleRoute(RouteInfo route) {
if (route == null) {
clearPreso();
} else {
Display display = route.getPresentationDisplay();
if (route.isEnabled() && display != null) {
if (preso == null) {
showPreso(route);
Log.d(getClass().getSimpleName(), "enabled route");
} else if (preso.getDisplay().getDisplayId() != display.getDisplayId()) {
clearPreso();
showPreso(route);
Log.d(getClass().getSimpleName(), "switched route");
} else {
// no-op: should already be set
}
} else {
clearPreso();
Log.d(getClass().getSimpleName(), "disabled route");
}
}
}
use of android.view.Display in project UltimateAndroid by cymcsg.
the class QuickContactFragment method onStart.
@SuppressWarnings("deprecation")
@Override
public void onStart() {
super.onStart();
// change dialog width
if (getDialog() != null) {
int fullWidth = getDialog().getWindow().getAttributes().width;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Display display = getActivity().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
fullWidth = size.x;
} else {
Display display = getActivity().getWindowManager().getDefaultDisplay();
fullWidth = display.getWidth();
}
final int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics());
int w = fullWidth - padding;
int h = getDialog().getWindow().getAttributes().height;
getDialog().getWindow().setLayout(w, h);
}
}
use of android.view.Display in project packer-ng-plugin by mcxiaoke.
the class MainActivity method addDeviceInfoSection.
@SuppressLint("NewApi")
private void addDeviceInfoSection() {
StringBuilder builder = new StringBuilder();
builder.append("[Device]\n");
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
final MemoryInfo memoryInfo = new MemoryInfo();
am.getMemoryInfo(memoryInfo);
if (AndroidUtils.hasJellyBean()) {
builder.append("Mem Total: ").append(StringUtils.getHumanReadableByteCount(memoryInfo.totalMem)).append("\n");
}
builder.append("Mem Free: ").append(StringUtils.getHumanReadableByteCount(memoryInfo.availMem)).append("\n");
builder.append("Mem Heap: ").append(am.getMemoryClass()).append("M\n");
builder.append("Mem Low: ").append(memoryInfo.lowMemory).append("\n");
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
//DisplayMetrics dm = getResources().getDisplayMetrics();
display.getMetrics(dm);
int statusBarHeightDp = ViewUtils.getStatusBarHeightInDp(this);
int systemBarHeightDp = ViewUtils.getSystemBarHeightInDp(this);
int statusBarHeight = ViewUtils.getStatusBarHeight(this);
int systemBarHeight = ViewUtils.getSystemBarHeight(this);
Point point = getScreenRawSize(display);
builder.append("statusBarHeightDp: ").append(statusBarHeightDp).append("\n");
builder.append("systemBarHeightDp: ").append(systemBarHeightDp).append("\n");
builder.append("statusBarHeightPx: ").append(statusBarHeight).append("\n");
builder.append("systemBarHeightPx: ").append(systemBarHeight).append("\n");
builder.append("screenWidth: ").append(point.x).append("\n");
builder.append("screenHeight: ").append(point.y).append("\n");
builder.append("WindowWidth: ").append(dm.widthPixels).append("\n");
builder.append("WindowHeight: ").append(dm.heightPixels).append("\n");
builder.append(toString2(dm));
builder.append("\n");
addSection(builder.toString());
}
use of android.view.Display in project nmid-headline by miao1007.
the class ScreenUtils method getScreenWidth.
public static int getScreenWidth(Context c) {
if (screenWidth == 0) {
WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
screenWidth = size.x;
}
return screenWidth;
}
use of android.view.Display in project Signal-Android by WhisperSystems.
the class ConversationPopupActivity method onCreate.
@Override
protected void onCreate(Bundle bundle, @NonNull MasterSecret masterSecret) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.alpha = 1.0f;
params.dimAmount = 0.1f;
params.gravity = Gravity.TOP;
getWindow().setAttributes(params);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
if (height > width)
getWindow().setLayout((int) (width * .85), (int) (height * .5));
else
getWindow().setLayout((int) (width * .7), (int) (height * .75));
super.onCreate(bundle, masterSecret);
titleView.setOnClickListener(null);
}
Aggregations