List of usage examples for android.view Display getHeight
@Deprecated public int getHeight()
From source file:github.popeen.dsub.fragments.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { rootView = inflater.inflate(R.layout.download, container, false); setTitle(R.string.button_bar_now_playing); WindowManager w = context.getWindowManager(); Display d = w.getDefaultDisplay(); swipeDistance = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; swipeVelocity = (d.getWidth() + d.getHeight()) * PERCENTAGE_OF_SCREEN_FOR_SWIPE / 100; gestureScanner = new GestureDetector(this); playlistFlipper = (ViewFlipper) rootView.findViewById(R.id.download_playlist_flipper); emptyTextView = (TextView) rootView.findViewById(R.id.download_empty); songTitleTextView = (TextView) rootView.findViewById(R.id.download_song_title); albumArtImageView = (ImageView) rootView.findViewById(R.id.download_album_art_image); positionTextView = (TextView) rootView.findViewById(R.id.download_position); durationTextView = (TextView) rootView.findViewById(R.id.download_duration); statusTextView = (TextView) rootView.findViewById(R.id.download_status); progressBar = (SeekBar) rootView.findViewById(R.id.download_progress_bar); previousButton = (AutoRepeatButton) rootView.findViewById(R.id.download_previous); nextButton = (AutoRepeatButton) rootView.findViewById(R.id.download_next); rewindButton = (AutoRepeatButton) rootView.findViewById(R.id.download_rewind); fastforwardButton = (AutoRepeatButton) rootView.findViewById(R.id.download_fastforward); pauseButton = rootView.findViewById(R.id.download_pause); stopButton = rootView.findViewById(R.id.download_stop); startButton = rootView.findViewById(R.id.download_start); repeatButton = (ImageButton) rootView.findViewById(R.id.download_repeat); bookmarkButton = (ImageButton) rootView.findViewById(R.id.download_bookmark); rateBadButton = (ImageButton) rootView.findViewById(R.id.download_rating_bad); rateGoodButton = (ImageButton) rootView.findViewById(R.id.download_rating_good); playbackSpeedButton = (ImageButton) rootView.findViewById(R.id.download_playback_speed); toggleListButton = rootView.findViewById(R.id.download_toggle_list); playlistView = (RecyclerView) rootView.findViewById(R.id.download_list); FastScroller fastScroller = (FastScroller) rootView.findViewById(R.id.download_fast_scroller); fastScroller.attachRecyclerView(playlistView); setupLayoutManager(playlistView, false); ItemTouchHelper touchHelper = new ItemTouchHelper(new DownloadFileItemHelperCallback(this, true)); touchHelper.attachToRecyclerView(playlistView); starButton = (ImageButton) rootView.findViewById(R.id.download_star); if (Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_MENU_STAR, true)) { starButton.setOnClickListener(new OnClickListener() { @Override//from w w w. j a v a 2 s. co m public void onClick(View v) { getDownloadService().toggleStarred(); setControlsVisible(true); } }); } else { starButton.setVisibility(View.GONE); } View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { return gestureScanner.onTouchEvent(me); } }; pauseButton.setOnTouchListener(touchListener); stopButton.setOnTouchListener(touchListener); startButton.setOnTouchListener(touchListener); bookmarkButton.setOnTouchListener(touchListener); rateBadButton.setOnTouchListener(touchListener); rateGoodButton.setOnTouchListener(touchListener); playbackSpeedButton.setOnTouchListener(touchListener); emptyTextView.setOnTouchListener(touchListener); albumArtImageView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { lastY = (int) me.getRawY(); } return gestureScanner.onTouchEvent(me); } }); previousButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().previous(); return null; } }.execute(); setControlsVisible(true); } }); previousButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(true); } }); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Boolean>(context) { @Override protected Boolean doInBackground() throws Throwable { getDownloadService().next(); return true; } }.execute(); setControlsVisible(true); } }); nextButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(false); } }); rewindButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { changeProgress(true); } }); rewindButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(true); } }); fastforwardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { changeProgress(false); } }); fastforwardButton.setOnRepeatListener(new Runnable() { public void run() { changeProgress(false); } }); pauseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().pause(); return null; } }.execute(); } }); stopButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().reset(); return null; } }.execute(); } }); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { warnIfStorageUnavailable(); new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { start(); return null; } }.execute(); } }); repeatButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { RepeatMode repeatMode = getDownloadService().getRepeatMode().next(); getDownloadService().setRepeatMode(repeatMode); switch (repeatMode) { case OFF: Util.toast(context, R.string.download_repeat_off); break; case ALL: Util.toast(context, R.string.download_repeat_all); break; case SINGLE: Util.toast(context, R.string.download_repeat_single); break; default: break; } updateRepeatButton(); setControlsVisible(true); } }); bookmarkButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { createBookmark(); setControlsVisible(true); } }); rateBadButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } downloadService.toggleRating(1); setControlsVisible(true); } }); rateGoodButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { DownloadService downloadService = getDownloadService(); if (downloadService == null) { return; } downloadService.toggleRating(5); setControlsVisible(true); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setPlaybackSpeed(); } else { playbackSpeedButton.setVisibility(View.GONE); } toggleListButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleFullscreenAlbumArt(); setControlsVisible(true); } }); View overlay = rootView.findViewById(R.id.download_overlay_buttons); final int overlayHeight = overlay != null ? overlay.getHeight() : -1; albumArtImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (overlayHeight == -1 || lastY < (view.getBottom() - overlayHeight)) { toggleFullscreenAlbumArt(); setControlsVisible(true); } } }); progressBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(final SeekBar seekBar) { new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { getDownloadService().seekTo(progressBar.getProgress()); return null; } @Override protected void done(Void result) { seekInProgress = false; } }.execute(); } @Override public void onStartTrackingTouch(final SeekBar seekBar) { seekInProgress = true; } @Override public void onProgressChanged(final SeekBar seekBar, final int position, final boolean fromUser) { if (fromUser) { positionTextView.setText(Util.formatDuration(position / 1000)); setControlsVisible(true); } DownloadService downloadService = getDownloadService(); TextView textTimer = (TextView) context.findViewById(R.id.textTimer); if (downloadService != null && downloadService.getSleepTimer()) { int timeRemaining = downloadService.getSleepTimeRemaining(); textTimer.setText(context.getResources().getString(R.string.download_stop_time_remaining, Util.formatDuration(timeRemaining))); if (timeRemaining > 0) { textTimer.setVisibility(View.VISIBLE); } else { textTimer.setVisibility(View.GONE); } } else { if (textTimer != null) { textTimer.setVisibility(View.GONE); } } } }); return rootView; }
From source file:com.segma.trim.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MobileAds.initialize(getApplicationContext(), ADMOB_KEY); setContentView(R.layout.activity_main); loadAds();//from w ww . j a v a 2 s.c om MEMORY_SIZE = ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).getMemoryClass(); MAX_BITMAP_PIXELS = calculateMaxBitmapPixels(); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); ipv = (ImageProcessingView) findViewById(R.id.ipv); loadLicense(); loadUserSetting(); final Runnable runnableOnTextView = new Runnable() { @Override public void run() { ipv.setVisibility(View.VISIBLE); // TODO: update pending: the image enlarges due to larger space rawBitmap = getSampleImage(); rawBitmapWidth = rawBitmap.getWidth(); rawBitmapHeight = rawBitmap.getHeight(); STATE = STATE_PROCESSING_IMAGE; textView.setVisibility(View.GONE); ipv.process(rawBitmap); } }; Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(size); screenWidth = size.x; screenHeight = size.y; } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); screenWidth = display.getWidth(); screenHeight = display.getHeight(); } initControls(); textView = (TextView) findViewById(R.id.tv_message); textView.setEnabled(false); ViewTreeObserver viewTreeObserver = ipv.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ImageProcessingViewWidth = ipv.getWidth(); ImageProcessingViewHeight = ipv.getHeight(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { ipv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } else { ipv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } if (ImageProcessingViewHeight != 0) textView.setEnabled(true); } }); } textView.setText(MESSAGE_STARTUP); textView.setOnTouchListener(new View.OnTouchListener() { float original_text_size; @Override public boolean onTouch(View v, final MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: original_text_size = textView.getTextSize(); //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Math.round(original_text_size * 1.15)); handlerOnTextView.postDelayed(runnableOnTextView, LONG_PRESS_TIME_ON_TEXTVIEW); textView.setEnabled(false); break; case MotionEvent.ACTION_MOVE: handlerOnTextView.removeCallbacks(runnableOnTextView); break; case MotionEvent.ACTION_UP: //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, original_text_size); handlerOnTextView.removeCallbacks(runnableOnTextView); v.setEnabled(true); break; } return false; } }); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); actionBar = getSupportActionBar(); //actionBar.setDisplayHomeAsUpEnabled(true); ipv.setVisibility(View.INVISIBLE); if (MODE_DEBUG) { LICENSE = LICENSE_PREMIUM; getPackageManager().clearPackagePreferredActivities(getApplicationContext().getPackageName()); } }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Gets the current orientation.//w w w . j av a2 s .co m * * @param context * @return {@link es.javocsoft.android.lib.toolbox.ToolBox.SCREEN_ORIENTATION} */ @SuppressWarnings("deprecation") public static SCREEN_ORIENTATION screen_getOrientation(Context context) { SCREEN_ORIENTATION res = SCREEN_ORIENTATION.PORTRAIT; Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); //int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) { res = SCREEN_ORIENTATION.SQUARE; //orientation = Configuration.ORIENTATION_SQUARE; } else { if (display.getWidth() < display.getHeight()) { res = SCREEN_ORIENTATION.PORTRAIT; //orientation = Configuration.ORIENTATION_PORTRAIT; } else { res = SCREEN_ORIENTATION.LANDSCAPE; //orientation = Configuration.ORIENTATION_LANDSCAPE; } } return res; }
From source file:com.youku.player.base.YoukuBasePlayerActivity.java
private boolean isLand() { Display getOrient = getWindowManager().getDefaultDisplay(); return getOrient.getWidth() > getOrient.getHeight(); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Gets the device screen size in pixels. * /* w ww. j a v a 2 s .co m*/ * @param context * @return */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public static Point device_screenSize(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final Point size = new Point(); try { display.getSize(size); } catch (NoSuchMethodError ignore) { // Older device size.x = display.getWidth(); size.y = display.getHeight(); } return size; }
From source file:com.plusot.senselib.SenseMain.java
private void adjustViews() { vgs = new ViewGroup[4]; vgs[0] = (ViewGroup) findViewById(R.id.double1); vgs[1] = (ViewGroup) findViewById(R.id.double2); vgs[2] = (ViewGroup) findViewById(R.id.double3); vgs[3] = (ViewGroup) findViewById(R.id.double4); int devider = 1; if (this.viewsAdded <= 4) { if (map == null) { if (vgs[3].getChildCount() == 0 && vgs[1].getChildCount() == 2) { View view = vgs[1].getChildAt(1); vgs[1].removeView(view); vgs[3].addView(view);/*from w w w . ja va 2 s. co m*/ } if (vgs[2].getChildCount() == 0 && vgs[0].getChildCount() == 2) { View view = vgs[0].getChildAt(1); vgs[0].removeView(view); vgs[2].addView(view); } } else { if (vgs[3].getChildCount() == 1 && vgs[1].getChildCount() == 1) { View view = vgs[3].getChildAt(0); vgs[3].removeView(view); vgs[1].addView(view); } if (vgs[2].getChildCount() == 1 && vgs[0].getChildCount() == 1) { View view = vgs[2].getChildAt(0); vgs[2].removeView(view); vgs[0].addView(view); } } } for (int i = 0; i < 4; i++) { if (vgs[i].getChildCount() > 0) { devider = i + 1; vgs[i].setVisibility(View.VISIBLE); } else vgs[i].setVisibility(View.GONE); } LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f / devider); for (int i = 0; i < 4; i++) vgs[i].setLayoutParams(params); Display display = getWindowManager().getDefaultDisplay(); @SuppressWarnings("deprecation") int w = display.getWidth(); @SuppressWarnings("deprecation") int h = display.getHeight(); //LLog.d(Globals.TAG, CLASSTAG + " Size = " + w + " x " + h); for (int i = 0; i < 8; i++) { if (map == null) { View view = findViewById(i + VIEW_ID_BASE); if (view == null) continue; params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.setMargins(1, 1, 1, 1); view.setBackgroundResource(R.drawable.round_border); view.setLayoutParams(params); } else { int x = w / 10; if (w < 500) x = w / 40; int y = h / 6; switch (devider) { case 1: y = h / 6 + h / 2; break; case 2: y = h / 6; break; case 3: y = h / 8; break; case 4: y = h / 10; break; } View view = null; switch (i) { case 0: view = vgs[0].getChildAt(0); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (vgs[0].getChildCount() == 1) params.setMargins(0, 0, 0, y); else params.setMargins(0, 0, x, y); break; case 1: view = vgs[0].getChildAt(1); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.setMargins(x, 0, 0, y); break; case 2: view = vgs[1].getChildAt(0); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (devider > 2) { if (vgs[1].getChildCount() == 1) params.setMargins(0, y, x + w / 2, 0); else params.setMargins(0, y / 2, x, y / 2); } else if (vgs[1].getChildCount() == 1) params.setMargins(0, y, 0, 0); else params.setMargins(0, y, x, 0); break; case 3: view = vgs[1].getChildAt(1); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (devider > 2) params.setMargins(x, y / 2, 0, y / 2); else params.setMargins(x, y, 0, 0); break; case 4: view = vgs[2].getChildAt(0); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (devider > 3) { if (vgs[2].getChildCount() == 1) params.setMargins(0, y, x + w / 2, 0); else params.setMargins(0, y / 2, x, y / 2); } else if (vgs[2].getChildCount() == 1) params.setMargins(0, y, 0, 0); else params.setMargins(0, y, x, 0); break; case 5: view = vgs[2].getChildAt(1); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (devider > 3) params.setMargins(x, y / 2, 0, y / 2); else params.setMargins(x, y, 0, 0); break; case 6: view = vgs[3].getChildAt(0); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); if (vgs[3].getChildCount() == 1) params.setMargins(0, y, 0, 0); else params.setMargins(0, y, x, 0); break; case 7: view = vgs[3].getChildAt(1); if (view == null) break; params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.setMargins(x, y, 0, 0); break; } if (view != null) { view.setLayoutParams(params); view.setBackgroundResource(R.drawable.transparent_border); } } //View v = view.findViewById(R.id.graph_view_layout); } }
From source file:net.robotmedia.acv.ui.widget.OcrLayout.java
/** Updates screenWidth and screenHeight. */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") private void determineScreenDimensions(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT >= 19) { // Get the total size of the screen (because on android 4.4 and // above we use immersive mode to hide the navigation bar). DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getRealMetrics(metrics); this.screenWidth = metrics.widthPixels; this.screenHeight = metrics.heightPixels; } else if (android.os.Build.VERSION.SDK_INT >= 13) { // Get the size of the screen minus the height of the navigation bar Point size = new Point(); display.getSize(size);/*from w w w . ja v a 2 s.c o m*/ this.screenWidth = size.x; this.screenHeight = size.y; } else { // Get the size of the screen minus the height of the navigation bar (old method) this.screenWidth = display.getWidth(); // deprecated this.screenHeight = display.getHeight(); // deprecated } }
From source file:org.telegram.ui.ChatActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);/*from w w w. ja v a2s. c o m*/ Display display = parentActivity.getWindowManager().getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT < 13) { displaySize.set(display.getWidth(), display.getHeight()); } else { display.getSize(displaySize); } }
From source file:org.telegram.ui.ChatActivity.java
@Override public void onConfigurationChanged(android.content.res.Configuration newConfig) { super.onConfigurationChanged(newConfig); fixLayout();//from ww w . j a v a 2 s .c om if (parentActivity != null) { Display display = parentActivity.getWindowManager().getDefaultDisplay(); if (android.os.Build.VERSION.SDK_INT < 13) { displaySize.set(display.getWidth(), display.getHeight()); } else { display.getSize(displaySize); } } }