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.example.examplescroll.MainActivity.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void getDisplaySize(Point displaySize) {
    Display display = getWindowManager().getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(displaySize);
    } else {/*  w  ww  .  j a  v  a 2  s . c  o  m*/
        displaySize.x = display.getWidth();
        displaySize.y = display.getHeight();
    }
}

From source file:io.indy.drone.activity.BaseActivity.java

/**
 * large screen devices in portrait mode will always have enough room to show all
 * the information in a StrikeDetailFragment without having to use the
 * fragment_strike_detail_half.xml layout
 *//*from   www.  ja v a 2s . com*/
protected boolean shouldAlwaysUseFlexLayout() {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    return width > 900;
}

From source file:com.in.mobile.gesture.ad.AdMechanism.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ad_mechanism);

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
    }/*from  ww  w .j av  a  2  s .  c o  m*/

    FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    new AdContentLoader(frameLayout, size, this);

    GCMRegistrar.checkManifest(this);

    registerReceiver(mHandleMessageReceiver, new IntentFilter(Commons.DISPLAY_MESSAGE_ACTION));

    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                GCMRegistrar.register(getApplicationContext(), Commons.SENDER_ID);
            } catch (Exception e) {
                Log.e("AdMechanism - onCreate", e.toString());
            }
        }
    });

    thread.start();

    // extract to sdcard
    // extractDatabaseFile(new DatabaseCommons());

}

From source file:com.android.incallui.CircularRevealActivity.java

private Animator getRevealAnimator(Point touchPoint) {
    final View view = getWindow().getDecorView();
    final Display display = getWindowManager().getDefaultDisplay();
    final Point size = new Point();
    display.getSize(size);

    int startX = size.x / 2;
    int startY = size.y / 2;
    if (touchPoint != null) {
        startX = touchPoint.x;// www  .  j av  a 2  s .  com
        startY = touchPoint.y;
    }

    final Animator valueAnimator = ViewAnimationUtils.createCircularReveal(view, startX, startY, 0,
            Math.max(size.x, size.y));
    valueAnimator.setDuration(REVEAL_DURATION);
    return valueAnimator;
}

From source file:com.example.androidmillgame.GamePanel.java

public GamePanel(Context context, long period) {
    super(context);
    this.period = period;

    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display wsize = wm.getDefaultDisplay();
    Point size = new Point();
    wsize.getSize(size);
    DisplayMetrics displayMetrics = new DisplayMetrics();
    wsize.getMetrics(displayMetrics);//www  . ja v  a2  s. c  o m
    this.dpi = displayMetrics.densityDpi;
    this.PWIDTH = size.x;
    this.PHEIGHT = size.y;

    setFocusable(true);
    requestFocus();// ...............................................the.JPane.now.has.focus,.so.receives.key.events
    imgres = new Images(context);// ..............................................................preload.resources
    generatedJoints = new SmartJointFactory(context);
    DraggablePoint = new DragPlayer();
    backgroundRect = new Rect(PWIDTH / 2 - PHEIGHT / 2, 0, PWIDTH / 2 + PHEIGHT / 2, PHEIGHT);
    background = new Rect(0, 0, imgres.getImage("background").getWidth(),
            imgres.getImage("background").getHeight());
    scale = imgres.getImage("background").getHeight() / PHEIGHT;
    int resumescaled = imgres.getImage("resumenop").getWidth();
    resumeRect = new Rect(PWIDTH / 2 - resumescaled / 2, PHEIGHT / 2 - resumescaled / 2 + Pd2px.pd2px(50),
            PWIDTH / 2 + resumescaled / 2, PHEIGHT / 2 + resumescaled / 2 + Pd2px.pd2px(50));
    GC = new GameController(generatedJoints.Joints, DraggablePoint, context);
    Display = new HUD(PWIDTH / 2, PHEIGHT / 2, imgres.getImage("hud"));
    this.startGame();
}

From source file:nz.ac.otago.psyanlab.common.designer.program.util.ProgramPagerAdapter.java

