Example usage for android.view Display getSize

List of usage examples for android.view Display getSize

Introduction

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

Prototype

public void getSize(Point outSize) 

Source Link

Document

Gets the size of the display, in pixels.

Usage

From source file:com.yahala.ui.LoginActivity.java

public void setPage(int page, boolean animated, Bundle params, boolean back) {
    if (android.os.Build.VERSION.SDK_INT > 13) {
        Point displaySize = new Point();
        Display display = getWindowManager().getDefaultDisplay();
        display.getSize(displaySize);

        final SlideView outView = views[currentViewNum];
        final SlideView newView = views[page];
        currentViewNum = page;//from w ww  .  j a v a  2 s.c om

        newView.setParams(params);
        getSupportActionBar().setTitle(newView.getHeaderName());
        newView.onShow();
        newView.setX(back ? -displaySize.x : displaySize.x);
        outView.animate().setInterpolator(new AccelerateDecelerateInterpolator())
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        outView.setVisibility(View.GONE);
                        outView.setX(0);
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                }).setDuration(300).translationX(back ? displaySize.x : -displaySize.x).start();

        newView.animate().setInterpolator(new AccelerateDecelerateInterpolator())
                .setListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {
                        newView.setVisibility(View.VISIBLE);
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                }).setDuration(300).translationX(0).start();
    } else {
        views[currentViewNum].setVisibility(View.GONE);
        currentViewNum = page;
        views[page].setParams(params);
        views[page].setVisibility(View.VISIBLE);
        getSupportActionBar().setTitle(views[page].getHeaderName());
        views[page].onShow();
    }
}

From source file:com.aashir.gmote.player.widget.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from   ww w .  j a v  a  2s . co  m*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    textView.setBackgroundResource(outValue.resourceId);
    textView.setAllCaps(true);

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    return textView;
}

From source file:com.dva217.shadowchess.app.BaseGameUtils.BaseGameActivity.java

protected android.graphics.Point getScreenMetrics() {
    WindowManager wm = (WindowManager) BaseGameActivity.this.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    android.graphics.Point point = new android.graphics.Point();
    display.getSize(point);
    return point;
}

From source file:gr.sepals.eshop.info.gui.InfoSlidePagerActivity.java

@SuppressWarnings("deprecation")
private void showHandGesture() {
    final float startX = getResources().getDimension(R.dimen.hand_start_X);
    final float startY = getResources().getDimension(R.dimen.hand_start_Y);
    final float endX = getResources().getDimension(R.dimen.hand_end_X);
    final float endY = getResources().getDimension(R.dimen.hand_end_Y);
    Display display = getWindowManager().getDefaultDisplay();
    //ConfigOptions co = new ShowcaseView.ConfigOptions();
    //co.hideOnClickOutside = true;
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    ShowcaseView sv = ShowcaseView.insertShowcaseView(width, height, this, R.string.slide_left_title,
            R.string.slide_left_description, null);//, co);
    sv.setScaleMultiplier(0);/*from  www .j  a  v a2 s.  co m*/
    sv.animateGesture(startX, startY, endX, endY, true);
    sv.setOnShowcaseEventListener(new OnShowcaseEventListener() {

        @Override
        public void onShowcaseViewShow(ShowcaseView showcaseView) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onShowcaseViewHide(ShowcaseView showcaseView) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
            // TODO Auto-generated method stub
            Settings.setBoolean(getApplicationContext(), InternalDatabaseKeys.SHOW_SLIDE_HAND, false);
        }
    });
}

From source file:com.hb.hkm.hypebeaststore.BaseStoreFront.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Display display = getWindowManager().getDefaultDisplay();

    display.getSize(screen_size);
    mdisplay.setViewPort(screen_size);//from   w  ww .j a v a  2 s. c  o m
    initRetentionMagic(savedInstanceState);
    mgriddisplayevent = new GrideDisplayEvent() {
        @Override
        public void requestmoreitems(int page) {
            if (sync != null) {
                if (sync.getStatus() == AsyncTask.Status.FINISHED) {
                    load_fetched_content(page);
                }
            } else {
                sync = new ListQueryManager(getApplicationContext());
                load_fetched_content(page);
            }
        }
    };
    retent.msubmissionfilter.reset();
    setMainLayoutXML(savedInstanceState);
    retent.msubmissionfilter.setOnFilterApply(new SubmissionFilter.callbackfiltertrigger() {
        @Override
        public void applyfilter() {
            mdisplay.notifyList();
            load_fetched_content(1);
        }
    });

    try {
        /**
         * start coding each component
         */
        swipcontainer = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
        swipcontainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                retent.current_product_list2.clear();
                mdisplay.notifyList();
                load_fetched_content(1);
            }
        });
        /**
         * get the control of the loading circle
         */
        circlepb = (CircleProgressBar) this.findViewById(R.id.circlepb);
        if (retent.current_product_list2.size() > 0) {
            circlepb.setVisibility(View.GONE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.tomandfelix.stapp2.tabs.SlidingTabLayout.java

public void setLabelWidth() {
    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    for (TextView t : labels) {
        t.setWidth(size.x / 2);//from   w w  w . j  a  va2  s . com
    }
}

From source file:io.github.importre.android.chromeadb.ChromeAdbService.java

@SuppressLint("NewApi")
private void setCursorPosToCenter() {
    if (mWindowManager == null || mCursorImage == null) {
        return;/*from  w w  w. ja v  a  2s .com*/
    }

    Display display = mWindowManager.getDefaultDisplay();
    int x, y;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point size = new Point();
        display.getSize(size);
        x = size.x;
        y = size.y;
    } else {
        x = display.getWidth();
        y = display.getHeight();
    }

    move(x >> 1, y >> 1);
}

From source file:com.breadwallet.BreadWalletApp.java

@Override
public void onCreate() {
    super.onCreate();

    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int DISPLAY_WIDTH_PX = size.x;
    DISPLAY_HEIGHT_PX = size.y;/*www. j a  v  a2s . co  m*/
    mFingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);

}

From source file:com.teamunemployment.breadcrumbs.client.view.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from w ww.  j a  v a2s .com
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);

    return textView;
}

From source file:client.smrtms.com.smrtms_client.View.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*from  w  ww  . j  a  v a2 s .c om*/
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    textView.setPadding(padding, padding, padding, padding);

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    textView.setWidth(size.x / 3);

    return textView;
}