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();
}
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();
}
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();
}
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;
}
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;
}
Aggregations