@Override
public float getPageWidth(int position) {
    Display display = mActivity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    final int screenWidth = size.x;
    float desiredWidth;
    if (position % 2 == 0) {
        // Even position.
        desiredWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 540,
                mActivity.getResources().getDisplayMetrics());
    } else {//from   w  ww .  j  av a 2  s  .co m
        // Odd position.
        desiredWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 640,
                mActivity.getResources().getDisplayMetrics());
    }

    if (desiredWidth > screenWidth) {
        return super.getPageWidth(position);
    }

    // Return fraction of screen our page will be.
    return desiredWidth / screenWidth;
}

From source file:com.amazon.android.tv.tenfoot.ui.activities.ContentBrowseActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.content_browse_activity_layout);

    Helpers.handleActivityEnterFadeTransition(this, ACTIVITY_ENTER_TRANSITION_FADE_DURATION);

    mContentTitle = (TextView) findViewById(R.id.content_detail_title);
    CalligraphyUtils.applyFontToTextView(this, mContentTitle,
            ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.BOLD_FONT));

    mContentDescription = (TextView) findViewById(R.id.content_detail_description);
    CalligraphyUtils.applyFontToTextView(this, mContentDescription,
            ConfigurationManager.getInstance(this).getTypefacePath(ConfigurationConstants.LIGHT_FONT));

    mContentImage = (ImageView) findViewById(R.id.content_image);

    mContentImage.setImageURI(Uri.EMPTY);

    // Get display/background size
    Display display = getWindowManager().getDefaultDisplay();
    Point windowSize = new Point();
    display.getSize(windowSize);
    int imageWidth = (int) getResources().getDimension(R.dimen.content_image_width);
    int imageHeight = (int) getResources().getDimension(R.dimen.content_image_height);
    int gradientSize = (int) getResources().getDimension(R.dimen.content_image_gradient_size);
    // Create the background
    Bitmap background = BackgroundImageUtils.createBackgroundWithPreviewWindow(windowSize.x, windowSize.y,
            imageWidth, imageHeight, gradientSize,
            ContextCompat.getColor(this, R.color.browse_background_color));
    mBackgroundWithPreview = new BitmapDrawable(getResources(), background);
    // Set the background
    mMainFrame = findViewById(R.id.main_frame);
    mMainFrame.setBackground(mBackgroundWithPreview);
}

From source file:com.paperpad.mybox.GcmBroadcastReceiver.java

/**
* Sends the registration ID to your server over HTTP, so it can use GCM/HTTP
* or CCS to send messages to your app. Not needed for this demo since the
* device sends upstream messages to a server that echoes back the message
* using the 'from' address in the message.
 * @param regId /*from ww w  .jav  a  2  s .c  o  m*/
*/
private void sendRegistrationIdToBackend(Context context, String regId) {
    int id_menu = 0;
    String application_unique_identifier = Installation.id(context);
    String application_version = "0.2.8";
    try {
        application_version = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }
    ;

    String device_type = "";
    boolean isTablet = context.getResources().getBoolean(R.bool.isTablet);
    if (isTablet) {
        device_type = "tablet";
    } else {
        device_type = "smartphone";
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {

        display.getSize(size);
    } else {
        size.x = display.getWidth(); // deprecated
        size.y = display.getHeight();
    }

    String device_screen_resolution = size.x + "x" + size.y;

    //      ArrayList<AppHit> hits = new ArrayList<AppHit>();
    AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier,
            application_version, regId, Build.MANUFACTURER, Build.MODEL, "android", device_screen_resolution, 5,
            Build.VERSION.SDK_INT + "", device_type, "", System.currentTimeMillis() / 1000,
            System.currentTimeMillis() / 1000, null);
    ArrayList<AppSession> appSessions = new ArrayList<AppSession>();
    appSessions.add(appSession);
    AppJsonWriter appJsonWriter = new AppJsonWriter();
    String str = appJsonWriter.writeJson(appSessions);
    String endpoint = SERVER_URL;
    String body = str;
    int status = 0;
    try {
        status = AppJsonWriter.post(endpoint, body);
    } catch (IOException e) {
        Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status);
        e.printStackTrace();
    }
}

