List of usage examples for android.graphics Point Point
public Point()
From source file:com.phicdy.mycuration.ui.TopActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); curationFragment = new CurationListFragment(); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.addOnPageChangeListener(new PageChangeListener()); track = (ViewGroup) findViewById(R.id.track); trackScroller = (HorizontalScrollView) findViewById(R.id.track_scroller); indicator = (View) findViewById(R.id.indicator); WindowManager wm = getWindowManager(); Display disp = wm.getDefaultDisplay(); Point size = new Point(); disp.getSize(size);/* w w w . j a v a2 s . com*/ int displayWidth = size.x; LayoutInflater inflater = LayoutInflater.from(this); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { final int position = i; ImageView ivTab = (ImageView) inflater.inflate(R.layout.tab_item, track, false); ivTab.setImageResource(mSectionsPagerAdapter.getImageResource(position)); ivTab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(position); } }); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) ivTab.getLayoutParams(); layoutParams.width = displayWidth / mSectionsPagerAdapter.getCount(); ivTab.setLayoutParams(layoutParams); track.addView(ivTab); } final float density = getResources().getDisplayMetrics().density; indicatorOffset = (int) (INDICATOR_OFFSET_DP * density); setTitle(getString(R.string.home)); dbAdapter = DatabaseAdapter.getInstance(getApplicationContext()); setAlarmManager(); }
From source file:com.inductivebiblestudyapp.ui.dialogs.SimpleTooltipDialog.java
/** * Returns screen size in size 2 array./*from ww w . ja v a2 s . c om*/ * Taken directly from: * https://github.com/kvirair/Quick-Action/blob/master/src/garin/artemiy/quickaction/library/QuickAction.java * @param dimens 0 will become X size, 1 Y size. */ @SuppressWarnings("deprecation") protected void getScreenDimens(int[] dimens) { if (dimens.length < 2) { throw new IllegalArgumentException("Cannot store result in length <2"); } final int X = 0; final int Y = 1; WindowManager windowManager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { Display display = windowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); dimens[X] = size.x; dimens[Y] = size.y; } else { dimens[X] = windowManager.getDefaultDisplay().getWidth(); dimens[Y] = windowManager.getDefaultDisplay().getHeight(); } }
From source file:be.ac.ucl.lfsab1509.bouboule.MyLevelFragment.java
private Point getDisplayVector() { Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w ww . j av a2 s . c o m return size; }
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 /*ww w . j ava 2 s . c o m*/ */ 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.hangulo.powercontact.util.Utils.java
public static int getScreenHeightSize(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);// ww w . j ava 2s . co m //int width = size.x; return (size.y); }
From source file:com.microsoft.mimickeralarm.mimics.MimicWithCameraFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_camera_mimic, container, false); SurfaceView previewView = (SurfaceView) view.findViewById(R.id.camera_preview_view); Display display = getActivity().getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//w w w . j a v a 2 s. c o m mSize = size; double aspectRatio = size.y > size.x ? (double) size.y / (double) size.x : (double) size.x / (double) size.y; mCameraPreview = new CameraPreview(previewView, aspectRatio, CameraFacing); View overlay = view.findViewById(R.id.camera_preview_overlay); overlay.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { // Camera sensor ranges from -1000 to 1000 regardless of aspect ratio, sizes, resolution, ... int deltaX = (int) (((float) mSize.x - event.getX()) / mSize.x * -2000) + 1000; int deltaY = (int) (((float) mSize.y - event.getY()) / mSize.y * -2000) + 1000; mCameraPreview.onFocus(deltaX, deltaY); } return true; } }); ProgressButton progressButton = (ProgressButton) view.findViewById(R.id.capture_button); progressButton.setReadyState(ProgressButton.State.ReadyCamera); mStateManager = new MimicStateManager(); mStateManager.registerCountDownTimer((CountDownTimerView) view.findViewById(R.id.countdown_timer), TIMEOUT_MILLISECONDS); mStateManager.registerStateBanner((MimicStateBanner) view.findViewById(R.id.mimic_state)); mStateManager.registerProgressButton(progressButton, MimicButtonBehavior.CAMERA); mStateManager.registerMimic(this); mSensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (mSensorManager != null) { mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); } mLightSensorListener = new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { if (event.values[0] < LIGHT_THRESHOLD && CameraFacing == Camera.CameraInfo.CAMERA_FACING_FRONT) { mTooDarkToast.show(); } else { mTooDarkToast.cancel(); } } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }; // This toast is only shown when there is not enough light mTooDarkToast = Toast.makeText(getActivity(), getString(R.string.mimic_camera_too_dark), Toast.LENGTH_SHORT); return view; }
From source file:com.amazon.android.tv.tenfoot.ui.activities.ContentBrowseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_browse_activity_layout); Helpers.handleActivityEnterFadeTransition(this, ACTIVITY_ENTER_TRANSITION_FADE_DURATION); mContentTitle = (TextView) findViewById(R.id.content_detail_title); CalligraphyUtils.applyFontToTextView(this, mContentTitle, ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.BOLD_FONT)); mContentDescription = (TextView) findViewById(R.id.content_detail_description); CalligraphyUtils.applyFontToTextView(this, mContentDescription, ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.LIGHT_FONT)); mContentImage = (ImageView) findViewById(R.id.content_image); mContentImage.setImageURI(Uri.EMPTY); // Get display/background size Display display = getWindowManager().getDefaultDisplay(); Point windowSize = new Point(); display.getSize(windowSize);/*from ww w. ja va2 s. co m*/ int imageWidth = (int) getResources().getDimension(R.dimen.content_image_width); int imageHeight = (int) getResources().getDimension(R.dimen.content_image_height); int gradientSize = (int) getResources().getDimension(R.dimen.content_image_gradient_size); // Create the background Bitmap background = BackgroundImageUtils.createBackgroundWithPreviewWindow(windowSize.x, windowSize.y, imageWidth, imageHeight, gradientSize, ContextCompat.getColor(this, R.color.browse_background_color)); mBackgroundWithPreview = new BitmapDrawable(getResources(), background); // Set the background mMainFrame = findViewById(R.id.main_frame); mMainFrame.setBackground(mBackgroundWithPreview); }
From source file:com.cleveroad.audiowidget.AudioWidget.java
@SuppressWarnings("deprecation") private AudioWidget(@NonNull Builder builder) { this.context = builder.context.getApplicationContext(); this.vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); this.handler = new Handler(); this.screenSize = new Point(); this.removeBounds = new RectF(); this.hiddenRemWidPos = new Point(); this.visibleRemWidPos = new Point(); this.controller = newController(); this.windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getSize(screenSize); screenSize.y -= statusBarHeight() + navigationBarHeight(); Configuration configuration = prepareConfiguration(builder); playPauseButton = new PlayPauseButton(configuration); expandCollapseWidget = new ExpandCollapseWidget(configuration); removeWidgetView = new RemoveWidgetView(configuration); int offsetCollapsed = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_collapsed); int offsetExpanded = context.getResources().getDimensionPixelOffset(R.dimen.aw_edge_offset_expanded); playPauseButtonManager = new TouchManager(playPauseButton, playPauseButton.newBoundsChecker( builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed, builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed)) .screenWidth(screenSize.x).screenHeight(screenSize.y); expandedWidgetManager = new TouchManager(expandCollapseWidget, expandCollapseWidget.newBoundsChecker( builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded, builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded)) .screenWidth(screenSize.x).screenHeight(screenSize.y); playPauseButtonManager.callback(new PlayPauseButtonCallback()); expandedWidgetManager.callback(new ExpandCollapseWidgetCallback()); expandCollapseWidget.onWidgetStateChangedListener(new OnWidgetStateChangedListener() { @Override//from ww w . ja v a 2s . co m public void onWidgetStateChanged(@NonNull State state) { if (state == State.COLLAPSED) { playPauseButton.setLayerType(View.LAYER_TYPE_SOFTWARE, null); try { windowManager.removeView(expandCollapseWidget); } catch (IllegalArgumentException e) { // view not attached to window } playPauseButton.enableProgressChanges(true); } if (onWidgetStateChangedListener != null) { onWidgetStateChangedListener.onWidgetStateChanged(state); } } @Override public void onWidgetPositionChanged(int cx, int cy) { } }); onControlsClickListener = new OnControlsClickListenerWrapper(); expandCollapseWidget.onControlsClickListener(onControlsClickListener); ppbToExpBoundsChecker = playPauseButton.newBoundsChecker( builder.edgeOffsetXExpandedSet ? builder.edgeOffsetXExpanded : offsetExpanded, builder.edgeOffsetYExpandedSet ? builder.edgeOffsetYExpanded : offsetExpanded); expToPpbBoundsChecker = expandCollapseWidget.newBoundsChecker( builder.edgeOffsetXCollapsedSet ? builder.edgeOffsetXCollapsed : offsetCollapsed, builder.edgeOffsetYCollapsedSet ? builder.edgeOffsetYCollapsed : offsetCollapsed); }
From source file:com.hangulo.powercontact.util.Utils.java
public static int getScreenWidthtSize(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w. j a va 2 s . co m //int width = size.x; return (size.x); }
From source file:org.xwalk.embedding.asynctest.v6.XWalkViewTestAsync.java
@SmallTest public void testSetInitialScale2() throws Throwable { WindowManager wm = (WindowManager) getInstrumentation().getTargetContext() .getSystemService(Context.WINDOW_SERVICE); Point screenSize = new Point(); wm.getDefaultDisplay().getSize(screenSize); // Make sure after 50% scale, page width still larger than screen. int height = screenSize.y * 2 + 1; int width = screenSize.x * 2 + 1; final String page = "<html><body>" + "<p style='height:" + height + "px;width:" + width + "px'>" + "testSetInitialScale</p></body></html>"; final float defaultScaleFactor = 0; final float defaultScale = 0.5f; final float scaleFactor = 0.25f; assertEquals(defaultScaleFactor, getScaleFactor(), .01f); loadDataSync(null, page, "text/html", false); assertEquals(scaleFactor, getScaleFactor(), .01f); int onScaleChangedCallCount = mTestHelperBridge.getOnScaleChangedHelper().getCallCount(); setInitialScale(60);//from w ww . j a v a 2 s.c o m loadDataSync(null, page, "text/html", false); mTestHelperBridge.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(0.6f, getPixelScale(), .01f); onScaleChangedCallCount = mTestHelperBridge.getOnScaleChangedHelper().getCallCount(); setInitialScale(500); loadDataSync(null, page, "text/html", false); mTestHelperBridge.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(5.0f, getPixelScale(), .01f); onScaleChangedCallCount = mTestHelperBridge.getOnScaleChangedHelper().getCallCount(); // default min-scale will be used. setInitialScale(0); loadDataSync(null, page, "text/html", false); mTestHelperBridge.getOnScaleChangedHelper().waitForCallback(onScaleChangedCallCount); assertEquals(defaultScale, getPixelScale(), .01f); }