Example usage for android.view Display getHeight

List of usage examples for android.view Display getHeight

Introduction

In this page you can find the example usage for android.view Display getHeight.

Prototype

@Deprecated
public int getHeight() 

Source Link

Usage

From source file:com.google.android.apps.mytracks.fragments.MarkerDetailFragment.java

/**
 * Updates the UI.//from   w  ww . j  a va2s. co  m
 */
@SuppressWarnings("deprecation")
private void updateUi() {
    View waypointView = getView().findViewById(R.id.marker_detail_waypoint);
    View statisticsView = getView().findViewById(R.id.marker_detail_statistics);

    boolean isWaypoint = waypoint.getType() == WaypointType.WAYPOINT;
    waypointView.setVisibility(isWaypoint ? View.VISIBLE : View.GONE);
    statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE);

    if (isWaypoint) {
        String photoUrl = waypoint.getPhotoUrl();
        boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
        photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
        textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
        waypointInfo.setVisibility(View.VISIBLE);

        if (hasPhoto) {
            handler.removeCallbacks(hideText);
            Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay();
            PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(),
                    defaultDisplay.getHeight(), true);
            handler.postDelayed(hideText, HIDE_TEXT_DELAY);
        }

        setName(R.id.marker_detail_waypoint_name, hasPhoto);

        TextView category = (TextView) getView().findViewById(R.id.marker_detail_waypoint_category);
        ListItemUtils.setTextView(getActivity(), category, StringUtils.getCategory(waypoint.getCategory()),
                hasPhoto);

        TextView description = (TextView) getView().findViewById(R.id.marker_detail_waypoint_description);
        ListItemUtils.setTextView(getActivity(), description, waypoint.getDescription(), hasPhoto);

        setLocation(R.id.marker_detail_waypoint_location, hasPhoto);
    } else {
        setName(R.id.marker_detail_statistics_name, false);

        setLocation(R.id.marker_detail_statistics_location, false);

        Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId());
        ActivityType activityType = track != null
                ? CalorieUtils.getActivityType(getActivity(), track.getCategory())
                : ActivityType.INVALID;
        StatsUtils.setTripStatisticsValues(getActivity(), null, getView(), waypoint.getTripStatistics(),
                activityType, null);
        StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false);
    }
}

From source file:com.github.mobile.util.HttpImageGetter.java

@SuppressWarnings("deprecation")
private Point fetchDisplaySizePreHoneycomb(WindowManager wm) {
    Display display = wm.getDefaultDisplay();
    return new Point(display.getWidth(), display.getHeight());
}

From source file:org.odk.collect.android.widgets.DrawWidget.java

private void setupScreen() {
    setOrientation(LinearLayout.VERTICAL);

    // Retrieve answer from data model and update ui
    mBinaryName = mPrompt.getAnswerText();

    // Set location of folder containing answer
    mInstanceFolder = FormEntryActivity.mInstancePath.substring(0,
            FormEntryActivity.mInstancePath.lastIndexOf("/") + 1);

    // Error text, if needed
    mErrorTextView = new TextView(getContext());
    mErrorTextView.setText("Selected file is not a valid image");

    LayoutParams layoutParams = new TableLayout.LayoutParams();
    layoutParams.setMargins(7, 5, 7, 5);

    mCaptureButton = new Button(getContext());
    mCaptureButton.setText(getCapturePrompt());
    mCaptureButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mCaptureButton.setPadding(20, 20, 20, 20);
    mCaptureButton.setEnabled(!mPrompt.isReadOnly());
    mCaptureButton.setLayoutParams(layoutParams);

    // Launch capture intent on click
    mCaptureButton.setOnClickListener(new View.OnClickListener() {
        @Override//  w  w  w  .  j a  v a2  s.com
        public void onClick(View v) {
            mWaitingForData = true;
            mErrorTextView.setVisibility(View.GONE);

            File tmp = new File(
                    FileUtilsExtended.EXTERNAL_CACHE + File.separator + FileUtilsExtended.CAPTURED_IMAGE_FILE);

            // Copy existing image into temporary slot (edit existing image)
            if (mBinaryName == null) {
                // Remove this file if it's still sitting around
                tmp.delete();
            } else {
                try {
                    org.apache.commons.io.FileUtils.copyFile(new File(mInstanceFolder, mBinaryName), tmp);
                } catch (IOException e) {
                    Log.e(Collect.LOGTAG,
                            t + "unable to copy existing binary image to temporary location: " + e.toString());
                    e.printStackTrace();
                }
            }

            Intent i = new Intent(getContext(), DrawActivity.class);
            i.putExtra(DrawActivity.KEY_DRAW_MODE, mDrawMode);
            i.putExtra(DrawActivity.KEY_OUTPUT_URI, Uri.fromFile(tmp));
            ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.IMAGE_CAPTURE);
        }
    });

    addView(mCaptureButton);

    // Proceed to add the imageView only if the user has taken a picture
    if (mBinaryName == null)
        return;

    // Below taken from ImageWidget (w/o onClick for loading a larger image)
    mImageView = new ImageView(getContext());

    Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();

    File f = new File(mInstanceFolder + "/" + mBinaryName);

    if (f.exists()) {
        Bitmap bmp = FileUtils.getBitmapScaledToDisplay(f, screenHeight, screenWidth);

        if (bmp == null) {
            mErrorTextView.setVisibility(View.VISIBLE);
        }

        mImageView.setImageBitmap(bmp);
    } else {
        mImageView.setImageBitmap(null);
    }

    mImageView.setPadding(10, 10, 10, 10);
    mImageView.setAdjustViewBounds(true);

    addView(mImageView);
}

