List of usage examples for android.graphics Point Point
public Point()
From source file:com.google.android.gms.samples.vision.face.sleepAlert.DAssistActivity.java
/** * Creates and starts the camera. Note that this uses a higher resolution in comparison * to other detection examples to enable the barcode detector to detect small barcodes * at long distances.// ww w . java 2s . c o m */ private void createCameraSource() { Context context = getApplicationContext(); FaceDetector detector = new FaceDetector.Builder(context) .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS).build(); detector.setProcessor(new MultiProcessor.Builder<>(new GraphicFaceTrackerFactory()).build()); if (!detector.isOperational()) { // Note: The first time that an app using face API is installed on a device, GMS will // download a native library to the device in order to do detection. Usually this // completes before the app is run for the first time. But if that download has not yet // completed, then the above call will not detect any faces. // // isOperational() can be used to check if the required native library is currently // available. The detector will automatically become operational once the library // download completes on device. Log.w(TAG, "Face detector dependencies are not yet available."); } Display display = getWindowManager().getDefaultDisplay(); Point screenSize = new Point(); display.getSize(screenSize); this.width = screenSize.x; this.height = screenSize.y; System.out.println(" Srini with size" + screenSize.x); System.out.println(" Srini with size" + screenSize.y); mCameraSource = new CameraSource.Builder(context, detector) .setRequestedPreviewSize(screenSize.x, screenSize.y).setFacing(CameraSource.CAMERA_FACING_FRONT) .setRequestedFps(30.0f).build(); }
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;//from w ww. j av a2 s . co m } else { Display d = w.getDefaultDisplay(); measuredWidth = d.getWidth(); } measuredWidth = measuredWidth / 6; return measuredWidth; }
From source file:com.appsimobile.appsii.module.weather.WeatherLoadingService.java
private static int getMaxScreenDimension(WindowManager windowManager) { Point point = new Point(); windowManager.getDefaultDisplay().getSize(point); int dimen = Math.max(point.x, point.y); dimen = (dimen * 3) / 4;/*from www . ja v a 2s. c o m*/ return dimen; }
From source file:com.andfchat.frontend.activities.ChatScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(sessionData.getSessionSettings().getTheme()); setContentView(R.layout.activity_chat_screen); AdEntry.setAdClickListener(this); SystemBarTintManager tintManager = new SystemBarTintManager(this); // enable status bar tint tintManager.setStatusBarTintEnabled(true); tintManager.setTintColor(getResources().getColor(R.color.primary_color_dark)); toggleSidebarRight.setSelected(false); eventManager.clear();//from ww w . ja v a 2 s .c o m eventManager.register((ChatroomEventListener) this); eventManager.register((ConnectionEventListener) this); // Fetch fragments chatFragment = (ChatFragment) getSupportFragmentManager().findFragmentById(R.id.chatFragment); userList = (UserListFragment) getSupportFragmentManager().findFragmentById(R.id.userListFragment); channelList = (ChannelListFragment) getSupportFragmentManager().findFragmentById(R.id.channelListFragment); inputFragment = (ChatInputFragment) getSupportFragmentManager().findFragmentById(R.id.chatInputFragment); // Register fragments eventManager.register((ChatroomEventListener) chatFragment); eventManager.register((MessageEventListener) chatFragment); eventManager.register((ChatroomEventListener) userList); eventManager.register((UserEventListener) userList); eventManager.register(channelList); eventManager.register(inputFragment); // PopUps loginPopup = new FListLoginPopup(); charSelectionPopup = new FListCharSelectionPopup(); loginPopup.setDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (sessionData.getTicket() == null) { openLogin(); } } }); charSelectionPopup.setDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (!sessionData.isInChat()) { connection.closeConnection(ChatScreen.this); sessionData.setTicket(null); openLogin(); } } }); RoboGuice.injectMembers(this, charSelectionPopup); RoboGuice.injectMembers(this, loginPopup); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); height = size.y; width = size.x; AndFChatApplication application = (AndFChatApplication) getApplicationContext(); application.setScreenDimension(size); setupActionBar(); }
From source file:com.google.mist.plot.MainActivity.java
private void dumpSensorData() throws JSONException { //TODO(cjr): do we want JSONException here? File dataDir = getOrCreateSessionDir(); File target = new File(dataDir, String.format("%s.json", mRecordingType)); JSONObject jsonObject = new JSONObject(); jsonObject.put("version", "1.0.0"); boolean isCalibrated = mPullDetector.getCalibrationStatus(); jsonObject.put("calibrated", isCalibrated); // Write system information Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size);//from w w w . ja va 2 s . c o m JSONObject deviceData = new JSONObject(); deviceData.put("Build.DEVICE", Build.DEVICE); deviceData.put("Build.MODEL", Build.MODEL); deviceData.put("Build.PRODUCT", Build.PRODUCT); deviceData.put("Build.VERSION.SDK_INT", Build.VERSION.SDK_INT); deviceData.put("screenResolution.X", size.x); deviceData.put("screenResolution.Y", size.y); jsonObject.put("systemInfo", deviceData); // Write magnetometer data JSONArray magnetData = new JSONArray(); for (int i = 0; i < mSensorData.size(); i++) { JSONArray dataPoint = new JSONArray(); long time = mSensorTime.get(i); dataPoint.put(time); dataPoint.put(mSensorAccuracy.get(i)); float[] data = mSensorData.get(i); for (float d : data) { dataPoint.put(d); } magnetData.put(dataPoint); } jsonObject.put("magnetometer", magnetData); // Write onAccuracyChanged data JSONArray accuracyChangedData = new JSONArray(); for (int i = 0; i < mAccuracyData.size(); i++) { JSONArray dataPoint = new JSONArray(); long time = mAccuracyTime.get(i); dataPoint.put(time); dataPoint.put(mAccuracyData.get(i)); accuracyChangedData.put(dataPoint); } jsonObject.put("onAccuracyChangedData", accuracyChangedData); // Write rotation data if (mRecordRotation) { JSONArray rotationData = new JSONArray(); for (int i = 0; i < mSensorData.size(); i++) { JSONArray dataPoint = new JSONArray(); long time = mRotationTime.get(i); dataPoint.put(time); float[] data = mRotationData.get(i); for (float d : data) { dataPoint.put(d); } rotationData.put(dataPoint); } jsonObject.put("rotation", rotationData); } // Write event labels JSONArray trueLabels = new JSONArray(); for (int i = 0; i < mPositivesData.size(); i++) { JSONArray dataPoint = new JSONArray(); long time = mPositivesTime.get(i); dataPoint.put(time); dataPoint.put(mPositivesData.get(i)); trueLabels.put(dataPoint); } jsonObject.put("labels", trueLabels); try { FileWriter fw = new FileWriter(target, true); fw.write(jsonObject.toString()); fw.flush(); fw.close(); mDumpPath = target.toString(); } catch (IOException e) { Log.e(TAG, e.toString()); } }
From source file:com.flexvdi.androidlauncher.LoginActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mContext = this; try {// w ww. j a v a 2s . c o m GStreamer.init(mContext); } catch (Exception e) { Log.e(TAG, "Can't initialize GStreamer" + e.getMessage()); finish(); } settings = getSharedPreferences("flexVDI", MODE_PRIVATE); settingsEditor = settings.edit(); /* Uncomment this for clearing preferences (useful when debugging) */ //settingsEditor.clear(); //settingsEditor.apply(); //settingsEditor.commit(); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_login); textUser = (EditText) findViewById(R.id.textUser); textServer = (EditText) findViewById(R.id.textServer); textPassword = (EditText) findViewById(R.id.textPassword); goButton = (Button) findViewById(R.id.buttonGO); goButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ConnectivityManager cm = (ConnectivityManager) mContext .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); if (!isConnected) { Toast.makeText(view.getContext(), getResources().getString(R.string.no_network), Toast.LENGTH_LONG).show(); return; } if (checkBoxGenericSpice.isChecked()) { String userField = textUser.getText().toString(); if (userField.length() == 0 || !userField.contains(":")) { Toast.makeText(view.getContext(), getResources().getString(R.string.invalid_spice_server), Toast.LENGTH_LONG).show(); return; } String spiceAddress = userField.substring(0, userField.indexOf(":")); String spicePort = userField.substring(userField.indexOf(":") + 1); if (spiceAddress.length() == 0 || spicePort.length() == 0) { Toast.makeText(view.getContext(), getResources().getString(R.string.invalid_spice_server), Toast.LENGTH_LONG).show(); return; } String spicePassword = textPassword.getText().toString(); settingsEditor.putBoolean("enableSound", checkBoxEnableSound.isChecked()); settingsEditor.putBoolean("staticResolution", checkBoxStaticResolution.isChecked()); settingsEditor.putBoolean("genericSpice", checkBoxGenericSpice.isChecked()); settingsEditor.putString("flexServerName", textServer.getText().toString()); settingsEditor.putString("spice_address", spiceAddress); settingsEditor.putString("spice_port", spicePort); settingsEditor.putString("spice_password", spicePassword); settingsEditor.putBoolean("use_ws", false); settingsEditor.apply(); settingsEditor.commit(); startMainActivity(); } else { if (textServer.getText().length() == 0) { Toast.makeText(view.getContext(), getResources().getString(R.string.empty_flexvdi_server), Toast.LENGTH_LONG).show(); } else { if (textUser.getText().length() != 0 && textPassword.getText().length() != 0) { new RequestTask().execute("authmode", textServer.getText().toString(), textUser.getText().toString(), textPassword.getText().toString(), ""); } else Toast.makeText(view.getContext(), getResources().getString(R.string.empty_credentials), Toast.LENGTH_LONG).show(); } } } }); // The advanced settings button. checkBoxAdvancedOptions = (CheckBox) findViewById(R.id.checkBoxAdvancedSettings); layoutAdvancedOptions = (LinearLayout) findViewById(R.id.layoutAdvancedOptions2); checkBoxAdvancedOptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { if (checked) layoutAdvancedOptions.setVisibility(View.VISIBLE); else layoutAdvancedOptions.setVisibility(View.GONE); } }); textServer.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View field, boolean hasFocus) { if (!hasFocus && checkBoxGenericSpice.isChecked()) { if (textUser.getText().toString().length() == 0) { textUser.setText(textServer.getText()); } } } }); checkBoxEnableSound = (CheckBox) findViewById(R.id.checkBoxEnableSound); if (settings.getBoolean("enableSound", true)) { checkBoxEnableSound.setChecked(true); } else { checkBoxEnableSound.setChecked(false); } if (!settings.contains("staticResolution")) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); if ((size.x + size.y) > 2340) { /* 2340 = 1440+900 */ settingsEditor.putBoolean("staticResolution", true); } else { settingsEditor.putBoolean("staticResolution", false); } settingsEditor.apply(); settingsEditor.commit(); } checkBoxStaticResolution = (CheckBox) findViewById(R.id.checkBoxStaticResolution); if (settings.getBoolean("staticResolution", true)) { checkBoxStaticResolution.setChecked(true); } else { checkBoxStaticResolution.setChecked(false); } checkBoxGenericSpice = (CheckBox) findViewById(R.id.checkBoxGenericSpice); if (settings.getBoolean("genericSpice", false)) { checkBoxGenericSpice.setChecked(true); checkBoxAdvancedOptions.setChecked(true); layoutAdvancedOptions.setVisibility(View.VISIBLE); if (settings.contains("flexServerName")) { textServer.setText(settings.getString("flexServerName", "")); textUser.setText(settings.getString("flexServerName", "")); textServer.setHint(getResources().getString(R.string.spice_server)); textUser.setHint(getResources().getString(R.string.spice_server_port)); } } else { checkBoxGenericSpice.setChecked(false); if (settings.contains("flexServerName")) { textServer.setText(settings.getString("flexServerName", "")); layoutAdvancedOptions.setVisibility(View.GONE); } else { textServer.setText("manager.flexvdi.com"); checkBoxAdvancedOptions.setChecked(true); } } checkBoxGenericSpice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { if (checked) { textServer.setHint(getResources().getString(R.string.spice_server)); textUser.setHint(getResources().getString(R.string.spice_server_port)); String server = textServer.getText().toString(); if (server.length() != 0) { if (server.contains(":")) { textUser.setText(server); } else { textUser.setText(server + ":5900"); textServer.setText(server + ":5900"); } } } else { textServer.setHint(getResources().getString(R.string.flexvdi_server)); String server = textServer.getText().toString(); if (server.length() != 0 && server.contains(":")) { textServer.setText(server.substring(0, server.indexOf(":"))); } textUser.setText(""); textUser.setHint(getResources().getString(R.string.user)); } } }); deviceID = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID); textViewDeviceID = (TextView) findViewById(R.id.textViewDeviceID); textViewDeviceID.setText("ID: " + deviceID + " (" + BuildConfig.VERSION_NAME + ")"); try { HttpsURLConnection.setDefaultHostnameVerifier(new NullHostNameVerifier()); SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new X509TrustManager[] { new NullX509TrustManager() }, new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); } catch (NoSuchAlgorithmException nsae) { Log.e(TAG, nsae.getMessage()); } catch (KeyManagementException kme) { Log.e(TAG, kme.getMessage()); } }
From source file:com.echlabsw.android.drawertab.MainActivity.java
@TargetApi(13) @SuppressWarnings("deprecation") private int getDisplayPxWidth() { Display display = getWindowManager().getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size);/*from ww w . j a v a 2s . c om*/ return size.x; } else { return display.getWidth(); } }
From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java
/** * ???X?/* ww w . j a v a 2 s.c o m*/ * * @return */ private int getMarqueeStartX() { final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); final Display display = wm.getDefaultDisplay(); final Point size = new Point(); display.getSize(size); final int measureText = (int) mTextPaint.measureText(mText); final int measureWidth = getMeasuredWidth(); if (size.x == measureWidth) { return measureWidth; } else if (measureText > size.x) { // ???? return size.x; } else if (measureWidth > measureText) { return measureWidth; } else { return measureText; } }
From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java
/*** * Hide the searchbox using the circle animation. Can be called regardless of result list length * @param activity Activity/*w w w .j a v a2s .c o m*/ */ public void hideCircularly(Activity activity) { Display display = activity.getWindowManager().getDefaultDisplay(); Point size = new Point(); final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView() .findViewById(android.R.id.content); RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root); display.getSize(size); Resources r = getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics()); int cx = layout.getLeft() + layout.getRight(); int cy = layout.getTop(); int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px); SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, cx, cy, 0, finalRadius); animator.setInterpolator(new ReverseInterpolator()); animator.setDuration(500); animator.start(); animator.addListener(new SupportAnimator.AnimatorListener() { @Override public void onAnimationStart() { } @Override public void onAnimationEnd() { setVisibility(View.GONE); } @Override public void onAnimationCancel() { } @Override public void onAnimationRepeat() { } }); }
From source file:com.nextgis.mobile.fragment.LayersFragment.java
/** * Users of this fragment must call this method to set up the navigation drawer interactions. * * @param fragmentId//w w w . java2 s .co m * The android:id of this fragment in its activity's layout. * @param drawerLayout * The DrawerLayout containing this fragment's UI. */ public void setUp(int fragmentId, DrawerLayout drawerLayout, final MapDrawable map) { MainActivity activity = (MainActivity) getActivity(); mFragmentContainerView = activity.findViewById(fragmentId); Display display = activity.getWindowManager().getDefaultDisplay(); int displayWidth; if (android.os.Build.VERSION.SDK_INT >= 13) { Point size = new Point(); display.getSize(size); displayWidth = size.x; } else { displayWidth = display.getWidth(); } ViewGroup.LayoutParams params = mFragmentContainerView.getLayoutParams(); if (params.width >= displayWidth) { params.width = (int) (displayWidth * 0.8); } mFragmentContainerView.setLayoutParams(params); final MapFragment mapFragment = activity.getMapFragment(); mListAdapter = new LayersListAdapter(activity, mapFragment.mMap); mListAdapter.setDrawer(drawerLayout); mListAdapter.setOnPencilClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!mapFragment.hasEdits()) { if (mapFragment.mFinishListener != null) mapFragment.mFinishListener.onClick(null); return; } AlertDialog builder = new AlertDialog.Builder(getContext()).setTitle(R.string.save) .setMessage(R.string.has_edits) .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mapFragment.saveEdits(); mapFragment.setMode(MapFragment.MODE_NORMAL); } }).setNegativeButton(R.string.discard, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mapFragment.cancelEdits(); mapFragment.setMode(MapFragment.MODE_NORMAL); } }).create(); builder.show(); } }); mListAdapter.setOnLayerEditListener(new LayersListAdapter.onEdit() { @Override public void onLayerEdit(ILayer layer) { IGISApplication application = (IGISApplication) getActivity().getApplication(); application.sendEvent(GA_LAYER, GA_EDIT, GA_MENU); mapFragment.onFinishChooseLayerDialog(MapFragment.EDIT_LAYER, layer); toggle(); } }); mapFragment.setOnModeChangeListener(new MapFragment.onModeChange() { @Override public void onModeChangeListener() { mListAdapter.notifyDataSetChanged(); } }); mLayersListView = (ReorderedLayerView) mFragmentContainerView.findViewById(R.id.layer_list); mLayersListView.setAdapter(mListAdapter); mLayersListView.setDrawer(drawerLayout); mDrawerLayout = drawerLayout; // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener // ActionBarDrawerToggle ties together the the proper interactions // between the navigation drawer and the action bar app icon. mDrawerToggle = new ActionBarDrawerToggle(getActivity(), // host Activity mDrawerLayout, // DrawerLayout object // R.drawable.ic_drawer, // nav drawer image to replace 'Up' caret R.string.layers_drawer_open, // "open drawer" description for accessibility R.string.layers_drawer_close // "close drawer" description for accessibility ) { @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); if (!isAdded()) { return; } getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); if (!isAdded()) { return; } setupSyncOptions(); getActivity().supportInvalidateOptionsMenu(); // calls onPrepareOptionsMenu() } }; // Defer code dependent on restoration of previous instance state. syncState(); }