List of usage examples for android.view Display getSize
public void getSize(Point outSize)
From source file:com.wheelphone.remotemini.WheelphoneRemoteMini.java
public void onCreate(Bundle savedInstanceState) { if (debugUsbComm) { logString = TAG + ": onCreate"; Log.d(TAG, logString);// w ww . j a va 2 s .c o m appendLog("debugUsbComm.txt", logString, false); } super.onCreate(savedInstanceState); setContentView(R.layout.main); camera = (SurfaceView) findViewById(R.id.smallcameraview); context = this.getApplicationContext(); line1 = (TextView) findViewById(R.id.line1); line2 = (TextView) findViewById(R.id.line2); version = (TextView) findViewById(R.id.version); signWifi = (TextView) findViewById(R.id.advice); signStreaming = (TextView) findViewById(R.id.streaming); signInformation = (LinearLayout) findViewById(R.id.information); pulseAnimation = AnimationUtils.loadAnimation(this, R.anim.pulse); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); settings.registerOnSharedPreferenceChangeListener(this); camera.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); holder = camera.getHolder(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "com.wheelphone.remotemini.wakelock"); httpServer = new CustomHttpServer(8080, this.getApplicationContext(), handler); soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { soundPool.play(sampleId, 0.99f, 0.99f, 1, 0, 1); } }); timerImg = new Timer(); intent = new Intent(context, FrontImageActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //startActivity(intent); // Query the QCAR initialization flags: mQCARFlags = getInitializationFlags(); // Update the application status to start initializing application updateApplicationStatus(APPSTATUS_INIT_APP); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); updateRendering(size.x, size.y); btnStart = (Button) findViewById(R.id.btnStart); //Make sure that the app stays open: getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); wheelphone = new WheelphoneRobot(getApplicationContext(), getIntent()); wheelphone.enableSpeedControl(); wheelphone.setWheelPhoneRobotListener(this); }
From source file:com.miz.functions.MizLib.java
public static String getImageUrlSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 300) return "w500"; else if (columnWidth > 185) return "w300"; }/*from w w w . ja v a2 s .co m*/ return "w185"; }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
public void setUpWindow() { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Params for the window. // You can easily set the alpha and the dim behind the window from here WindowManager.LayoutParams params = getWindow().getAttributes(); params.alpha = 1.0f; // lower than one makes it more transparent params.dimAmount = .6f; // set it higher if you want to dim behind the window getWindow().setAttributes(params);/*from w w w. ja va 2 s. c om*/ getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(android.R.color.transparent))); // Gets the display size so that you can set the window to a percent of that Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // You could also easily used an integer value from the shared preferences to set the percent if (height > width) { getWindow().setLayout((int) (width * .9), (int) (height * .9)); } else { getWindow().setLayout((int) (width * .7), (int) (height * .8)); } }
From source file:com.miz.functions.MizLib.java
public static String getActorUrlSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 400) return "h632"; if (columnWidth >= 300) return "w300"; }//from w w w . j a v a2s .com return "w185"; }
From source file:com.miz.functions.MizLib.java
public static int getThumbnailSize(Context c) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; if (columnWidth > 320) return 440; else if (columnWidth > 240) return 320; else if (columnWidth > 180) return 240; }//from w w w .jav a 2 s . c o m return 180; }
From source file:com.miz.functions.MizLib.java
public static void resizeBitmapFileToCoverSize(Context c, String filepath) { final int mImageThumbSize = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size); final int mImageThumbSpacing = c.getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing); WindowManager window = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display d = window.getDefaultDisplay(); Point size = new Point(); d.getSize(size); final int numColumns = (int) Math.floor(Math.max(size.x, size.y) / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { final int columnWidth = (Math.max(size.x, size.y) / numColumns) - mImageThumbSpacing; int imageWidth = 0; if (columnWidth > 300) imageWidth = 500;// w ww .j a va2 s .c o m else if (columnWidth > 240) imageWidth = 320; else if (columnWidth > 180) imageWidth = 240; else imageWidth = 180; if (new File(filepath).exists()) try { Bitmap bm = decodeSampledBitmapFromFile(filepath, imageWidth, (int) (imageWidth * 1.5)); bm = Bitmap.createScaledBitmap(bm, imageWidth, (int) (imageWidth * 1.5), true); FileOutputStream out = new FileOutputStream(filepath); bm.compress(Bitmap.CompressFormat.JPEG, 90, out); out.close(); bm.recycle(); } catch (Exception e) { } } }
From source file:com.paramonod.kikos.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); FirebaseDatabase.getInstance().setPersistenceEnabled(true); myRef = FirebaseDatabase.getInstance().getReference("Shops"); //ShopInterface shopInterface = new ShopInterface("asas","qaqa","wdwdwd","12","11","11"); //myRef.child("Shops").child("1").setValue(shopInterface); //mAuth.signInAnonymously(); myRef.keepSynced(true);//from w w w.jav a 2 s . c om myRef.orderByValue().addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot snapshot, String previousChild) { Log.e("here", Integer.toString(shopInterfaces.size() - 1)); shopInterfaces.add(snapshot.getValue(ShopInterface.class)); Log.e("here", Integer.toString(shopInterfaces.size() - 1)); main.setupMap(); //System.out.println(shopInterfaces.get(1).getCoordX()); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String s) { } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public void onCancelled(DatabaseError databaseError) { } }); //mAuth.signOut(); main = this; setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setTitle("OrgShop"); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); final Display display = getWindowManager().getDefaultDisplay(); android.graphics.Point size = new android.graphics.Point(); display.getSize(size); X = size.x; Y = size.y; // Y = displaymetrics.heightPixels; // X = displaymetrics.widthPixels; System.out.println(X + " " + Y); // Adding Toolbar to Main screen int ii = 0; places.clear(); while (true) { String connectionsJSONString = getPreferences(MODE_PRIVATE).getString("places" + ii, null); Pair p = new Gson().fromJson(connectionsJSONString, Pair.class); if (p != null) places.add(p); else break; ii++; } placesIDX = ii; bottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation); Manager.findFragmentById(R.id.fragment1); bottomNavigationView .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { //AsyncTask asyncTask = new NewAsyncTask(); switch (item.getItemId()) { case R.id.Map: // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); Manager.beginTransaction().replace(R.id.fragment1, MapFr).addToBackStack("Map") .commit(); //asyncTask.execute(R.id.Map); break; case R.id.Shops: // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); // Listfr.flag = 0; Manager.beginTransaction().replace(R.id.fragment1, CatFr).addToBackStack("Categories") .commit(); //x = R.id.Shops; //asyncTask.execute(); break; case R.id.Third: // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); // System.out.println(0); int idx[] = new int[shopInterfaces.size()]; for (int i = 0; i < idx.length; i++) { idx[i] = i; } try { updateMyLoc(); idx = sortArraywithGeo(idx, myLoc); } catch (Exception e) { e.printStackTrace(); } CardContentFragment.flag = 1; CardContentFragment.idx = idx; Manager.beginTransaction().replace(R.id.fragment1, Cardfr).addToBackStack(null) .commit(); //new ImageLoad().execute(); //while (AsyncTest == 0){} //System.out.println(1); //Picturex(); //AsyncTest = -1; /* Manager.beginTransaction() .replace(R.id.fragment1, Listfr) .commit(); */ // asyncTask.execute(R.id.Third); break; } return false; } }); // Setting ViewPager for each Tabs // Set Tabs inside Toolbar // Create Navigation drawer and inlfate layout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); // Adding menu icon to Toolbar ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { VectorDrawableCompat indicator = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme()); indicator.setTint(ResourcesCompat.getColor(getResources(), R.color.white, getTheme())); supportActionBar.setHomeAsUpIndicator(indicator); supportActionBar.setDisplayHomeAsUpEnabled(true); } //Set behavior of Navigation drawer navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setCheckedItem(R.id.mapButton); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { // Set item in checked state menuItem.setChecked(true); if (menuItem.getItemId() == R.id.favorite_button) { sPref = getPreferences(MODE_PRIVATE); String savedText = sPref.getString("q", ""); boolean w = true; for (int i = 0; i < 10; i++) { if (savedText.contains(Integer.toString(i))) { w = false; } } if (w) { Toast.makeText(main, " ? ", Toast.LENGTH_LONG).show(); SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); editor.putString("q", ""); editor.commit(); } else { String[] q = savedText.split(" "); int[] a = new int[q.length]; for (int i = 0; i < q.length; i++) { a[i] = Integer.parseInt(q[i]); System.out.println(a[i]); } try { updateMyLoc(); a = sortArraywithGeo(a, myLoc); } catch (Exception e) { e.printStackTrace(); } ListContentFragment l = new ListContentFragment(); l.flag = 1; l.idx = a; // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); Manager.beginTransaction().replace(R.id.fragment1, l).addToBackStack("favorite").commit(); } } if (menuItem.getItemId() == R.id.mapButton) { // Manager.beginTransaction() // .replace(R.id.fragment1, PrFr) // .commit(); Manager.beginTransaction().replace(R.id.fragment1, MapFr).addToBackStack("map").commit(); } if (menuItem.getItemId() == R.id.clear_button) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("").setMessage( "? ? ?? ? ? aka KiKoS, aka paramomnod") .setIcon(R.drawable.itkerk).setCancelable(false) .setNegativeButton(" :)", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } if (menuItem.getItemId() == R.id.login_button) { int ii = 0; places.clear(); while (true) { String connectionsJSONString = getPreferences(MODE_PRIVATE).getString("places" + ii, null); Pair p = new Gson().fromJson(connectionsJSONString, Pair.class); if (p != null) places.add(p); else break; ii++; } if (places.size() == 0) { Toast.makeText(main, " ? ?", Toast.LENGTH_LONG).show(); } else { String q[] = new String[places.size()]; for (int i = 0; i < q.length; i++) { q[i] = places.get(i).first; } new AlertDialog.Builder(main).setSingleChoiceItems(q, 0, null) .setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); int selectedPosition = ((AlertDialog) dialog).getListView() .getCheckedItemPosition(); Pair p = places.get(selectedPosition); GeoPoint geo = p.second; int[] idx = new int[shopInterfaces.size()]; for (int i = 0; i < idx.length; i++) { idx[i] = i; } idx = sortArraywithGeo(idx, geo); CardContentFragment c = new CardContentFragment(); CardContentFragment.flag = 1; CardContentFragment.idx = idx; Manager.beginTransaction().replace(R.id.fragment1, c).addToBackStack("map") .commit(); } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); int selectedPosition = ((AlertDialog) dialog).getListView() .getCheckedItemPosition(); places.remove(selectedPosition); placesIDX--; for (int i = 0; i < placesIDX; i++) { SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); String connectionsJSONString1 = new Gson().toJson(places.get(i)); editor.putString("places" + i, connectionsJSONString1); editor.commit(); } SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit(); editor.putString("places" + placesIDX, null); editor.commit(); } }).show(); } } /* if (menuItem.getItemId() == R.id.login_button) { if (mAuth.getCurrentUser() == null) { startActivity(new Intent(MainActivity.this, LoginActivity.class)); } else { startActivity(new Intent(MainActivity.this, AccountActivity.class)); } } */ // Closing drawer on item click mDrawerLayout.closeDrawers(); return true; } }); // Adding Floating Action Button to bottom right of main view /*FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Snackbar.make(v, "Hello Snackbar!", Snackbar.LENGTH_LONG).show(); } });*/ Manager.beginTransaction().replace(R.id.fragment1, MapFr).commit(); }
From source file:app.sunstreak.yourpisd.MainActivity.java
public int screenHeight() { WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.x; }
From source file:app.sunstreak.yourpisd.MainActivity.java
public int screenWidth() { WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size.y; }
From source file:nu.yona.app.ui.YonaActivity.java
/** * @param position position of tab in number * @return View to display for tab./* w w w . j a v a2s . c o m*/ */ private View getTabView(int position) { View v = LayoutInflater.from(this).inflate(R.layout.bottom_tab_item, null); Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width / TOTAL_TABS, LinearLayout.LayoutParams.MATCH_PARENT); v.setLayoutParams(lp); ImageView img = (ImageView) v.findViewById(R.id.tab_image); switch (position) { case 0: img.setImageResource(R.drawable.dashboard_selector); v.setTag(R.string.dashboard); break; case 1: img.setImageResource(R.drawable.friends_selector); v.setTag(R.string.friends); break; case 2: img.setImageResource(R.drawable.challenges_selector); v.setTag(R.string.challenges); break; case 3: img.setImageResource(R.drawable.settings_selector); v.setTag(R.string.settings); break; default: break; } final int LEFT_RIGHT_MARGIN = getResources().getInteger(R.integer.tab_item_margin_left_right); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.setMargins(LEFT_RIGHT_MARGIN, 0, LEFT_RIGHT_MARGIN, 0); params.gravity = Gravity.CENTER_HORIZONTAL; v.setLayoutParams(params); return v; }