Search in sources :

Example 1 with Display

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");
        }
    }
}
Also used : Display(android.view.Display) TargetApi(android.annotation.TargetApi)

Example 2 with Display

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);
    }
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) Display(android.view.Display)

Example 3 with Display

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());
}
Also used : MemoryInfo(android.app.ActivityManager.MemoryInfo) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) DisplayMetrics(android.util.DisplayMetrics) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Display(android.view.Display) SuppressLint(android.annotation.SuppressLint)

Example 4 with Display

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;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 5 with Display

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);
}
Also used : WindowManager(android.view.WindowManager) Display(android.view.Display)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22