List of usage examples for android.view Display getSize
public void getSize(Point outSize)
From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_user_crop_dialog, null); if (mRemoveCropHelperMode) { getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0)); } else {//from ww w .ja v a 2 s. c o m int width = 10; int height = 10; WindowManager wm = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 13) { android.graphics.Point size = new android.graphics.Point(); display.getSize(size); width = size.x - 10; height = size.y - 10; } else { width = display.getWidth() - 10; height = display.getHeight() - 10; } int maxImageSize = width * height * 4; if (maxImageSize > 0) { int maxImages = (DEFAULT_MEM_CACHE_SIZE * 1000) / maxImageSize; if (maxImages > 0) { mPagesToPreRenderPerDirection = Math.min(MAX_PAGES_TO_PRERENDER_PER_DIRECTION, (maxImages - 1) / 2); } } } initUI(view); return view; }
From source file:com.farmerbb.taskbar.service.TaskbarService.java
private int getNavBarSize() { Point size = new Point(); Point realSize = new Point(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); display.getSize(size); display.getRealSize(realSize);//from ww w .j a v a 2 s. c om return realSize.y - size.y; }
From source file:tv.piratemedia.lightcontroler.controller.java
public void popupMenu() { MenuView = View.inflate(this, R.layout.menu, null); TextView settings = (TextView) MenuView.findViewById(R.id.settings_menu_item); TextView DeviceSetup = (TextView) MenuView.findViewById(R.id.setup_menu_item); if (DeviceMac.toLowerCase().equals(Utils.GetWifiMac().replace(":", "").toLowerCase())) { DeviceSetup.setVisibility(View.VISIBLE); } else {/*from w w w .ja v a2 s. c o m*/ DeviceSetup.setVisibility(View.GONE); } settings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { closeMenu(); Intent intent = new Intent(getApplicationContext(), controlPreferences.class); startActivity(intent); finish(); } }); DeviceSetup.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Controller.getWifiNetworks(); closeMenu(); } }); MenuView.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_corner)); mMenu = new PopupWindow(MenuView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); mMenu.setContentView(MenuView); mMenu.setTouchable(true); if (Build.VERSION.SDK_INT == 21) { mMenu.setElevation((int) dipToPixels(this, 10)); } Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); mMenu.setAnimationStyle(R.anim.abc_slide_in_top); mMenu.setBackgroundDrawable(new BitmapDrawable()); mMenu.setFocusable(true); mMenu.setOutsideTouchable(false); mMenu.showAtLocation(findViewById(R.id.container), 0, size.x - (int) dipToPixels(this, 208), (int) dipToPixels(this, 32)); mMenu.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { MenuView.setAnimation( AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_out_corner)); } }); }
From source file:com.hippo.ehviewer.ui.scene.DownloadsScene.java
private void guideDownloadLabels() { MainActivity activity = getActivity2(); if (null == activity || !Settings.getGuideDownloadLabels()) { return;//from ww w. ja v a 2s . c om } Display display = activity.getWindowManager().getDefaultDisplay(); Point point = new Point(); display.getSize(point); mShowcaseView = new ShowcaseView.Builder(activity).withMaterialShowcase().setStyle(R.style.Guide) .setTarget(new PointTarget(point.x, point.y / 3)).blockAllTouches() .setContentTitle(R.string.guide_download_labels_title) .setContentText(R.string.guide_download_labels_text).replaceEndButton(R.layout.button_guide) .setShowcaseEventListener(new SimpleShowcaseEventListener() { @Override public void onShowcaseViewDidHide(ShowcaseView showcaseView) { mShowcaseView = null; ViewUtils.removeFromParent(showcaseView); Settings.puttGuideDownloadLabels(false); openDrawer(Gravity.RIGHT); } }).build(); }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size); //size of screen screenWidth = size.x;//w w w .j a v a 2 s . com screenHeight = size.y; FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); topLayout = new FrameLayout(this); setContentView(topLayout); mGLView = overlay.getGLView(); // OpenGLview int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); Log.d("CameraDebug", "InitLayout acquired camera"); if (CAMERA_PREVIEW) { cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); }
From source file:org.telegram.ui.GalleryImageViewer.java
@SuppressWarnings("unchecked") @Override/*from w w w .java2s. c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Display display = getWindowManager().getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT < 13) { displaySize.set(display.getWidth(), display.getHeight()); } else { display.getSize(displaySize); } classGuid = ConnectionsManager.Instance.generateClassGuid(); setContentView(R.layout.gallery_layout); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayUseLogoEnabled(false); actionBar.setTitle(getString(R.string.Gallery)); actionBar.show(); mViewPager = (GalleryViewPager) findViewById(R.id.gallery_view_pager); ImageView shareButton = (ImageView) findViewById(R.id.gallery_view_share_button); ImageView deleteButton = (ImageView) findViewById(R.id.gallery_view_delete_button); nameTextView = (TextView) findViewById(R.id.gallery_view_name_text); timeTextView = (TextView) findViewById(R.id.gallery_view_time_text); bottomView = findViewById(R.id.gallery_view_bottom_view); fakeTitleView = (TextView) findViewById(R.id.fake_title_view); loadingProgress = (ProgressBar) findViewById(R.id.action_progress); title = (TextView) findViewById(R.id.action_bar_title); if (title == null) { final int titleId = getResources().getIdentifier("action_bar_title", "id", "android"); title = (TextView) findViewById(titleId); } NotificationCenter.Instance.addObserver(this, FileLoader.FileDidFailedLoad); NotificationCenter.Instance.addObserver(this, FileLoader.FileDidLoaded); NotificationCenter.Instance.addObserver(this, FileLoader.FileLoadProgressChanged); NotificationCenter.Instance.addObserver(this, MessagesController.mediaCountDidLoaded); NotificationCenter.Instance.addObserver(this, MessagesController.mediaDidLoaded); NotificationCenter.Instance.addObserver(this, MessagesController.userPhotosLoaded); NotificationCenter.Instance.addObserver(this, 658); Integer index = null; if (localPagerAdapter == null) { final MessageObject file = (MessageObject) NotificationCenter.Instance.getFromMemCache(51); final TLRPC.FileLocation fileLocation = (TLRPC.FileLocation) NotificationCenter.Instance .getFromMemCache(53); final ArrayList<MessageObject> messagesArr = (ArrayList<MessageObject>) NotificationCenter.Instance .getFromMemCache(54); index = (Integer) NotificationCenter.Instance.getFromMemCache(55); Integer uid = (Integer) NotificationCenter.Instance.getFromMemCache(56); if (uid != null) { user_id = uid; } if (file != null) { ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>(); HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>(); imagesArr.add(file); if (file.messageOwner.action == null || file.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) { needSearchMessage = true; imagesByIds.put(file.messageOwner.id, file); if (file.messageOwner.dialog_id != 0) { currentDialog = file.messageOwner.dialog_id; } else { if (file.messageOwner.to_id.chat_id != 0) { currentDialog = -file.messageOwner.to_id.chat_id; } else { if (file.messageOwner.to_id.user_id == UserConfig.clientUserId) { currentDialog = file.messageOwner.from_id; } else { currentDialog = file.messageOwner.to_id.user_id; } } } } localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds); } else if (fileLocation != null) { ArrayList<TLRPC.FileLocation> arr = new ArrayList<TLRPC.FileLocation>(); arr.add(fileLocation); withoutBottom = true; deleteButton.setVisibility(View.INVISIBLE); nameTextView.setVisibility(View.INVISIBLE); timeTextView.setVisibility(View.INVISIBLE); localPagerAdapter = new LocalPagerAdapter(arr); } else if (messagesArr != null) { ArrayList<MessageObject> imagesArr = new ArrayList<MessageObject>(); HashMap<Integer, MessageObject> imagesByIds = new HashMap<Integer, MessageObject>(); imagesArr.addAll(messagesArr); Collections.reverse(imagesArr); for (MessageObject message : imagesArr) { imagesByIds.put(message.messageOwner.id, message); } index = imagesArr.size() - index - 1; MessageObject object = imagesArr.get(0); if (object.messageOwner.dialog_id != 0) { currentDialog = object.messageOwner.dialog_id; } else { if (object.messageOwner.to_id.chat_id != 0) { currentDialog = -object.messageOwner.to_id.chat_id; } else { if (object.messageOwner.to_id.user_id == UserConfig.clientUserId) { currentDialog = object.messageOwner.from_id; } else { currentDialog = object.messageOwner.to_id.user_id; } } } localPagerAdapter = new LocalPagerAdapter(imagesArr, imagesByIds); } } mViewPager.setPageMargin(Utilities.dp(20)); mViewPager.setOffscreenPageLimit(1); mViewPager.setAdapter(localPagerAdapter); if (index != null) { fromAll = true; mViewPager.setCurrentItem(index); } shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { TLRPC.FileLocation file = getCurrentFile(); File f = new File(Utilities.getCacheDir(), file.volume_id + "_" + file.local_id + ".jpg"); if (f.exists()) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); startActivity(intent); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mViewPager == null || localPagerAdapter == null || localPagerAdapter.imagesArr == null) { return; } int item = mViewPager.getCurrentItem(); MessageObject obj = localPagerAdapter.imagesArr.get(item); if (obj.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SENT) { ArrayList<Integer> arr = new ArrayList<Integer>(); arr.add(obj.messageOwner.id); MessagesController.Instance.deleteMessages(arr); finish(); } } }); if (currentDialog != 0 && totalCount == 0) { MessagesController.Instance.getMediaCount(currentDialog, classGuid, true); } if (user_id != 0) { MessagesController.Instance.loadUserPhotos(user_id, 0, 30, 0, true, classGuid); } checkCurrentFile(); }
From source file:com.google.android.apps.santatracker.games.SplashActivity.java
@Override protected void onStart() { super.onStart(); // Orientation boolean gameIsLandscape = getIntent().getBooleanExtra(EXTRA_LANDSCAPE, false); boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); // Figure out how many degrees to rotate // Landscape always wants to be at 90degrees, portrait always wants to be at 0degrees float degreesToRotate = 0f; if (rotation == Surface.ROTATION_0) { degreesToRotate = gameIsLandscape && !isLandscape ? 90.0f : 0.0f; } else if (rotation == Surface.ROTATION_90) { degreesToRotate = gameIsLandscape && isLandscape ? 0f : -90f; } else if (rotation == Surface.ROTATION_180) { degreesToRotate = gameIsLandscape && !isLandscape ? -90f : -180f; } else if (rotation == Surface.ROTATION_270) { degreesToRotate = gameIsLandscape && isLandscape ? -180f : -270f; }//w w w .j av a2s .c o m // On a TV, should always be 0 if (isRunningOnTV()) { degreesToRotate = 0f; } // Rotate, if necessary if (degreesToRotate != 0) { Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { display.getRealSize(size); } else { display.getSize(size); } int w = size.x; int h = size.y; View mainLayout = findViewById(R.id.splash_layout); mainLayout.setRotation(degreesToRotate); mainLayout.setTranslationX((w - h) / 2); mainLayout.setTranslationY((h - w) / 2); ViewGroup.LayoutParams lp = mainLayout.getLayoutParams(); lp.height = w; lp.width = h; mainLayout.requestLayout(); } }
From source file:com.miz.functions.MizLib.java
public static int getDisplaySize(Context c, int type) { WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/*from w w w . j a v a 2 s. c o m*/ return type == HEIGHT ? size.y : size.x; }
From source file:com.miz.functions.MizLib.java
public static String getBackdropUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int width = Math.max(size.x, size.y); if (width > 1280 && isTablet(c)) // We only want to download full size images on tablets, as these are the only devices where you can see the difference return "original"; else if (width > 780) return "w1280"; return "w780"; }
From source file:com.miz.functions.MizLib.java
public static String getBackdropThumbUrlSize(Context c) { WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int width = Math.min(size.x, size.y); if (width >= 780) return "w780"; if (width >= 400) return "w500"; return "w300"; }