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.almalence.opencam.Fragment.java

@TargetApi(13)
private void showCameraParameters() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    alertDialog.setTitle(R.string.Pref_CameraParameters_Title);
    final StringBuilder about_string = new StringBuilder();
    String version = "UNKNOWN_VERSION";
    int version_code = -1;
    try {/* www  . j  a v a  2  s .c om*/
        PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
        version = pInfo.versionName;
        version_code = pInfo.versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    about_string.append("\nApplication name: ");
    about_string.append(MainScreen.getInstance().getResources().getString(R.string.Pref_About));
    about_string.append("\nAndroid API version: ");
    about_string.append(Build.VERSION.SDK_INT);
    about_string.append("\nDevice manufacturer: ");
    about_string.append(Build.MANUFACTURER);
    about_string.append("\nDevice model: ");
    about_string.append(Build.MODEL);
    about_string.append("\nDevice code-name: ");
    about_string.append(Build.HARDWARE);
    about_string.append("\nDevice variant: ");
    about_string.append(Build.DEVICE);
    {
        ActivityManager activityManager = (ActivityManager) getActivity()
                .getSystemService(Activity.ACTIVITY_SERVICE);
        about_string.append("\nStandard max heap (MB): ");
        about_string.append(activityManager.getMemoryClass());
        about_string.append("\nLarge max heap (MB): ");
        about_string.append(activityManager.getLargeMemoryClass());
    }
    {
        Point display_size = new Point();
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        display.getSize(display_size);
        about_string.append("\nDisplay size: ");
        about_string.append(display_size.x);
        about_string.append("x");
        about_string.append(display_size.y);
    }

    //show camera 2 support level
    int level = CameraController.getCamera2Level();
    about_string.append("\nCamera2 API: ");
    switch (level) {
    case 0://limited
        about_string.append("limited");
        break;
    case 1://full
        about_string.append("full");
        break;
    case 2://legacy
        about_string.append("legacy");
        break;
    default:
        about_string.append("not supported");
    }

    //      about_string.append("\nSensor orientation, back camera: ");
    //      about_string.append(CameraController.getSensorOrientation(0));
    //      about_string.append("\nSensor orientation, front camera: ");
    //      about_string.append(CameraController.getSensorOrientation(1));

    if (MainScreen.getInstance().preview_sizes != null) {
        about_string.append("\nPreview resolutions: ");
        for (int i = 0; i < MainScreen.getInstance().preview_sizes.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().preview_sizes.get(i).getWidth());
            about_string.append("x");
            about_string.append(MainScreen.getInstance().preview_sizes.get(i).getHeight());
        }
    }

    about_string.append("\nCurrent camera ID: ");
    about_string.append(MainScreen.getInstance().cameraId);

    if (MainScreen.getInstance().picture_sizes != null) {
        about_string.append("\nPhoto resolutions: ");
        for (int i = 0; i < MainScreen.getInstance().picture_sizes.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().picture_sizes.get(i).getWidth());
            about_string.append("x");
            about_string.append(MainScreen.getInstance().picture_sizes.get(i).getHeight());
        }
    }

    if (MainScreen.getInstance().video_sizes != null) {
        about_string.append("\nVideo resolutions: ");
        for (int i = 0; i < MainScreen.getInstance().video_sizes.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().video_sizes.get(i).getWidth());
            about_string.append("x");
            about_string.append(MainScreen.getInstance().video_sizes.get(i).getHeight());
        }
    }

    about_string.append("\nVideo stabilization: ");
    about_string.append(MainScreen.getInstance().supports_video_stabilization ? "true" : "false");

    about_string.append("\nFlash modes: ");
    if (MainScreen.getInstance().flash_values != null && MainScreen.getInstance().flash_values.size() > 0) {
        for (int i = 0; i < MainScreen.getInstance().flash_values.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().flash_values.get(i));
        }
    } else {
        about_string.append("None");
    }

    about_string.append("\nFocus modes: ");
    if (MainScreen.getInstance().focus_values != null && MainScreen.getInstance().focus_values.size() > 0) {
        for (int i = 0; i < MainScreen.getInstance().focus_values.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().focus_values.get(i));
        }
    } else {
        about_string.append("None");
    }

    about_string.append("\nScene modes: ");
    if (MainScreen.getInstance().scene_modes_values != null
            && MainScreen.getInstance().scene_modes_values.size() > 0) {
        for (int i = 0; i < MainScreen.getInstance().scene_modes_values.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().scene_modes_values.get(i));
        }
    } else {
        about_string.append("None");
    }

    about_string.append("\nWhite balances: ");
    if (MainScreen.getInstance().white_balances_values != null
            && MainScreen.getInstance().white_balances_values.size() > 0) {
        for (int i = 0; i < MainScreen.getInstance().white_balances_values.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().white_balances_values.get(i));
        }
    } else {
        about_string.append("None");
    }

    about_string.append("\nISOs: ");
    if (MainScreen.getInstance().isos != null && MainScreen.getInstance().isos.size() > 0) {
        for (int i = 0; i < MainScreen.getInstance().isos.size(); i++) {
            if (i > 0) {
                about_string.append(", ");
            }
            about_string.append(MainScreen.getInstance().isos.get(i));
        }
    } else {
        about_string.append("None");
    }

    String save_location = SavingService.getSaveToPath();
    about_string.append("\nSave Location: " + save_location);

    if (MainScreen.getInstance().flattenParamteters != null
            && !MainScreen.getInstance().flattenParamteters.equals("")) {
        about_string.append("\nFULL INFO:\n");
        about_string.append(MainScreen.getInstance().flattenParamteters);
    }

    alertDialog.setMessage(about_string);
    alertDialog.setPositiveButton(R.string.Pref_CameraParameters_Ok, null);
    alertDialog.setNegativeButton(R.string.Pref_CameraParameters_CopyToClipboard,
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ClipboardManager clipboard = (ClipboardManager) getActivity()
                            .getSystemService(Activity.CLIPBOARD_SERVICE);
                    ClipData clip = ClipData.newPlainText("OpenCamera About", about_string);
                    clipboard.setPrimaryClip(clip);
                }
            });
    alertDialog.show();
}