From source file:com.ubuntuone.android.files.fragment.GalleryFragment.java

@Override
public void onDownloadCached(String key, String path) {
    final GalleryViewHolder holder = holders.get(key);
    if (holder != null) {
        WindowManager wm = getActivity().getWindowManager();
        Display display = wm.getDefaultDisplay();
        int width = display.getWidth();
        int height = display.getHeight();
        int maxDimention = Math.max(width, height);

        final Bitmap bitmap = BitmapUtilities.decodeFile(new File(path), maxDimention);
        mHandler.post(new Runnable() {
            @Override/*from w w w  .ja  va  2  s.  c  o  m*/
            public void run() {
                if (holder.previewImage != null) {
                    holder.previewImage.setImageDrawable(new BitmapDrawable(bitmap));
                    holder.progressWrapper.setVisibility(View.GONE);
                }
            }
        });
    }
}

From source file:org.apache.cordova.SplashScreenInternal.java

/**
 * Shows the splash screen over the full Activity
 *///from  w  w w  . j  a  va  2  s.  c  o m
@SuppressWarnings("deprecation")
private void showSplashScreen(final boolean hideAfterDelay) {
    final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000);
    final int drawableId = preferences.getInteger("SplashDrawableId", 0);

    // If the splash dialog is showing don't try to show it again
    if (this.splashDialog != null && splashDialog.isShowing()) {
        return;
    }
    if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) {
        return;
    }

    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            // Get reference to display
            Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
            Context context = webView.getContext();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(context);
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);

            // TODO: Use the background color of the webview's parent instead of using the
            // preference.
            root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));
            root.setBackgroundResource(drawableId);

            // Create and show the dialog
            splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((cordova.getActivity().getWindow().getAttributes().flags
                    & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            if (hideAfterDelay) {
                final Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    public void run() {
                        removeSplashScreen();
                    }
                }, splashscreenTime);
            }
        }
    });
}

From source file:io.selendroid.server.model.internal.execute_native.IsElementDisplayedInViewport.java

