Search in sources :

Example 86 with DisplayMetrics

use of android.util.DisplayMetrics in project SimplifyReader by chentao0707.

the class BaseLazyFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.inject(this, view);
    if (null != getLoadingTargetView()) {
        mVaryViewHelperController = new VaryViewHelperController(getLoadingTargetView());
    }
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    mScreenDensity = displayMetrics.density;
    mScreenHeight = displayMetrics.heightPixels;
    mScreenWidth = displayMetrics.widthPixels;
    initViewsAndEvents();
}
Also used : VaryViewHelperController(com.github.obsessive.library.loading.VaryViewHelperController) DisplayMetrics(android.util.DisplayMetrics)

Example 87 with DisplayMetrics

use of android.util.DisplayMetrics in project SimplifyReader by chentao0707.

the class BaseAppCompatActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (toggleOverridePendingTransition()) {
        switch(getOverridePendingTransitionMode()) {
            case LEFT:
                overridePendingTransition(R.anim.left_in, R.anim.left_out);
                break;
            case RIGHT:
                overridePendingTransition(R.anim.right_in, R.anim.right_out);
                break;
            case TOP:
                overridePendingTransition(R.anim.top_in, R.anim.top_out);
                break;
            case BOTTOM:
                overridePendingTransition(R.anim.bottom_in, R.anim.bottom_out);
                break;
            case SCALE:
                overridePendingTransition(R.anim.scale_in, R.anim.scale_out);
                break;
            case FADE:
                overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
                break;
        }
    }
    super.onCreate(savedInstanceState);
    // base setup
    Bundle extras = getIntent().getExtras();
    if (null != extras) {
        getBundleExtras(extras);
    }
    if (isBindEventBusHere()) {
        EventBus.getDefault().register(this);
    }
    SmartBarUtils.hide(getWindow().getDecorView());
    setTranslucentStatus(isApplyStatusBarTranslucency());
    mContext = this;
    TAG_LOG = this.getClass().getSimpleName();
    BaseAppManager.getInstance().addActivity(this);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    mScreenDensity = displayMetrics.density;
    mScreenHeight = displayMetrics.heightPixels;
    mScreenWidth = displayMetrics.widthPixels;
    if (getContentViewLayoutID() != 0) {
        setContentView(getContentViewLayoutID());
    } else {
        throw new IllegalArgumentException("You must return a right contentView layout resource Id");
    }
    mNetChangeObserver = new NetChangeObserver() {

        @Override
        public void onNetConnected(NetUtils.NetType type) {
            super.onNetConnected(type);
            onNetworkConnected(type);
        }

        @Override
        public void onNetDisConnect() {
            super.onNetDisConnect();
            onNetworkDisConnected();
        }
    };
    NetStateReceiver.registerObserver(mNetChangeObserver);
    initViewsAndEvents();
}
Also used : NetChangeObserver(com.github.obsessive.library.netstatus.NetChangeObserver) NetUtils(com.github.obsessive.library.netstatus.NetUtils) Bundle(android.os.Bundle) DisplayMetrics(android.util.DisplayMetrics)

Example 88 with DisplayMetrics

use of android.util.DisplayMetrics in project UltimateAndroid by cymcsg.

the class MaterialProgressWheel method parseAttributes.

/**
     * Parse the attributes passed to the view from the XML
     *
     * @param a the attributes to parse
     */
private void parseAttributes(TypedArray a) {
    DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
    barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
    rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
    circleRadius = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwCircleRadius, circleRadius);
    fillRadius = a.getBoolean(R.styleable.MaterialProgressWheel_mpwFillRadius, false);
    barWidth = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwBarWidth, barWidth);
    rimWidth = (int) a.getDimension(R.styleable.MaterialProgressWheel_mpwRimWidth, rimWidth);
    float baseSpinSpeed = a.getFloat(R.styleable.MaterialProgressWheel_mpwSpinSpeed, spinSpeed / 360.0f);
    spinSpeed = baseSpinSpeed * 360;
    barSpinCycleTime = a.getInt(R.styleable.MaterialProgressWheel_mpwBarSpinCycleTime, (int) barSpinCycleTime);
    barColor = a.getColor(R.styleable.MaterialProgressWheel_mpwBarColor, barColor);
    rimColor = a.getColor(R.styleable.MaterialProgressWheel_mpwRimColor, rimColor);
    if (a.getBoolean(R.styleable.MaterialProgressWheel_mpwProgressIndeterminate, false)) {
        spin();
    }
    // Recycle
    a.recycle();
}
Also used : DisplayMetrics(android.util.DisplayMetrics)

Example 89 with DisplayMetrics

use of android.util.DisplayMetrics in project AndroidAutoLayout by hongyangAndroid.

the class ScreenUtils method getScreenSize.

public static int[] getScreenSize(Context context, boolean useDeviceSize) {
    int[] size = new int[2];
    WindowManager w = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display d = w.getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    d.getMetrics(metrics);
    // since SDK_INT = 1;
    int widthPixels = metrics.widthPixels;
    int heightPixels = metrics.heightPixels;
    if (!useDeviceSize) {
        size[0] = widthPixels;
        size[1] = heightPixels - getStatusBarHeight(context);
        return size;
    }
    // includes window decorations (statusbar bar/menu bar)
    if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 17)
        try {
            widthPixels = (Integer) Display.class.getMethod("getRawWidth").invoke(d);
            heightPixels = (Integer) Display.class.getMethod("getRawHeight").invoke(d);
        } catch (Exception ignored) {
        }
    // includes window decorations (statusbar bar/menu bar)
    if (Build.VERSION.SDK_INT >= 17)
        try {
            Point realSize = new Point();
            Display.class.getMethod("getRealSize", Point.class).invoke(d, realSize);
            widthPixels = realSize.x;
            heightPixels = realSize.y;
        } catch (Exception ignored) {
        }
    size[0] = widthPixels;
    size[1] = heightPixels;
    return size;
}
Also used : Point(android.graphics.Point) DisplayMetrics(android.util.DisplayMetrics) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 90 with DisplayMetrics

use of android.util.DisplayMetrics in project android-percent-support-extend by hongyangAndroid.

the class PercentLayoutHelper method getScreenSize.

private void getScreenSize() {
    WindowManager wm = (WindowManager) mHost.getContext().getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    mWidthScreen = outMetrics.widthPixels;
    mHeightScreen = outMetrics.heightPixels;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager)

Aggregations

DisplayMetrics (android.util.DisplayMetrics)772 WindowManager (android.view.WindowManager)107 Resources (android.content.res.Resources)99 Display (android.view.Display)78 Configuration (android.content.res.Configuration)61 Point (android.graphics.Point)57 View (android.view.View)52 SuppressLint (android.annotation.SuppressLint)47 Bitmap (android.graphics.Bitmap)42 Paint (android.graphics.Paint)42 Activity (android.app.Activity)32 ImageView (android.widget.ImageView)27 AssetManager (android.content.res.AssetManager)25 TypedArray (android.content.res.TypedArray)25 Context (android.content.Context)23 TypedValue (android.util.TypedValue)23 ViewGroup (android.view.ViewGroup)23 TextView (android.widget.TextView)22 Intent (android.content.Intent)21 RelativeLayout (android.widget.RelativeLayout)20