From source file:com.eurotong.orderhelperandroid.OrderMenuActivity.java

@Override
public void afterTextChanged(Editable s) {
    try {//  w  w w  . j a va2 s.c o  m
        Boolean flag = false;
        String key = editTextInput.getText().toString().trim().toLowerCase();
        if (key.contains("c")) {
            key = key.replace('c', 'c');
            flag = true;
        }
        if (key.contains("c")) {
            key = key.replace('c', 'c');
            flag = true;
        }
        if (key.contains("(")) {
            key = key.replace('(', 'c');
            flag = true;
        }
        if (key.contains("<")) {
            key = key.replace('<', 'c');
            flag = true;
        }

        int pos = key.indexOf("0");
        if (pos > 0) {
            if (key.charAt(pos - 1) >= '0' && key.charAt(pos - 1) <= '9') {
                key = key.replace('o', '0');
                flag = true;
            } else {
                key = key.replace('0', 'o');
                flag = true;
            }
        } else if (pos == 0) {
            key = key.replace('0', 'o');
            flag = true;
        }
        if (flag == true) {
            SetEditTextInputText(key);
        }

        Product[] menus = null;
        menus = ProductHints.Current().GetProductsByKeywords(key);
        menusContainer.removeAllViews();
        View filling = (View) getLayoutInflater().inflate(R.layout.order_menu_hint_fill_row, null);

        //http://stackoverflow.com/questions/1016896/android-how-to-get-screen-dimensions
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        int width = size.x;
        int height = size.y;

        filling.setMinimumHeight(height / 2);

        menusContainer.addView(filling);

        if (menus != null && menus.length > 0) {
            for (Product possiblemenu : menus) {
                for (VMMenuGroup menugroup : _lstVMMenuGroup) {
                    for (VMMenulistOrder menu : menugroup.VMMenus) {
                        if (possiblemenu.MenuNr.equals(menu.MenuNr)) {
                            View element = CreateMenuLine(menu);
                            menusContainer.addView(element);
                        }
                    }
                }
            }
        } else {
            //if(editTextInput.getText().toString().trim()!="")
            if (!editTextInput.getText().toString().trim().isEmpty()) {
                VMMenuGroup mg = new VMMenuGroup();
                mg.GroupName = getText(R.string.msg_no_mached_menu_found).toString();
                View element = CreateMenuGroupLine(mg);
                menusContainer.addView(element);
            }
        }
    } catch (Exception ex) {
        Log.e(Define.APP_CATALOG, ex.toString());
    }
}

From source file:com.facebook.android.friendsmash.GameFragment.java

