List of usage examples for android.view Display getWidth
@Deprecated public int getWidth()
From source file:de.akquinet.android.androlog.reporter.Report.java
/** * Adds the device data to the report./*from w ww . j a v a2 s. co m*/ * @param context * @throws JSONException if the device data cannot be added */ private void buildDeviceData(Context context) throws JSONException { device = new JSONObject(); device.put("device", Build.DEVICE); device.put("brand", Build.BRAND); Object windowService = context.getSystemService(Context.WINDOW_SERVICE); if (windowService instanceof WindowManager) { Display display = ((WindowManager) windowService).getDefaultDisplay(); device.put("resolution", display.getWidth() + "x" + display.getHeight()); device.put("orientation", display.getOrientation()); } device.put("display", Build.DISPLAY); device.put("manufacturer", Build.MANUFACTURER); device.put("model", Build.MODEL); device.put("product", Build.PRODUCT); device.put("build.type", Build.TYPE); device.put("android.version", Build.VERSION.SDK_INT); }
From source file:com.example.examplescroll.MainActivity.java
@SuppressWarnings("deprecation") @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) private void getDisplaySize(Point displaySize) { Display display = getWindowManager().getDefaultDisplay(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(displaySize);//from www . j av a 2 s .c om } else { displaySize.x = display.getWidth(); displaySize.y = display.getHeight(); } }
From source file:com.wpi.assistments.HomeTabbedActivity.java
private int getScale() { Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); Double val = new Double(width) / 800d; val = val * 100d; Log.i("test", Integer.toString(val.intValue())); return val.intValue(); }
From source file:com.javielinux.utils.PopupLinks.java
private void init(FragmentActivity activity) { this.activity = activity; Display display = activity.getWindowManager().getDefaultDisplay(); widthScreen = display.getWidth(); heightScreen = display.getHeight();/*from ww w .ja v a 2s. c om*/ }
From source file:org.solovyev.android.calculator.floating.FloatingCalculatorService.java
private void createView() { if (view != null) { return;//w ww . j av a2 s. c o m } final WindowManager wm = ((WindowManager) this.getSystemService(Context.WINDOW_SERVICE)); final DisplayMetrics dm = getResources().getDisplayMetrics(); final android.view.Display dd = wm.getDefaultDisplay(); //noinspection deprecation final int maxWidth = 2 * Math.min(dd.getWidth(), dd.getHeight()) / 3; final int desiredWidth = App.toPixels(dm, 300); final int width = Math.min(maxWidth, desiredWidth); final int height = getHeight(width); final FloatingCalculatorView.State state = new FloatingCalculatorView.State(width, height, -1, -1); view = new FloatingCalculatorView(this, state, this); view.show(); view.updateEditorState(editor.getState()); view.updateDisplayState(display.getState()); bus.register(this); preferences.registerOnSharedPreferenceChangeListener(this); }
From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case SELECT_PICTURE: if (resultCode == RESULT_OK) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst();/*from w w w . ja v a2 s . c o m*/ int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); Bitmap bkgImg = BitmapFactory.decodeFile(filePath); Display disp = getWindowManager().getDefaultDisplay(); int w = disp.getWidth(); int h = disp.getHeight(); double scaleX = (w * 1.0) / bkgImg.getWidth(); double scaleY = (h * 1.0) / bkgImg.getHeight(); double scale = Math.min(scaleX, scaleY); double sw = w * scaleX; double sh = h * scaleY; // System.out.println("Scale X ["+scaleX+"] - Scale Y ["+scaleY+"] - Scale ["+scale+"]"); bkgImg = Bitmap.createBitmap(bkgImg, 0, 0, w, h); pinTableFrag.setBackground(bkgImg); } } }
From source file:jp.co.cyberagent.android.gpuimage.sample.activity.ActivityGallery.java
@SuppressLint("NewApi") @Override/*w w w . jav a 2 s . co m*/ public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); //Get height, width mWindowSize = new Point(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { getWindowManager().getDefaultDisplay().getSize(mWindowSize); } else { Display display = getWindowManager().getDefaultDisplay(); mWindowSize.x = display.getWidth(); mWindowSize.y = display.getHeight(); } Log.v(DEBUG_TAG, "Window Size = " + mWindowSize.x + " = " + mWindowSize.y); //((SeekBar) findViewById(R.id.seekBar)).setOnSeekBarChangeListener(this); //findViewById(R.id.button_choose_filter).setOnClickListener(this); //findViewById(R.id.button_save).setOnClickListener(this); mGPUImageView = (GPUImageView) findViewById(R.id.gpuimage); //Drawable water = getResources().getDrawable(R.drawable.water_over_coral_reef_303786); //BitmapDrawable = getResources().getDrawable(R.drawable.water_over_coral_reef_303786); Bitmap water = BitmapFactory.decodeResource(getResources(), R.drawable.water_over_coral_reef_303786); mGPUImageView.setImage(water); /*Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, REQUEST_PICK_IMAGE);*/ switchFilterTo(new WaterRippleEffect(mWindowSize.x, mWindowSize.y)); mGPUImageView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); switch (action) { case (MotionEvent.ACTION_DOWN): Log.d(DEBUG_TAG, "Action was DOWN X = " + event.getX() + " | Y =" + event.getY()); //if(mFilter.getClass() == WaterRippleEffect.class) { try { float points[] = convertFromAndroiSpaceToOpenGL(event.getX(), event.getY()); ((WaterRippleEffect) mFilter).setTouches(points[0], points[1]); } catch (NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); } //} return true; case (MotionEvent.ACTION_MOVE): Log.d(DEBUG_TAG, "Action was MOVE"); return true; case (MotionEvent.ACTION_UP): Log.d(DEBUG_TAG, "Action was UP"); return true; case (MotionEvent.ACTION_CANCEL): Log.d(DEBUG_TAG, "Action was CANCEL"); return true; case (MotionEvent.ACTION_OUTSIDE): Log.d(DEBUG_TAG, "Movement occurred outside bounds " + "of current screen element"); return true; default: return true; } } }); }
From source file:com.mirasense.scanditsdk.plugin.ScanditSDKActivity.java
@SuppressWarnings("deprecation") public void initializeAndStartBarcodeRecognition(Bundle extras) { // Switch to full screen. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); ScanSettings settings = ScanditSDKParameterParser.settingsForBundle(extras); mBarcodePicker = new SearchBarBarcodePicker(this, settings); this.setContentView(mBarcodePicker); Display display = getWindowManager().getDefaultDisplay(); ScanditSDKParameterParser.updatePickerUIFromBundle(mBarcodePicker, extras, display.getWidth(), display.getHeight());// ww w. j a v a 2s . co m if (extras.containsKey(ScanditSDKParameterParser.paramContinuousMode)) { mContinuousMode = extras.getBoolean(ScanditSDKParameterParser.paramContinuousMode); } // Register listener, in order to be notified about relevant events // (e.g. a successfully scanned bar code). mBarcodePicker.setOnScanListener(this); mBarcodePicker.setOnSearchBarListener(this); if (extras.containsKey(ScanditSDKParameterParser.paramPaused) && extras.getBoolean(ScanditSDKParameterParser.paramPaused)) { mStartPaused = true; } else { mStartPaused = false; } }
From source file:im.vector.adapters.ImagesSliderAdapter.java
@SuppressLint("NewApi") private Point getDisplaySize() { Point size = new Point(); WindowManager w = ((Activity) context).getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { w.getDefaultDisplay().getSize(size); } else {/* www.jav a2 s . c o m*/ Display d = w.getDefaultDisplay(); size.x = d.getWidth(); size.y = d.getHeight(); } return size; }
From source file:com.loadsensing.app.Chart.java
private void generaChart(WebView googleChartView, int checkedId, String SensorSelected) { SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE); String address = SERVER_HOST + "?session=" + settings.getString("session", "") + "&id=" + SensorSelected + "&TipusGrafic=" + checkedId; ArrayList<HashMap<String, String>> valorsURL = new ArrayList<HashMap<String, String>>(); try {// www . j av a 2s .c o m String jsonString = JsonClient.connectString(address); // Convertim la resposta string a un JSONArray JSONArray ValorsGrafica = new JSONArray(jsonString); // En esta llamada slo hay 1 objeto JSONObject Valors = new JSONObject(); Valors = ValorsGrafica.getJSONObject(0); String grafica = Valors.getString("ValorsGrafica"); // Sobre el string de ValorGrafica, volvemos a parsearlo JSONArray ValorGrafica = new JSONArray(grafica); for (int i = 0; i < ValorGrafica.length(); i++) { JSONObject Valor = new JSONObject(); Valor = ValorGrafica.getJSONObject(i); HashMap<String, String> valorHashMap = new HashMap<String, String>(); valorHashMap.put("date", Valor.getString("date")); valorHashMap.put("value", Valor.getString("value")); valorsURL.add(valorHashMap); } } catch (Exception e) { Log.d(DEB_TAG, "Error rebent xarxes"); } // Montamos URL String mUrl = CHART_URL; // Etiquetas eje X, columna 0 y 1 mUrl = mUrl + "chxl=0:"; for (int i = 3; i < valorsURL.size(); i += 4) { mUrl = mUrl + "|" + URLEncoder.encode(valorsURL.get(i).get("date")); } mUrl = mUrl + "|Fecha"; mUrl = mUrl + "|1:"; for (int i = 1; i < valorsURL.size(); i += 4) { mUrl = mUrl + "|" + URLEncoder.encode(valorsURL.get(i).get("date")); } // Posicin etiquetas eje Y mUrl = mUrl + "&chxp=0,30,70,110|1,10,50,90"; // Rango x,y // Coger valor mnimo y mximo float max = new Float(valorsURL.get(0).get("value")); float min = new Float(valorsURL.get(0).get("value")); for (int i = 1; i < valorsURL.size(); i++) { Float valueFloat = new Float(valorsURL.get(i).get("value")); max = Math.max(max, valueFloat); min = Math.min(min, valueFloat); } BigDecimal maxRounded = new BigDecimal(max); maxRounded = maxRounded.setScale(1, BigDecimal.ROUND_CEILING); BigDecimal minRounded = new BigDecimal(min); minRounded = minRounded.setScale(1, BigDecimal.ROUND_FLOOR); mUrl = mUrl + "&chxr=0,-5,110|1,-5,110|2," + minRounded + "," + maxRounded; // Ejes visibles mUrl = mUrl + "&chxt=x,x,y"; // Tipo de grfico mUrl = mUrl + "&cht=lxy"; // Medida del grfico Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth() - 170; int height = display.getHeight() - 390; mUrl = mUrl + "&chs=" + width + "x" + height; // Colores mUrl = mUrl + "&chco=3072F3"; // Escala mUrl = mUrl + "&chds=0,9," + minRounded + "," + maxRounded; // Valores mUrl = mUrl + "&chd=t:0"; for (int i = 1; i < valorsURL.size(); i++) { mUrl = mUrl + "," + i; } mUrl = mUrl + "|"; mUrl = mUrl + valorsURL.get(0).get("value"); for (int i = 1; i < valorsURL.size(); i++) { mUrl = mUrl + "," + valorsURL.get(i).get("value"); } // Ttulo eyenda switch (checkedId) { case R.id.radio1: mUrl = mUrl + "&chdl=Sensor+strain+(V)&chdlp=b"; break; case R.id.radio2: mUrl = mUrl + "&chdl=Excitation+power+(V)&chdlp=b"; break; case R.id.radio3: mUrl = mUrl + "&chdl=Counter+(cnts)&chdlp=b"; break; } // Estilo de lineas mUrl = mUrl + "&chls=2"; // Mrgenes mUrl = mUrl + "&chma=0,5,5,25|5"; // Marcador mUrl = mUrl + "&chm=r,FF0000,0,0,0"; Log.d(DEB_TAG, "URL Chart " + mUrl); googleChartView.loadUrl(mUrl); }