List of usage examples for android.view Display getWidth
@Deprecated public int getWidth()
From source file:com.poepoemyintswe.popularmovies.ui.MainFragment.java
private int calculateWidth() { int measuredWidth; WindowManager w = getActivity().getWindowManager(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Point size = new Point(); w.getDefaultDisplay().getSize(size); measuredWidth = size.x;/* w w w .ja v a2 s. c om*/ } else { Display d = w.getDefaultDisplay(); measuredWidth = d.getWidth(); } measuredWidth = measuredWidth / 6; return measuredWidth; }
From source file:com.pickr.tasks.PhotoLoader.java
private Bitmap loadBitmap(PhotoSize size, Display display) throws IOException { InputStream is = null;//from w ww.j a v a 2 s. c o m 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:com.paperpad.mybox.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId //from www . j a v a 2s . c o m */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = 0; String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; boolean isTablet = context.getResources().getBoolean(R.bool.isTablet); if (isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; // ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, null); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.paperpad.MoulinsDuDuc.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId //ww w . ja v a 2 s. co m */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = 0; String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; boolean isTablet = context.getResources().getBoolean(R.bool.isTablet); if (isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; // ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier, application_version, regId, android.os.Build.MANUFACTURER, android.os.Build.MODEL, "android", device_screen_resolution, 5, android.os.Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, null); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.euphor.paperpad.GcmBroadcastReceiver.java
/** * Sends the registration ID to your server over HTTP, so it can use GCM/HTTP * or CCS to send messages to your app. Not needed for this demo since the * device sends upstream messages to a server that echoes back the message * using the 'from' address in the message. * @param regId /*from ww w. j a v a 2 s . c om*/ */ private void sendRegistrationIdToBackend(Context context, String regId) { int id_menu = MainActivity.params.getId(); String application_unique_identifier = Installation.id(context); String application_version = "0.2.8"; try { application_version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ; String device_type = ""; if (MainActivity.isTablet) { device_type = "tablet"; } else { device_type = "smartphone"; } WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); } else { size.x = display.getWidth(); // deprecated size.y = display.getHeight(); } String device_screen_resolution = size.x + "x" + size.y; ArrayList<AppHit> hits = new ArrayList<AppHit>(); AppSession appSession = new AppSession(id_menu, MainActivity.prod_or_sand, "sales", application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, hits); ArrayList<AppSession> appSessions = new ArrayList<AppSession>(); appSessions.add(appSession); AppJsonWriter appJsonWriter = new AppJsonWriter(); String str = appJsonWriter.writeJson(appSessions); String endpoint = SERVER_URL; String body = str; int status = 0; try { status = AppJsonWriter.post(endpoint, body); } catch (IOException e) { Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status); e.printStackTrace(); } }
From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java
private void setItemSize(View v) { Context c = v.getContext();//w w w . j a v a 2s . c o 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.example.android.apis.graphics.FingerPaint.java
private Bitmap loadBitmap() { SharedPreferences shre = PreferenceManager.getDefaultSharedPreferences(this); String previouslyEncodedImage = shre.getString("paint_image_data", ""); if (!previouslyEncodedImage.equalsIgnoreCase("")) { byte[] b = Base64.decode(previouslyEncodedImage, Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(b, 0, b.length); Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true); return mutableBitmap; }/*from www .j a va2 s. c om*/ Display display = getWindowManager().getDefaultDisplay(); @SuppressWarnings("deprecation") int width = display.getWidth(); @SuppressWarnings("deprecation") int height = display.getHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); return bitmap; }
From source file:com.andryr.musicplayer.fragments.AlbumListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_album_list, container, false); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.list_view); WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Resources res = getActivity().getResources(); float screenWidth = display.getWidth(); float itemWidth = res.getDimension(R.dimen.album_grid_item_width); mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), Math.round(screenWidth / itemWidth))); int artworkSize = res.getDimensionPixelSize(R.dimen.art_size); mAdapter = new AlbumListAdapter(getActivity(), artworkSize, artworkSize); mAdapter.setOnItemClickListener(mOnItemClickListener); mRecyclerView.setAdapter(mAdapter);//ww w.j a v a 2 s.co m mFastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller); mFastScroller.setShowBubble(mShowScrollerBubble); mFastScroller.setSectionIndexer(mAdapter); mFastScroller.setRecyclerView(mRecyclerView); return rootView; }
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 w w . j a va 2 s . 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.harmazing.aixiumama.activity.ActivityGallery.java
private Bitmap GetandSaveCurrentImage() { //Bitmap/*from w ww.ja v a 2s . c om*/ WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); int w = display.getWidth(); int h = display.getHeight(); Bitmap Bmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); //?? View decorview = this.getWindow().getDecorView(); // decorview.setDrawingCacheEnabled(true); // decorview.buildDrawingCache(); // Bmp = decorview.getDrawingCache(); Canvas c = new Canvas(Bmp); decorview.draw(c); // Bmp = Bitmap.createBitmap(Bmp, 0, BitmapUtil.dip2px(getApplicationContext(), 50) + getTopViewHeight(), w, CuteApplication.getScreenHW(getApplicationContext())[0] - BitmapUtil.dip2px(getApplicationContext(), 10)); decorview.destroyDrawingCache(); decorview.setDrawingCacheEnabled(false); return Bmp; }