@SuppressWarnings({ "deprecation" })
@TargetApi(13)/*from  ww  w  . j a  va  2 s  . c  o m*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_game, parent, false);

    gameFrame = (FrameLayout) v.findViewById(R.id.gameFrame);
    progressContainer = (FrameLayout) v.findViewById(R.id.progressContainer);
    smashPlayerNameTextView = (TextView) v.findViewById(R.id.smashPlayerNameTextView);
    scoreTextView = (TextView) v.findViewById(R.id.scoreTextView);
    livesContainer = (LinearLayout) v.findViewById(R.id.livesContainer);

    // Set the progressContainer as invisible by default
    progressContainer.setVisibility(View.INVISIBLE);

    // Set the icon width (for the images to be smashed)
    setIconWidth(getResources().getDimensionPixelSize(R.dimen.icon_width));

    // Set the screen dimensions
    WindowManager wm = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    if (Build.VERSION.SDK_INT >= 13) {
        Point size = new Point();
        display.getSize(size);
        setScreenWidth(size.x);
        setScreenHeight(size.y);
    } else {
        setScreenWidth(display.getWidth());
        setScreenHeight(display.getHeight());
    }

    // Always keep the Action Bar hidden
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActivity().getActionBar().hide();
    }

    // Instantiate the fireImageTask for future fired images
    fireImageTask = new Runnable() {
        public void run() {
            spawnImage(false);
        }
    };

    // Refresh the score board
    setScore(getScore());

    // Refresh the lives
    setLives(getLives());

    // Note: Images will start firing in the onResume method below

    return v;
}

From source file:com.klinker.android.twitter.activities.tweet_viewer.TweetPager.java

public void setUpWindow(boolean youtube) {

    requestWindowFeature(Window.FEATURE_ACTION_BAR | Window.FEATURE_PROGRESS);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND,
            WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    // Params for the window.
    // You can easily set the alpha and the dim behind the window from here
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.alpha = 1.0f; // lower than one makes it more transparent
    if (!youtube) {
        params.dimAmount = .75f; // set it higher if you want to dim behind the window
    } else {//  w w  w  . j  a v  a2  s .c  o m
        params.dimAmount = 0f;
    }
    getWindow().setAttributes(params);

    // Gets the display size so that you can set the window to a percent of that
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    // You could also easily used an integer value from the shared preferences to set the percent
    if (height > width) {
        getWindow().setLayout((int) (width * .9), (int) (height * .8));
    } else {
        getWindow().setLayout((int) (width * .7), (int) (height * .8));
    }
}

From source file:Steps.StepsFragment.java

private void showStickerMoreInfo(final Sticker clickedSticker) {
    // custom dialog
    clickedSticker.getName();// ww w  .j  a  v  a  2 s. co  m
    Log.d("NAMe", clickedSticker.getName());

    final Dialog dialog = new Dialog(getActivity());

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    dialog.setContentView(R.layout.sticker_dialog);
    ImageView image = (ImageView) (dialog).findViewById(R.id.image);

    //get the correct image
    String file = clickedSticker.getImagesrc();
    file = file.substring(0, file.lastIndexOf(".")); //trim the extension
    Resources resources = getActivity().getResources();
    int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName());
    image.setImageBitmap(SampleImage.decodeSampledBitmapFromResource(getResources(), resourceId, 250, 250));

    //load the additional details and information
    TextView id = (TextView) (dialog).findViewById(R.id.sticker_id);
    id.setText("#" + Integer.toString(clickedSticker.getId()));

    TextView status = (TextView) (dialog).findViewById(R.id.sticker_status);
    //at this poinrt only glued and notSticker available glued=1 notGlued=0
    String statuss = clickedSticker.getStatus().equals(2) ? "1" : "0";
    Integer count = clickedSticker.getCount();
    status.setText("(" + statuss + " glued, " + count + " left)");

    TextView title = (TextView) (dialog).findViewById(R.id.sticker_title);
    title.setText(clickedSticker.getName());

    TextView rarity = (TextView) (dialog).findViewById(R.id.rarity);
    rarity.setText(clickedSticker.getPopularity());

    TextView movie = (TextView) (dialog).findViewById(R.id.sticker_movie);
    movie.setText(clickedSticker.getMovie());
    //set the layout to have the same widh and height as the  windows screen

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = width;
    lp.height = height;
    dialog.getWindow().setAttributes(lp);
    RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout);
    dialog.show();
    // if button is clicked, close the custom dialog
    mainLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }

    });
    //listen for the inf tab
    ImageView info = (ImageView) (dialog).findViewById(R.id.info_image);
    info.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showInfoDialog(clickedSticker);
        }

    });

}

From source file:com.retroteam.studio.retrostudio.EditorLandscape.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_editor_landscape);

    //get display size
    Display display = getWindowManager().getDefaultDisplay();
    display.getSize(displaysize);

    //check where we're coming from, if we have an intent
    if (getIntent().getStringExtra("SourceActivity") != null && getIntent() != null) {
        Intent intent = getIntent();//  w ww.java  2s  . c o  m
        if (intent.getStringExtra("SourceActivity").equals("MainActivity")) {
            ProjectWrapper projwrapper = (ProjectWrapper) intent.getSerializableExtra("project");
            if (projwrapper != null) {
                // We are loading the project from a file.
                PROJECT_TITLE = projwrapper.title;
                PROJECT_TEMPO = projwrapper.tempo;
                TS_BEATS = projwrapper.tSig.beats();
                TS_NOTES = projwrapper.tSig.notes();
                theproject = projwrapper.project;
                ArrayList<MeasureTagGroup> mTagList = projwrapper.mTagList;
                //redraw project
                redrawMe(theproject);
                //re-apply measure tags
                for (int m = 0; m < mTagList.size(); m++) {
                    ImageView measure = (ImageView) findMeasureByCoords(mTagList.get(m).row,
                            mTagList.get(m).column);
                    measure.setTag(R.id.TAG_ROW, mTagList.get(m).row);
                    measure.setTag(R.id.TAG_COLUMN, mTagList.get(m).column);
                    measure.setTag(R.bool.TAG_HASNOTES, mTagList.get(m).hasNotes);
                    measure.setTag(R.id.TAG_GUISNAP, mTagList.get(m).guiSNAP);
                    measure.setTag(R.id.TAG_FILLED_NOTES, mTagList.get(m).filledNotes);
                    if (mTagList.get(m).hasNotes) {
                        measure.setImageResource(R.drawable.measure_new_filled);
                    }
                }
                Toast.makeText(this, "Opened project " + PROJECT_TITLE, Toast.LENGTH_SHORT).show();
            } else {
                // We're making a new project or coming from the main menu
                Toast.makeText(this, "Created new project.", Toast.LENGTH_SHORT).show();
                TS_BEATS = intent.getIntExtra("TimeSigBeats", 4);
                TS_NOTES = intent.getIntExtra("TimeSigNotes", 4);
                theproject = new Project(new TimeSignature(TS_BEATS, TS_NOTES));
            }
        }
    }

    // Put the project title in the actionbar.
    if (PROJECT_TITLE != "") {
        setupActionBar("'" + PROJECT_TITLE + "' Project Editor (" + Integer.toString(TS_BEATS) + "/"
                + Integer.toString(TS_NOTES) + " Time)");
    } else {
        setupActionBar(
                "Project Editor (" + Integer.toString(TS_BEATS) + "/" + Integer.toString(TS_NOTES) + " Time)");
    }

    //add buttons to the floating action menu
    FloatingActionsMenu menuAddTrack = (FloatingActionsMenu) findViewById(R.id.add_track_menu);
    FloatingActionButton addSineTrack = new FloatingActionButton(getBaseContext());
    addSineTrack.setTitle("Add Sine Wave Track");
    addSineTrack.setIcon(R.drawable.sine_wave);
    addSineTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SineWave wave = new SineWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.sine_wave, false);
        }
    });
    FloatingActionButton addSquareTrack = new FloatingActionButton(getBaseContext());
    addSquareTrack.setTitle("Add Square Wave Track");
    addSquareTrack.setIcon(R.drawable.square_wave);
    addSquareTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SquareWave wave = new SquareWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.square_wave, false);
        }
    });
    FloatingActionButton addNoiseTrack = new FloatingActionButton(getBaseContext());
    addNoiseTrack.setTitle("Add Noise Wave Track");
    addNoiseTrack.setIcon(R.drawable.noise_wave);
    addNoiseTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NoiseWave wave = new NoiseWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.noise_wave, false);
        }
    });

    FloatingActionButton addSawTrack = new FloatingActionButton(getBaseContext());
    addSawTrack.setTitle("Add Saw Wave Track");
    addSawTrack.setIcon(R.drawable.saw_wave);
    addSawTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SawtoothWave wave = new SawtoothWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.saw_wave, false);
        }
    });

    FloatingActionButton addInvSawTrack = new FloatingActionButton(getBaseContext());
    addInvSawTrack.setTitle("Add Inverse Saw Wave Track");
    addInvSawTrack.setIcon(R.drawable.inv_saw_wave);
    addInvSawTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InverseSawtoothWave wave = new InverseSawtoothWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.inv_saw_wave, false);
        }
    });

    FloatingActionButton addTriangleTrack = new FloatingActionButton(getBaseContext());
    addTriangleTrack.setTitle("Add Triangle Wave Track");
    addTriangleTrack.setIcon(R.drawable.triangle_wave);
    addTriangleTrack.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            TriangleWave wave = new TriangleWave();
            theproject.addTrack(wave);
            addTrack(R.drawable.triangle_wave, false);
        }
    });

    menuAddTrack.addButton(addSineTrack);
    menuAddTrack.addButton(addSquareTrack);
    menuAddTrack.addButton(addNoiseTrack);
    menuAddTrack.addButton(addSawTrack);
    menuAddTrack.addButton(addInvSawTrack);
    menuAddTrack.addButton(addTriangleTrack);

    // Set the project tempo.
    theproject.tempo(PROJECT_TEMPO);
}

From source file:com.andfchat.frontend.activities.ChatScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTheme(sessionData.getSessionSettings().getTheme());
    setContentView(R.layout.activity_chat_screen);

    AdEntry.setAdClickListener(this);

    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setTintColor(getResources().getColor(R.color.primary_color_dark));

    toggleSidebarRight.setSelected(false);

    eventManager.clear();/*from  w  w  w.j a v  a2s .  c  om*/
    eventManager.register((ChatroomEventListener) this);
    eventManager.register((ConnectionEventListener) this);

    // Fetch fragments
    chatFragment = (ChatFragment) getSupportFragmentManager().findFragmentById(R.id.chatFragment);
    userList = (UserListFragment) getSupportFragmentManager().findFragmentById(R.id.userListFragment);
    channelList = (ChannelListFragment) getSupportFragmentManager().findFragmentById(R.id.channelListFragment);
    inputFragment = (ChatInputFragment) getSupportFragmentManager().findFragmentById(R.id.chatInputFragment);

    // Register fragments
    eventManager.register((ChatroomEventListener) chatFragment);
    eventManager.register((MessageEventListener) chatFragment);
    eventManager.register((ChatroomEventListener) userList);
    eventManager.register((UserEventListener) userList);
    eventManager.register(channelList);
    eventManager.register(inputFragment);

    // PopUps
    loginPopup = new FListLoginPopup();
    charSelectionPopup = new FListCharSelectionPopup();

    loginPopup.setDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (sessionData.getTicket() == null) {
                openLogin();
            }
        }
    });

    charSelectionPopup.setDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (!sessionData.isInChat()) {
                connection.closeConnection(ChatScreen.this);
                sessionData.setTicket(null);
                openLogin();
            }
        }
    });

    RoboGuice.injectMembers(this, charSelectionPopup);
    RoboGuice.injectMembers(this, loginPopup);

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

    height = size.y;
    width = size.x;

    AndFChatApplication application = (AndFChatApplication) getApplicationContext();
    application.setScreenDimension(size);

    setupActionBar();
}

