List of usage examples for android.view Display getHeight
@Deprecated public int getHeight()
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()); if (extras.containsKey(ScanditSDKParameterParser.paramContinuousMode)) { mContinuousMode = extras.getBoolean(ScanditSDKParameterParser.paramContinuousMode); }//w ww . j a va 2 s . c o m // 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:com.pickr.tasks.PhotoLoader.java
private Bitmap loadBitmap(PhotoSize size, Display display) throws IOException { InputStream is = null;/*from w w w . ja v a2s . com*/ try { if (BuildConfig.DEBUG) { LOGGER.d("Loading photo with size " + size.getWidth() + "x" + size.getHeight() + " for screen " + display.getWidth() + "x" + display.getHeight()); } URL url = size.getSource(); Bitmap bitmap = FlickrCache.getBitmapCache().get(url); if (bitmap == null) { is = url.openStream(); Options options = new Options(); options.inPurgeable = true; options.inInputShareable = true; options.inSampleSize = BitmapUtils.calculateInSampleSize(size.getWidth(), size.getHeight(), display.getWidth(), display.getHeight()); bitmap = BitmapFactory.decodeStream(is, null, options); FlickrCache.getBitmapCache().put(url, bitmap); } Message msg = mHandler.obtainMessage(PHOTO_URL, url); mHandler.sendMessage(msg); return bitmap; } finally { IOUtils.closeQuietly(is); } }
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 {/*from w ww .ja v a2 s . c o m*/ Display d = w.getDefaultDisplay(); size.x = d.getWidth(); size.y = d.getHeight(); } return size; }
From source file:jp.co.cyberagent.android.gpuimage.sample.activity.ActivityGallery.java
@SuppressLint("NewApi") @Override//from w w w .j ava 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.frublin.androidoauth2.FsDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSpinner = new ProgressDialog(getContext()); mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE); mSpinner.setMessage("Loading..."); mContent = new LinearLayout(getContext()); mContent.setOrientation(LinearLayout.VERTICAL); setUpTitle();/*from w ww .j ava 2s .co m*/ setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); final float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(mContent, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }
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 {//from w ww. j ava2 s.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); }
From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java
private void setItemSize(View v) { Context c = v.getContext();/*from w w w .j a v a2s . co m*/ WindowManager wm = (WindowManager) v.getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int x = display.getWidth(); int y = display.getHeight(); int nwidth = x; if (Config.isLandscape(c)) { ((TextView) v.findViewById(R.id.tvToyTitle)).setMaxLines(Config.TITLE_MAX_LINE_LANDSCAPE); nwidth = x > y ? x : y; } else { ((TextView) v.findViewById(R.id.tvToyTitle)).setMaxLines(Config.TITLE_MAX_LINE_PORTRAIT); nwidth = x < y ? x : y; } int nItemPerWidth = nwidth / Config.getSpans(c); Log.e(TAG, ">>>" + x + "/" + y + " -->" + nItemPerWidth); v.findViewById(R.id.imageview_Background) .setLayoutParams(new LinearLayout.LayoutParams(nItemPerWidth, nItemPerWidth)); }
From source file:com.daiv.android.twitter.manipulations.EmojiKeyboard.java
@Override protected void onFinishInflate() { try {/*from w ww.ja va2 s .c om*/ try { getContext().getPackageManager().getPackageInfo("com.daiv.android.emoji_keyboard_trial", PackageManager.GET_META_DATA); } catch (Exception e) { getContext().getPackageManager().getPackageInfo("com.daiv.android.emoji_keyboard_trial_ios", PackageManager.GET_META_DATA); } emojiPager = (ViewPager) findViewById(R.id.emojiKeyboardPager); backspace = (ImageButton) findViewById(R.id.delete); Display d = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); keyboardHeight = (int) (d.getHeight() / 3.0); dataSource = new EmojiDataSource(getContext()); dataSource.open(); recents = (ArrayList<Recent>) dataSource.getAllRecents(); emojiPager.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, keyboardHeight)); tabs = (PagerSlidingTabStrip) findViewById(R.id.emojiTabs); tabs.setIndicatorColor(getResources().getColor(R.color.app_color)); emojiPagerAdapter = new EmojiPagerAdapter(getContext(), emojiPager); emojiPager.setAdapter(emojiPagerAdapter); tabs.setViewPager(emojiPager); emojiPager.setCurrentItem(1); backspace.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { removeText(); } }); } catch (Exception e) { } }
From source file:com.klinker.android.twitter.manipulations.EmojiKeyboard.java
@Override protected void onFinishInflate() { try {//ww w . j a v a2s .com try { getContext().getPackageManager().getPackageInfo("com.klinker.android.emoji_keyboard_trial", PackageManager.GET_META_DATA); } catch (Exception e) { getContext().getPackageManager().getPackageInfo("com.klinker.android.emoji_keyboard_trial_ios", PackageManager.GET_META_DATA); } emojiPager = (ViewPager) findViewById(R.id.emojiKeyboardPager); backspace = (ImageButton) findViewById(R.id.delete); Display d = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); keyboardHeight = (int) (d.getHeight() / 3.0); dataSource = new EmojiDataSource(getContext()); dataSource.open(); recents = (ArrayList<Recent>) dataSource.getAllRecents(); emojiPager.setLayoutParams( new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, keyboardHeight)); tabs = (PagerSlidingTabStrip) findViewById(R.id.emojiTabs); tabs.setIndicatorColor(getResources().getColor(R.color.app_color)); emojiPagerAdapter = new EmojiPagerAdapter(getContext(), emojiPager); emojiPager.setAdapter(emojiPagerAdapter); tabs.setViewPager(emojiPager); emojiPager.setCurrentItem(1); backspace.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { removeText(); } }); } catch (Exception e) { } }
From source file:com.renren.api.connect.android.view.RenrenDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); progress = new ProgressDialog(getContext()); progress.requestWindowFeature(Window.FEATURE_NO_TITLE); progress.setMessage("Loading..."); content = new LinearLayout(getContext()); content.setOrientation(LinearLayout.VERTICAL); requestWindowFeature(Window.FEATURE_NO_TITLE); if (this.showTitle) { setUpTitle();/*from w w w . ja v a 2 s . c o m*/ } setUpWebView(); Display display = getWindow().getWindowManager().getDefaultDisplay(); float scale = getContext().getResources().getDisplayMetrics().density; float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE; addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f))); }