From source file:com.paperpad.MoulinsDuDuc.GcmBroadcastReceiver.java

/**
* Sends the registration ID to your server over HTTP, so it can use GCM/HTTP
* or CCS to send messages to your app. Not needed for this demo since the
* device sends upstream messages to a server that echoes back the message
* using the 'from' address in the message.
 * @param regId //from  w w  w .  j av a 2s .  c  o m
*/
private void sendRegistrationIdToBackend(Context context, String regId) {
    int id_menu = 0;
    String application_unique_identifier = Installation.id(context);
    String application_version = "0.2.8";
    try {
        application_version = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }
    ;

    String device_type = "";
    boolean isTablet = context.getResources().getBoolean(R.bool.isTablet);
    if (isTablet) {
        device_type = "tablet";
    } else {
        device_type = "smartphone";
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {

        display.getSize(size);
    } else {
        size.x = display.getWidth(); // deprecated
        size.y = display.getHeight();
    }

    String device_screen_resolution = size.x + "x" + size.y;

    //      ArrayList<AppHit> hits = new ArrayList<AppHit>();
    AppSession appSession = new AppSession(id_menu, "production", "MyBox", application_unique_identifier,
            application_version, regId, android.os.Build.MANUFACTURER, android.os.Build.MODEL, "android",
            device_screen_resolution, 5, android.os.Build.VERSION.SDK_INT + "", device_type, "",
            System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, null);
    ArrayList<AppSession> appSessions = new ArrayList<AppSession>();
    appSessions.add(appSession);
    AppJsonWriter appJsonWriter = new AppJsonWriter();
    String str = appJsonWriter.writeJson(appSessions);
    String endpoint = SERVER_URL;
    String body = str;
    int status = 0;
    try {
        status = AppJsonWriter.post(endpoint, body);
    } catch (IOException e) {
        Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status);
        e.printStackTrace();
    }
}

From source file:com.euphor.paperpad.GcmBroadcastReceiver.java

/**
* Sends the registration ID to your server over HTTP, so it can use GCM/HTTP
* or CCS to send messages to your app. Not needed for this demo since the
* device sends upstream messages to a server that echoes back the message
* using the 'from' address in the message.
 * @param regId // w  w  w .j  a v  a2 s .c o m
*/
private void sendRegistrationIdToBackend(Context context, String regId) {
    int id_menu = MainActivity.params.getId();
    String application_unique_identifier = Installation.id(context);
    String application_version = "0.2.8";
    try {
        application_version = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
    } catch (NameNotFoundException e) {

        e.printStackTrace();
    }
    ;

    String device_type = "";
    if (MainActivity.isTablet) {
        device_type = "tablet";
    } else {
        device_type = "smartphone";
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {

        display.getSize(size);
    } else {
        size.x = display.getWidth(); // deprecated
        size.y = display.getHeight();
    }

    String device_screen_resolution = size.x + "x" + size.y;

    ArrayList<AppHit> hits = new ArrayList<AppHit>();
    AppSession appSession = new AppSession(id_menu, MainActivity.prod_or_sand, "sales",
            application_unique_identifier, application_version, regId, Build.MANUFACTURER, Build.MODEL,
            "android", device_screen_resolution, 5, Build.VERSION.SDK_INT + "", device_type, "",
            System.currentTimeMillis() / 1000, System.currentTimeMillis() / 1000, hits);
    ArrayList<AppSession> appSessions = new ArrayList<AppSession>();
    appSessions.add(appSession);
    AppJsonWriter appJsonWriter = new AppJsonWriter();
    String str = appJsonWriter.writeJson(appSessions);
    String endpoint = SERVER_URL;
    String body = str;
    int status = 0;
    try {
        status = AppJsonWriter.post(endpoint, body);
    } catch (IOException e) {
        Log.e("GcmBroadcastReceiver", "request couldn't be sent " + status);
        e.printStackTrace();
    }
}