From source file:Steps.StepsFragment.java

private void showNewSticker(final Sticker sticker_1, final Sticker sticker_2, final Sticker sticker_3) {
    // custom dialog

    final Dialog dialog = new Dialog(getActivity());

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override// w  w  w .  j  a  v  a 2  s.c  o m
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.new_stickers_dialog);
    //get the correct image -1st sticker

    ImageView image = (ImageView) (dialog).findViewById(R.id.sticker1);
    image.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_1);
        }
    });
    String file = sticker_1.getImagesrc();
    file = file.substring(0, file.lastIndexOf(".")); //trim the extension
    Resources resources = getActivity().getResources();
    int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName());
    TextView number = (TextView) (dialog).findViewById(R.id.text_sticker1);
    number.setText("#" + Integer.toString(sticker_1.getId()));
    RelativeLayout image_layout = (RelativeLayout) (dialog).findViewById(R.id.sticker1_layout);
    ImageView imageCategory = (ImageView) (dialog).findViewById(R.id.category_image1);
    determineCategoty(imageCategory, sticker_1);
    determinePicture(sticker_1, image, resourceId);
    animate(image_layout, 3000);

    //get the correct image -2nd sticker
    ImageView image2 = (ImageView) (dialog).findViewById(R.id.sticker2);
    image2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_2);
        }
    });
    String file2 = sticker_2.getImagesrc();
    file2 = file2.substring(0, file2.lastIndexOf(".")); //trim the extension
    Resources resources2 = getActivity().getResources();
    int resourceId2 = resources2.getIdentifier(file2, "drawable", getActivity().getPackageName());
    TextView number2 = (TextView) (dialog).findViewById(R.id.text_sticker2);
    number2.setText("#" + Integer.toString(sticker_2.getId()));
    RelativeLayout image_layout2 = (RelativeLayout) (dialog).findViewById(R.id.sticker2_layout);
    ImageView imageCategory2 = (ImageView) (dialog).findViewById(R.id.category_image2);
    determineCategoty(imageCategory2, sticker_2);
    determinePicture(sticker_2, image2, resourceId2);
    animate(image_layout2, 3000);

    //get the correct image -3rd sticker
    ImageView image3 = (ImageView) (dialog).findViewById(R.id.sticker3);
    image3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showStickerMoreInfo(sticker_3);
        }
    });
    String file3 = sticker_3.getImagesrc();
    file3 = file3.substring(0, file3.lastIndexOf(".")); //trim the extension
    Resources resources3 = getActivity().getResources();
    int resourceId3 = resources3.getIdentifier(file3, "drawable", getActivity().getPackageName());

    TextView number3 = (TextView) (dialog).findViewById(R.id.text_sticker3);
    number3.setText("#" + Integer.toString(sticker_3.getId()));
    RelativeLayout image_layout3 = (RelativeLayout) (dialog).findViewById(R.id.sticker3_layout);
    ImageView imageCategory3 = (ImageView) (dialog).findViewById(R.id.category_image3);
    determineCategoty(imageCategory3, sticker_3);
    determinePicture(sticker_3, image3, resourceId3);
    animate(image_layout3, 3000);

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    //set the layout to have the same widh and height as the  windows screen
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = width;
    lp.height = height;
    dialog.getWindow().setAttributes(lp);
    RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout);
    dialog.show();
    // if button is clicked, close the custom dialog
    Button doneButton = (Button) (dialog).findViewById(R.id.doneButton);
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }

    });
}

