Example usage for android.view Display getWidth

List of usage examples for android.view Display getWidth

Introduction

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

Prototype

@Deprecated
public int getWidth() 

Source Link

Usage

From source file:jp.co.ipublishing.esnavi.views.MarqueeView.java

/**
 * ??// w w w  . ja  v a 2  s.c  o m
 *
 * @param measureSpec
 * @return
 */
private int measureWidth(int measureSpec) {
    final int result;
    final int specMode = MeasureSpec.getMode(measureSpec);
    final int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        // We were told how big to be
        result = specSize;
    } else {
        final WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
        final Display display = wm.getDefaultDisplay();
        result = display.getWidth();
    }

    return result;
}

From source file:pt.carlos.alex.rosario.MainActivity.java

/**
 * Detecta a orientao do cran.// ww  w .  j  ava 2  s .  c o  m
 * 
 * Utiliza mtodos Deprecated, para garantir a retro compatibilidade com API
 * Level < 13 (Honeycomb)
 * 
 * @return True se o cran estiver orientado em Landscape
 */
@SuppressWarnings("deprecation")
private boolean isLandscape() {

    Display getOrient = getWindowManager().getDefaultDisplay();

    if (V.DEBUG) {
        Log.d(TAG, "Screen Size - Width: " + getOrient.getWidth() + "; Heigth: " + getOrient.getHeight());
    }

    return !(getOrient.getWidth() < getOrient.getHeight());
}

From source file:com.iStudy.Study.Renren.View.RenrenDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    progress = new ProgressDialog(getContext());
    progress.requestWindowFeature(Window.FEATURE_NO_TITLE);
    progress.setMessage("Loading...");

    content = new LinearLayout(getContext());
    content.setOrientation(LinearLayout.VERTICAL);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (this.showTitle) {
        setUpTitle();/* w w w .j  ava  2s  .  c o m*/
    }
    setUpWebView();

    Display display = getWindow().getWindowManager().getDefaultDisplay();
    float scale = getContext().getResources().getDisplayMetrics().density;
    @SuppressWarnings("deprecation")
    float[] dimensions = display.getWidth() < display.getHeight() ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;
    addContentView(content, new FrameLayout.LayoutParams((int) (dimensions[0] * scale + 0.5f),
            (int) (dimensions[1] * scale + 0.5f)));
}

From source file:com.color.kid.kidpaint.activity.OptionsActivity.java

protected void initialiseNewBitmap(Drawable drawable) {
    Display display = getWindowManager().getDefaultDisplay();
    float width = display.getWidth();
    float height = display.getHeight();
    Bitmap bitmap = Bitmap.createBitmap((int) width + 200, (int) height, Bitmap.Config.ARGB_8888);
    bitmap.eraseColor(Color.WHITE);
    PaintroidApplication.drawingSurface//from  ww  w  . j  a  v a 2 s.  c  o m
            .resetBitmap(Util.overlay(bitmap, Util.drawableToBitmap(drawable, this)));
    PaintroidApplication.perspective.resetScaleAndTranslation();
    mCurrentTool = new DrawTool(this, ToolType.BRUSH);
    PaintroidApplication.currentTool = mCurrentTool;
    PaintroidApplication.currentTool.resetInternalState(Tool.StateChange.NEW_IMAGE_LOADED);
    PaintroidApplication.isPlainImage = true;
    PaintroidApplication.isSaved = false;
    PaintroidApplication.savedPictureUri = null;
}

From source file:com.tekinarslan.material.sample.customui.slidingtab_new.SlidingTabLayout.java

public SlidingTabLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);
    // Make sure that the Tab Strips fills this View
    setFillViewport(true);/*from   w ww . j  a v  a2  s  . c  om*/

    mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);

    mTabStrip = new SlidingTabStrip(context);
    addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    viewWidth = display.getWidth();
}

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

private String constructImageElement() {
    File f = new File(mInstanceFolder + File.separator + mBinaryName);

    Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
            .getDefaultDisplay();//  ww  w . j  a  v  a  2s. c  o m
    int screenWidth = display.getWidth();
    // int screenHeight = display.getHeight();

    String imgElement = f.exists() ? ("<img align=\"middle\" src=\"file:///" + f.getAbsolutePath() +
    // Appending the time stamp to the filename is a hack to prevent
    // caching.
            "?" + new Date().getTime() + "\" width=\"" + Integer.toString(screenWidth - 10) + "\" >") : "";

    return imgElement;
}

From source file:com.bydavy.card.receipts.fragments.PreviewPictureFragment.java

private void updateView(Cursor c) {
    final boolean hasReceipt = ((c != null) && c.moveToFirst());

    if (hasReceipt) {
        final int picturePathColumnIndex = c.getColumnIndex(Receipts.COLUMN_NAME_PICTURE_PATH);

        mPicturePath = c.getString(picturePathColumnIndex);

        final Display display = getActivity().getWindowManager().getDefaultDisplay();

        // Cancel picture task
        if (mViewPictureWorker != null) {
            mViewPictureWorker.cancel(true);
        }/*from w  w  w  . j  a v  a2 s.c om*/
        mViewPictureWorker = new BitmapWorkerTask(mPicture, display.getWidth(), display.getHeight()) {
            @Override
            protected void onPostExecute(Bitmap bitmap) {
                super.onPostExecute(bitmap);
                if (getState() != StateFragmentListener.STATE_COMPLETED) {
                    setState(StateFragmentListener.STATE_COMPLETED);
                }
            }
        };
        mViewPictureWorker.execute(mPicturePath);
    }
}

From source file:br.com.bioscada.apps.biotracks.fragments.MarkerDetailFragment.java

/**
 * Updates the UI.//ww w  . j  a v  a 2  s  . com
 */
@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() == Waypoint.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.google.android.apps.mytracks.fragments.MarkerDetailFragment.java

/**
 * Updates the UI.// w  w  w.  ja v a  2s .c  om
 */
@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:edu.berkeley.boinc.ProjectDetailsFragment.java

@SuppressWarnings("deprecation")
@Override/*from  ww w  .j a v  a 2 s .  c o  m*/
public void onAttach(Activity activity) {
    // first time fragment can get a valid context (before this, getActivity() will return null!)
    Display display = activity.getWindowManager().getDefaultDisplay();
    width = display.getWidth();
    height = display.getHeight();
    super.onAttach(activity);
}