@SuppressWarnings("deprecation")
public boolean isDisplayedOnViewport(View view) {
    int coordinates[] = { -1, -1 };
    int width = 0, height = 0;

    view.getLocationOnScreen(coordinates);
    if (coordinates[0] + view.getWidth() < 0)
        return false;
    if (coordinates[1] + view.getHeight() < 0)
        return false;

    if (width == 0 || height == 0) {
        if (instrumentation.getContext() == null)
            return false;
        Display display = ((WindowManager) instrumentation.getContext()
                .getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        try {/*from   ww  w  .  j a  v  a 2 s.  c  om*/
            android.graphics.Point screenSize = new android.graphics.Point();
            display.getSize(screenSize);
            width = screenSize.x;
            height = screenSize.y;
        } catch (NoSuchMethodError e) {
            width = display.getWidth();
            height = display.getHeight();
        }
    }

    if (coordinates[0] > width)
        return false;
    if (coordinates[1] > height)
        return false;

    return true;
}

From source file:com.farmerbb.taskbar.adapter.StartMenuAdapter.java

@SuppressWarnings("deprecation")
private void openContextMenu(final AppEntry entry, final int[] location) {
    LocalBroadcastManager.getInstance(getContext())
            .sendBroadcast(new Intent("com.farmerbb.taskbar.HIDE_START_MENU"));

    new Handler().postDelayed(() -> {
        SharedPreferences pref = U.getSharedPreferences(getContext());
        Intent intent = null;/*w w  w. ja  v a  2s  .c  o  m*/

        switch (pref.getString("theme", "light")) {
        case "light":
            intent = new Intent(getContext(), ContextMenuActivity.class);
            break;
        case "dark":
            intent = new Intent(getContext(), ContextMenuActivityDark.class);
            break;
        }

        if (intent != null) {
            intent.putExtra("package_name", entry.getPackageName());
            intent.putExtra("app_name", entry.getLabel());
            intent.putExtra("component_name", entry.getComponentName());
            intent.putExtra("user_id", entry.getUserId(getContext()));
            intent.putExtra("launched_from_start_menu", true);
            intent.putExtra("x", location[0]);
            intent.putExtra("y", location[1]);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
                && FreeformHackHelper.getInstance().isInFreeformWorkspace()) {
            DisplayManager dm = (DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE);
            Display display = dm.getDisplay(Display.DEFAULT_DISPLAY);

            if (intent != null && U.isOPreview())
                intent.putExtra("context_menu_fix", true);

            getContext().startActivity(intent, U.getActivityOptions(ApplicationType.CONTEXT_MENU)
                    .setLaunchBounds(new Rect(0, 0, display.getWidth(), display.getHeight())).toBundle());
        } else
            getContext().startActivity(intent);
    }, shouldDelay() ? 100 : 0);
}

From source file:com.noriginmedia.exoplayer.VideoPlayerFragment.java

private void resizeVideo(Configuration config, boolean fullscreen) {
    Display display = mActivity.getWindowManager().getDefaultDisplay();
    int screenWidth = display.getWidth();
    int screenHeight = display.getHeight();
    boolean softkeys = false;
    resizeVideo(config, fullscreen, screenWidth, screenHeight, true, softkeys);
}

From source file:com.bitants.wally.fragments.ImageZoomFragment.java

private void animateIn(final Dialog dialog) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) zoomableImageView.getLayoutParams();
    params.width = rect.right;/*  ww w . j a  v  a2  s. c om*/
    params.height = rect.bottom;
    zoomableImageView.setLayoutParams(params);

    zoomableImageView.setX(rect.left);
    zoomableImageView.setY(rect.top - statusBarHeightCorrection);
    zoomableImageView.setAlpha(0.0f);
    zoomableImageView.setImageBitmap(bitmap);

    WindowManager win = getActivity().getWindowManager();
    Display d = win.getDefaultDisplay();
    int displayWidth = d.getWidth(); // Width of the actual device
    int displayHeight = d.getHeight() + statusBarHeightCorrection;

    ValueAnimator animWidth = ValueAnimator.ofInt(rect.right, displayWidth);
    animWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.width = val;
            zoomableImageView.setLayoutParams(layoutParams);
        }
    });
    animWidth.setDuration(500);
    animWidth.setInterpolator(new LinearOutSlowInInterpolator());
    animWidth.start();

    ValueAnimator animHeight = ValueAnimator.ofInt(rect.bottom, displayHeight);
    animHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.height = val;
            zoomableImageView.setLayoutParams(layoutParams);
        }
    });
    animHeight.setDuration(500);
    animHeight.setInterpolator(new LinearOutSlowInInterpolator());

    animHeight.start();

    if (statusBarHeightCorrection > 0) {
        zoomableImageView.animate().y(0.0f).setDuration(300).start();
    }

    ValueAnimator animDim = ValueAnimator.ofFloat(0.0f, 0.5f);
    animDim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
            layoutParams.copyFrom(dialog.getWindow().getAttributes());
            layoutParams.dimAmount = (Float) valueAnimator.getAnimatedValue();
            dialog.getWindow().setAttributes(layoutParams);
        }
    });
    animDim.setDuration(300);
    animDim.setStartDelay(300);
    animDim.start();
    zoomableImageView.animate().alpha(1.0f).setDuration(300).start();
}

From source file:com.netpace.expressit.activity.UploadVideoStoryActivity.java

@SuppressLint("NewApi")
private Point getDisplayDimensions() {

    Point size = new Point();
    Display display = getWindowManager().getDefaultDisplay();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);/*w  w  w  . java2  s  . co  m*/
    } else {
        size.set(display.getWidth(), display.getHeight());
    }

    return size;
}