From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java

private void initDrawer() {
    mDrawerList.setClipToPadding(false);
    mDrawerList.setLayoutManager(new LinearLayoutManager(this));
    mDrawerList.setAdapter(new NavigationDrawerAdapter(this));
    mDrawerList.setHasFixedSize(true);//from   w ww.  ja  v a  2  s  . c o m

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (null != mSnackBar)
                mSnackBar.clear();
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    DrawerLayout.LayoutParams dlp = (DrawerLayout.LayoutParams) mNavigationDrawer.getLayoutParams();

    TypedValue tv = new TypedValue();
    int actionBarHeight;
    if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        int maxWidth = getResources().getDimensionPixelSize(R.dimen.navigation_drawer_max_width);
        Display display = getWindowManager().getDefaultDisplay();
        int width;
        Point size = new Point();
        display.getSize(size);
        width = size.x - actionBarHeight;
        dlp.width = Math.min(width, maxWidth);
    } else {
        dlp.width = getResources().getDimensionPixelSize(R.dimen.navigation_drawer_min_width);
    }
    mNavigationDrawer.setLayoutParams(dlp);

    View cover = findViewById(R.id.drawer_cover);
    LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams) cover.getLayoutParams();
    llp.height = dlp.width * 9 / 16;
    cover.setLayoutParams(llp);
}

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java

private void setBitmap(final Bitmap showBitmap) {
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int targetWidth = size.x;

    if (showBitmap.getWidth() != targetWidth) {
        Bitmap scaledBitmap = Bitmap.createScaledBitmap(showBitmap, targetWidth,
                (int) (((long) showBitmap.getHeight() * (long) targetWidth) / showBitmap.getWidth()), true);
        imageView.setImageBitmap(scaledBitmap);
    } else {//from w w w.  j  av  a 2s  .  com
        imageView.setImageBitmap(showBitmap);
    }
    imageView.setVisibility(View.VISIBLE);
    invalidateOptionsMenu();
}