use of android.view.WindowManager in project materialistic by hidroh.
the class AppUtils method getDisplayHeight.
public static int getDisplayHeight(Context context) {
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
Point point = new Point();
display.getSize(point);
return point.y;
} else {
//noinspection deprecation
return display.getHeight();
}
}
use of android.view.WindowManager in project ScrollableTabHost-for-Android by honcheng.
the class ScrollableTabActivity method commit.
public void commit() {
bottomRadioGroup.removeAllViews();
int optimum_visible_items_in_portrait_mode = 5;
try {
WindowManager window = getWindowManager();
Display display = window.getDefaultDisplay();
int window_width = display.getWidth();
optimum_visible_items_in_portrait_mode = (int) (window_width / 64.0);
} catch (Exception e) {
optimum_visible_items_in_portrait_mode = 5;
}
int screen_width = getWindowManager().getDefaultDisplay().getWidth();
int width;
if (intentList.size() <= optimum_visible_items_in_portrait_mode) {
width = screen_width / intentList.size();
} else {
//width = screen_width/5;
width = 320 / 5;
}
RadioStateDrawable.width = width;
RadioStateDrawable.screen_width = screen_width;
buttonLayoutParams = new RadioGroup.LayoutParams(width, RadioGroup.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < intentList.size(); i++) {
TabBarButton tabButton = new TabBarButton(this);
int[] iconStates = (int[]) states.get(i);
if (iconStates.length == 1)
tabButton.setState(titleList.get(i).toString(), iconStates[0]);
else if (iconStates.length == 2)
tabButton.setState(titleList.get(i).toString(), iconStates[0], iconStates[1]);
else if (iconStates.length == 3)
tabButton.setState(titleList.get(i).toString(), iconStates[0], iconStates[1], iconStates[2]);
tabButton.setId(i);
tabButton.setGravity(Gravity.CENTER);
bottomRadioGroup.addView(tabButton, i, buttonLayoutParams);
}
setCurrentTab(0);
}
use of android.view.WindowManager 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.view.WindowManager 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;
}
use of android.view.WindowManager in project AndroidTraining by mixi-inc.
the class DefaultModule method configure.
@SuppressWarnings("unchecked")
protected void configure() {
bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
bind(Context.class).toProvider(ContextProvider.class);
bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
bind(ObserverManager.class);
bindProviderListener(new ObserverRegister());
bind(StateManager.class).in(ApplicationScoped.class);
bind(StateEventObserver.class);
bindFieldListener(RetainState.class, new RetainStateListener());
}
Aggregations