List of usage examples for android.view Display getWidth
@Deprecated public int getWidth()
From source file:com.xuejian.client.lxp.module.toolbox.im.IMMainActivity.java
private void showActionDialog() { final Activity act = this; final AlertDialog dialog = new AlertDialog.Builder(act).create(); View contentView = View.inflate(act, R.layout.dialog_city_detail_action, null); Button btn = (Button) contentView.findViewById(R.id.btn_go_plan); btn.setText("Talk"); btn.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j ava 2 s.c om public void onClick(View view) { MobclickAgent.onEvent(mContext, "event_create_new_talk"); startActivityForResult(new Intent(IMMainActivity.this, PickContactsWithCheckboxActivity.class) .putExtra("request", NEW_CHAT_REQUEST_CODE), NEW_CHAT_REQUEST_CODE); dialog.dismiss(); } }); Button btn1 = (Button) contentView.findViewById(R.id.btn_go_share); btn1.setText("?"); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { MobclickAgent.onEvent(mContext, "event_add_new_friend"); startActivity(new Intent(IMMainActivity.this, AddContactActivity.class)); dialog.dismiss(); } }); contentView.findViewById(R.id.btn_cancle).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); WindowManager windowManager = act.getWindowManager(); Window window = dialog.getWindow(); window.setContentView(contentView); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp = window.getAttributes(); lp.width = (int) (display.getWidth()); // window.setAttributes(lp); window.setGravity(Gravity.BOTTOM); // ?dialog? window.setWindowAnimations(R.style.SelectPicDialog); // }
From source file:se.toxbee.sleepfighter.activity.EditGPSFilterAreaActivity.java
/** * Returns the screen dimensions as a Point. * * @return the screen dimensions./*from ww w . j a v a 2 s. c om*/ */ private Point getScreenDim() { Display display = this.getWindowManager().getDefaultDisplay(); @SuppressWarnings("deprecation") Point size = new Point(display.getWidth(), display.getHeight()); return size; }
From source file:de.baumann.thema.RequestActivity.java
@SuppressWarnings("deprecation") private int getDisplaySize(String which) { Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay(); if (which.equals("height")) { return display.getHeight(); }// w ww . j av a 2 s . co m if (which.equals("width")) { return display.getWidth(); } if (DEBUG) Log.v(TAG, "Normally unreachable. Line. What happened??"); return 1000; }
From source file:com.makotosan.vimeodroid.vimeo.Methods.java
public MoogalXml getMoogalXml(String clipId, String userId, VideoQuality quality) { MoogalXml moogal = new MoogalXml(); Display display = ((WindowManager) this.context.getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay();/* w ww . j av a 2s . co m*/ String baseUrl = "http://vimeo.com/moogaloop/load/clip:" + clipId + "/local/?moog_width=" + display.getWidth() + "&moog_height=" + display.getHeight() + "&embed_location=¶m_server=vimeo.com¶m_force_embed=0¶m_multimoog=¶m_autoplay=1¶m_fullscreen=1¶m_md5=0¶m_force_info=undefined¶m_show_portrait=0¶m_show_title=0¶m_ver=39487¶m_show_byline=0¶m_context=user:" + userId + "¶m_clip_id=" + clipId + "¶m_color=00ADEF¶m_context_id=&context=user:" + userId; // Call it, and then we'll get XML final HttpGet request = new HttpGet(baseUrl); final HttpClient client = app.getHttpClient(); final ResponseHandler<String> handler = new BasicResponseHandler(); String finalUrl = ""; try { final String response = client.execute(request, handler); String requestSignature = ""; String requestSignatureExpires = ""; String embedCode = ""; final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); final XmlPullParser xpp = factory.newPullParser(); xpp.setInput(new StringReader(response)); int eventType = xpp.getEventType(); String tagName = ""; while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_TAG: tagName = xpp.getName(); break; case XmlPullParser.END_TAG: tagName = ""; break; case XmlPullParser.TEXT: if ("request_signature".equals(tagName)) { requestSignature = xpp.getText(); break; } if ("request_signature_expires".equals(tagName)) { requestSignatureExpires = xpp.getText(); break; } if ("embed_code".equals(tagName)) { embedCode = xpp.getText(); } break; } eventType = xpp.next(); } finalUrl = String.format( "http://vimeo.com/moogaloop/play/clip:%s/%s/%s/?q=%s&type=local&embed_location=", clipId, requestSignature, requestSignatureExpires, quality); moogal.setUrl(finalUrl); moogal.setEmbedCode(embedCode); moogal.setRequestSignature(requestSignature); moogal.setRequestSignatureExpires(requestSignatureExpires); // Log.d("GetMp4Url", "Playing video at " + finalUrl); } catch (Exception e) { e.printStackTrace(); } return moogal; // return finalUrl; }
From source file:org.navitproject.navit.Navit.java
/** * @brief Shows the native keyboard or other input method. * //from w ww.jav a 2 s . c o m * @return {@code true} if an input method is going to be displayed, {@code false} if not */ public int showNativeKeyboard() { /* * Apologies for the huge mess that this function is, but Android's soft input API is a big * nightmare. Its devs have mercifully given us an option to show or hide the keyboard, but * there is no reliable way to figure out if it is actually showing, let alone how much of the * screen it occupies, so our best bet is guesswork. */ Configuration config = getResources().getConfiguration(); if ((config.keyboard == Configuration.KEYBOARD_QWERTY) && (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO)) /* physical keyboard present, exit */ return 0; /* Use SHOW_FORCED here, else keyboard won't show in landscape mode */ mgr.showSoftInput(getCurrentFocus(), InputMethodManager.SHOW_FORCED); show_soft_keyboard_now_showing = true; /* * Crude way to estimate the height occupied by the keyboard: for AOSP on KitKat and Lollipop it * is about 62-63% of available screen width (in portrait mode) but no more than slightly above * 46% of height (in landscape mode). */ Display display_ = getWindowManager().getDefaultDisplay(); int width_ = display_.getWidth(); int height_ = display_.getHeight(); int maxHeight = height_ * 47 / 100; int inputHeight = width_ * 63 / 100; if (inputHeight > (maxHeight)) inputHeight = maxHeight; /* the receiver isn't going to fire before the UI thread becomes idle, well after this method returns */ Log.d(TAG, "showNativeKeyboard:return (assuming true)"); return inputHeight; }
From source file:org.navitproject.navit.Navit.java
public void fullscreen(int fullscreen) { int w, h;/*from w w w . ja va 2 s. c o m*/ isFullscreen = (fullscreen != 0); if (isFullscreen) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } Display display_ = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT < 17) { w = display_.getWidth(); h = display_.getHeight(); } else { Point size = new Point(); display_.getRealSize(size); w = size.x; h = size.y; } Log.d(TAG, String.format("Toggle fullscreen, w=%d, h=%d", w, h)); N_NavitGraphics.handleResize(w, h); }
From source file:me.wimanacra.collector.DisplayManagerCollector.java
@NonNull private JSONObject collectDisplayData(@NonNull Display display) throws JSONException { final DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*www . j a va 2 s .com*/ final JSONObject result = new JSONObject(); collectCurrentSizeRange(display, result); collectFlags(display, result); collectMetrics(display, result); collectRealMetrics(display, result); collectName(display, result); collectRealSize(display, result); collectRectSize(display, result); collectSize(display, result); collectRotation(display, result); collectIsValid(display, result); result.put("orientation", display.getRotation()).put("refreshRate", display.getRefreshRate()); //noinspection deprecation result.put("height", display.getHeight()).put("width", display.getWidth()).put("pixelFormat", display.getPixelFormat()); return result; }
From source file:org.smilec.smile.ui.GeneralActivity.java
@SuppressWarnings("deprecation") @Override//w ww . ja v a 2 s. c om public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.bt_restart: AlertDialog.Builder builderRestart = new AlertDialog.Builder(this); builderRestart.setMessage(R.string.restart_game).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { //new SmilePlugServerManager().connect(ip, GeneralActivity.this); new SmilePlugServerManager().resetGame(ip, GeneralActivity.this); // QuestionsManager.resetListOfDeletedQuestions(GeneralActivity.this); GeneralActivity.this.finish(); } catch (NetworkErrorException e) { ActivityUtil.showLongToast(GeneralActivity.this, R.string.toast_down_or_unavailable); Log.e(Constants.LOG_CATEGORY, "Error: ", e); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertRestart = builderRestart.create(); alertRestart.show(); break; case R.id.bt_retake: AlertDialog.Builder builderRetake = new AlertDialog.Builder(this); builderRetake.setMessage(R.string.retake_game).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { try { new SmilePlugServerManager().startRetakeQuestions(ip, GeneralActivity.this, board); ActivityUtil.showLongToast(GeneralActivity.this, R.string.toast_retaking); Intent intent = new Intent(GeneralActivity.this, org.smilec.smile.ui.UsePreparedQuestionsActivity.class); intent.putExtra(GeneralActivity.PARAM_IP, ip); status = CurrentMessageStatus.RE_TAKE.name(); intent.putExtra(GeneralActivity.PARAM_STATUS, status); startActivity(intent); } catch (NetworkErrorException e) { Log.e(Constants.LOG_CATEGORY, "Error: ", e); } } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertRetake = builderRetake.create(); alertRetake.show(); break; case R.id.bt_about: Dialog aboutDialog = new Dialog(this, R.style.Dialog); aboutDialog.setContentView(R.layout.about); Display displaySize = ActivityUtil.getDisplaySize(getApplicationContext()); aboutDialog.getWindow().setLayout(displaySize.getWidth(), displaySize.getHeight()); aboutDialog.show(); break; case R.id.bt_exit: AlertDialog.Builder builderExit = new AlertDialog.Builder(this); builderExit.setMessage(R.string.exit).setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); try { new SmilePlugServerManager().resetGame(ip, GeneralActivity.this); } catch (NetworkErrorException e) { Log.e(Constants.LOG_CATEGORY, "Error: ", e); } // QuestionsManager.resetListOfDeletedQuestions(GeneralActivity.this); GeneralActivity.this.finish(); } }).setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alertExit = builderExit.create(); alertExit.show(); break; } return true; }
From source file:org.acra.collector.DisplayManagerCollector.java
@NonNull private Object collectDisplayData(@NonNull Display display) { final DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);// ww w . j a v a 2s. c om //noinspection deprecation return collectCurrentSizeRange(display) + collectFlags(display) + display.getDisplayId() + ".height=" + display.getHeight() + '\n' + collectMetrics(display) + collectName(display) + display.getDisplayId() + ".orientation=" + display.getRotation() + '\n' + display.getDisplayId() + ".pixelFormat=" + display.getPixelFormat() + '\n' + collectRealMetrics(display) + collectRealSize(display) + collectRectSize(display) + display.getDisplayId() + ".refreshRate=" + display.getRefreshRate() + '\n' + collectRotation(display) + collectSize(display) + display.getDisplayId() + ".width=" + display.getWidth() + '\n' + collectIsValid(display); }
From source file:org.apache.cordova.splashscreen.SplashScreen.java
/** * Shows the splash screen over the full Activity *///from w ww . j ava 2s .co m @SuppressWarnings("deprecation") private void showSplashScreen(final boolean hideAfterDelay) { final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); final int drawableId = preferences.getInteger("SplashDrawableId", 0); // If the splash dialog is showing don't try to show it again if (splashDialog != null && splashDialog.isShowing()) { return; } if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Get reference to display Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); Context context = webView.getContext(); // Use an ImageView to render the image because of its flexible scaling options. splashImageView = new ImageView(context); splashImageView.setImageResource(drawableId); LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); splashImageView.setLayoutParams(layoutParams); splashImageView.setMinimumHeight(display.getHeight()); splashImageView.setMinimumWidth(display.getWidth()); // TODO: Use the background color of the webView's parent instead of using the preference. splashImageView.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); if (isMaintainAspectRatio()) { // CENTER_CROP scale mode is equivalent to CSS "background-size:cover" splashImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { // FIT_XY scales image non-uniformly to fit into image view. splashImageView.setScaleType(ImageView.ScaleType.FIT_XY); } // Create and show the dialog splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(splashImageView); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, splashscreenTime); } } }); }