Example usage for android.util DisplayMetrics DisplayMetrics

List of usage examples for android.util DisplayMetrics DisplayMetrics

Introduction

In this page you can find the example usage for android.util DisplayMetrics DisplayMetrics.

Prototype

public DisplayMetrics() 

Source Link

Usage

From source file:com.xplink.android.carchecklist.CarCheckListActivity.java

/** Called when the activity is first created. */
@Override/*from  w  w  w  . j  av  a  2  s. c om*/
public void onCreate(Bundle savedInstanceState) { // end 480
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // deleteAllData();
    // ************************************************************************************
    listValue = restoreCheckList();
    if (listValue != null) {
        SharedPreferences restoreShared = getSharedPreferences("mysettings", Context.MODE_PRIVATE);
        Editor edit = restoreShared.edit();

        Map<String, Boolean> mapList = listValue.get(0);
        Map<String, Integer> mapSetting = listValue.get(1);
        int countChecknum = 0;
        int numPowerChecked = 0;
        int numEngineChecked = 0;
        int numExteriorChecked = 0;
        int numInteriorChecked = 0;
        int numDocumentChecked = 0;

        for (Map.Entry<String, Boolean> entry : mapList.entrySet()) {

            String[] tmp = entry.getKey().split("\\_");
            Log.i("checkkeyvalue", tmp[0] + " : " + tmp[1]);
            String key = tmp[0];

            if ("inside".equals(key)) {
                if (entry.getValue()) {
                    getTotalInterior(true);
                    numInteriorChecked++;
                    Log.i("checkbox", "numInteriorChecked : " + numInteriorChecked);
                }
            } else if ("power".equals(key)) {
                if (entry.getValue()) {
                    getTotalPower(true);
                    numPowerChecked++;
                    Log.i("checkbox", "numPowerChecked : " + numPowerChecked);
                }
            } else if ("engine".equals(key)) {
                if (entry.getValue()) {
                    getTotalEngine(true);
                    numEngineChecked++;
                    Log.i("checkbox", "numEngineChecked : " + numEngineChecked);
                }
            } else if ("outside".equals(key)) {
                if (entry.getValue()) {
                    getTotalExterior(true);
                    numExteriorChecked++;
                    Log.i("checkbox", "numExteriorChecked : " + numExteriorChecked);
                }
            } else if ("doc".equals(key)) {
                if (entry.getValue()) {
                    getTotalDocument(true);
                    numDocumentChecked++;
                    Log.i("checkbox", "numDocumentChecked : " + numDocumentChecked);
                }
            }
            edit.putBoolean(entry.getKey(), entry.getValue());
            // println(entry.getKey() + " : " + entry.getValue());
        }
        Checknum = countChecknum;

        edit.putInt("CheckPowerTotal", numPowerChecked);
        edit.putInt("CheckEngineTotal", numEngineChecked);
        edit.putInt("CheckExteriorTotal", numExteriorChecked);
        edit.putInt("CheckInteriorTotal", numInteriorChecked);
        edit.putInt("CheckDocumentTotal", numDocumentChecked);

        edit.commit();

        CheckPowerTotal = restoreShared.getInt("CheckPowerTotal", 0);
        CheckEngineTotal = restoreShared.getInt("CheckEngineTotal", 0);
        CheckExteriorTotal = restoreShared.getInt("CheckExteriorTotal", 0);
        CheckInteriorTotal = restoreShared.getInt("CheckInteriorTotal", 0);
        CheckDocumentTotal = restoreShared.getInt("CheckDocumentTotal", 0);

        Log.i("checklist", "in listValue - numPowerChecked : " + numPowerChecked);
        Log.i("checklist", "numEngineChecked : " + numEngineChecked);
        Log.i("checklist", "numExteriorChecked : " + numExteriorChecked);
        Log.i("checklist", "numInteriorChecked : " + numInteriorChecked);
        Log.i("checklist", "numDocumentChecked : " + numDocumentChecked);

        Log.i("checklist", "CheckPowerTotal : " + CheckPowerTotal);
        Log.i("checklist", "CheckEngineTotal : " + CheckEngineTotal);
        Log.i("checklist", "CheckExteriorTotal : " + CheckExteriorTotal);
        Log.i("checklist", "CheckInteriorTotal : " + CheckInteriorTotal);
        Log.i("checklist", "CheckDocumentTotal : " + CheckDocumentTotal);

        //edit.commit();
        for (Map.Entry<String, Integer> entry : mapSetting.entrySet()) {

            if ("interior".equals(entry.getKey())) {
                edit.putInt("Interiorbar", entry.getValue());
            } else if ("power".equals(entry.getKey())) {
                edit.putInt("Powerbar", entry.getValue());
            } else if ("engine".equals(entry.getKey())) {
                edit.putInt("Enginebar", entry.getValue());
            } else if ("exterior".equals(entry.getKey())) {
                edit.putInt("Exteriorbar", entry.getValue());
            } else {
                edit.putInt("Documentbar", entry.getValue());
            }
            // Log.i("checkSettingsName", "checkSettingsName : " +
            // entry.getKey());
        }
        edit.commit();

        /*
         * ProgressBar PowerProgress, EngineProgress, ExteriorProgress,
         * InteriorProgress, DocumentProgress, RatioProgress; TextView
         * percenpower, percenengine, percenexterior, perceninterior,
         * percendocument, Ratiotext;
         */
    }
    // ************************************************************************************
    // isSaveCheckBox();
    store = new Bundle();
    db = new DBCarCheckList(this);

    intent = new Intent(getApplicationContext(), RecordActivity.class);

    // getSettingShared();

    // Log.i("dbcarchecklist", "create object DBCarCheckList");

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    float height = metrics.heightPixels;
    float width = metrics.widthPixels;

    Log.d("height", "" + height);
    Log.d("width", "" + width);

    int left195 = (int) ((width / 100) * 15.3);
    int left200 = (int) ((width / 100) * 16.25);
    int leftt200 = (int) ((width / 100) * 17);
    int left230 = (int) ((width / 100) * 18);
    int left475 = (int) ((width / 100) * 37.1);
    int left480 = (int) ((width / 100) * 38);
    int left495 = (int) ((width / 100) * 38.7);
    int left500 = (int) ((width / 100) * 40.5);
    int left510 = (int) ((width / 100) * 39.7);
    int left530 = (int) ((width / 100) * 41.2);
    int left865 = (int) ((width / 100) * 67.6);
    int left870 = (int) ((width / 100) * 69.5);
    int leftt870 = (int) ((width / 100) * 68);
    int leftt900 = (int) ((width / 100) * 70);
    int left950 = (int) ((width / 100) * 75);
    int left1150 = (int) ((width / 100) * 93);
    int left1180 = (int) ((width / 100) * 92);

    int top10 = (int) ((height / 100) * 3);
    int top20 = (int) ((height / 100) * 6.5);
    int top40 = (int) ((height / 100) * 5);
    int top95 = (int) ((height / 100) * 12);
    int top100 = (int) ((height / 100) * 12.5);
    int top110 = (int) ((height / 100) * 16.5);
    int top130 = (int) ((height / 100) * 19);
    int top135 = (int) ((height / 100) * 17.5);
    int top225 = (int) ((height / 100) * 28.8);
    int top390 = (int) ((height / 100) * 53);
    int top410 = (int) ((height / 100) * 51.5);
    int top480 = (int) ((height / 100) * 64.5);
    int top500 = (int) ((height / 100) * 63);
    int top505 = (int) ((height / 100) * 63.8);
    int top595 = (int) ((height / 100) * 75);
    int top610 = (int) ((height / 100) * 76);

    Intent intent = getIntent();
    PercenPower = intent.getIntExtra("power", PercenPower);
    PercenEngine = intent.getIntExtra("engine", PercenEngine);
    PercenExterior = intent.getIntExtra("exterior", PercenExterior);
    PercenInterior = intent.getIntExtra("interior", PercenInterior);
    PercenDocument = intent.getIntExtra("document", PercenDocument);

    // follow : get data from shared preferences
    /*
     * SharedPreferences memo = getSharedPreferences("mysettings",
     * Context.MODE_PRIVATE); PercenPower = memo.getInt("PercenPower", 0);
     * PercenEngine = memo.getInt("PercenEngine", 0); PercenExterior =
     * memo.getInt("PercenExterior", 0); PercenInterior =
     * memo.getInt("PercenInterior", 0); PercenDocument =
     * memo.getInt("PercenDocument", 0);
     */

    CheckPowerTotal = intent.getIntExtra("numpower", CheckPowerTotal);
    CheckEngineTotal = intent.getIntExtra("numengine", CheckEngineTotal);
    CheckExteriorTotal = intent.getIntExtra("numexterior", CheckExteriorTotal);
    CheckInteriorTotal = intent.getIntExtra("numinterior", CheckInteriorTotal);
    CheckDocumentTotal = intent.getIntExtra("numdocument", CheckDocumentTotal);

    // Log.d("percen", "" + PercenPower);

    type = Typeface.createFromAsset(getAssets(), "Circular.ttf");

    MyCustomPanel view = new MyCustomPanel(this);

    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1200, 800);
    params.width = 1200;
    params.height = 800;

    addContentView(view, params);

    RelativeLayout.LayoutParams imgpower = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imgpower.setMargins(left480, top20, 0, 0);
    RelativeLayout.LayoutParams bdpower = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bdpower.setMargins(left475, top40, 0, 0);
    RelativeLayout.LayoutParams txtpower = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtpower.setMargins(left510, top135, 0, 0);

    ImageView borderpower = (ImageView) findViewById(R.id.powerborder);
    borderpower.setLayoutParams(bdpower);
    percenpower = (TextView) findViewById(R.id.percenpower);
    percenpower.setLayoutParams(txtpower);
    percenpower.setTypeface(type);
    percenpower.setText("" + PercenPower + "%");
    PowerProgress = (ProgressBar) findViewById(R.id.PowerProgressbar);
    PowerProgress.setMax(100);
    PowerProgress.setProgress(PercenPower);
    headpower = (ImageView) findViewById(R.id.headpower);
    btnPower = (ImageButton) findViewById(R.id.battery_button);
    btnPower.setLayoutParams(imgpower);
    btnPower.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            // startAnimation
            SlidePowerLayout();
        }
    });

    RelativeLayout.LayoutParams imgengine = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imgengine.setMargins(left200, top110, 0, 0);
    RelativeLayout.LayoutParams bdengine = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bdengine.setMargins(left195, top110, 0, 0);
    RelativeLayout.LayoutParams txtengine = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtengine.setMargins(left230, top225, 0, 0);

    ImageView borderengine = (ImageView) findViewById(R.id.engineborder);
    borderengine.setLayoutParams(bdengine);
    percenengine = (TextView) findViewById(R.id.percenengine);
    percenengine.setLayoutParams(txtengine);
    percenengine.setTypeface(type);
    percenengine.setText("" + PercenEngine + "%");
    EngineProgress = (ProgressBar) findViewById(R.id.EngineProgressbar);
    EngineProgress.setMax(100);
    EngineProgress.setProgress(PercenEngine);
    headengine = (ImageView) findViewById(R.id.headengine);
    btnEngine = (ImageButton) findViewById(R.id.engine_button);
    btnEngine.setLayoutParams(imgengine);
    btnEngine.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // startAnimation
            SlideEngineLayout();
        }
    });

    RelativeLayout.LayoutParams imgexterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imgexterior.setMargins(leftt200, top390, 0, 0);
    RelativeLayout.LayoutParams bdexterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bdexterior.setMargins(left195, top410, 0, 0);
    RelativeLayout.LayoutParams txtexterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtexterior.setMargins(left230, top505, 0, 0);

    ImageView borderexterior = (ImageView) findViewById(R.id.exteriorborder);
    borderexterior.setLayoutParams(bdexterior);
    percenexterior = (TextView) findViewById(R.id.percenexterior);
    percenexterior.setLayoutParams(txtexterior);
    percenexterior.setTypeface(type);
    percenexterior.setText("" + PercenExterior + "%");
    ExteriorProgress = (ProgressBar) findViewById(R.id.ExteriorProgressbar);
    ExteriorProgress.setMax(100);
    ExteriorProgress.setProgress(PercenExterior);
    headexterior = (ImageView) findViewById(R.id.headexterior);
    btnExterior = (ImageButton) findViewById(R.id.outside_button);
    btnExterior.setLayoutParams(imgexterior);

    btnExterior.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // startAnimation
            SlideExteriorLayout();
        }
    });

    RelativeLayout.LayoutParams imginterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imginterior.setMargins(left500, top480, 0, 0);
    RelativeLayout.LayoutParams bdinterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bdinterior.setMargins(left495, top500, 0, 0);
    RelativeLayout.LayoutParams txtinterior = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtinterior.setMargins(left530, top595, 0, 0);

    ImageView borderinterior = (ImageView) findViewById(R.id.interiorborder);
    borderinterior.setLayoutParams(bdinterior);
    perceninterior = (TextView) findViewById(R.id.perceninterior);
    perceninterior.setLayoutParams(txtinterior);
    perceninterior.setTypeface(type);
    perceninterior.setText("" + PercenInterior + "%");
    InteriorProgress = (ProgressBar) findViewById(R.id.InteriorProgressbar);
    InteriorProgress.setMax(100);
    InteriorProgress.setProgress(PercenInterior);
    headinterior = (ImageView) findViewById(R.id.headinterior);
    btnInterior = (ImageButton) findViewById(R.id.inside_button);
    btnInterior.setLayoutParams(imginterior);
    btnInterior.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            // startAnimation
            SlideInteriorLayout();
        }
    });

    RelativeLayout.LayoutParams imgdocument = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imgdocument.setMargins(left870, top480, 0, 0);
    RelativeLayout.LayoutParams bddocument = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    bddocument.setMargins(left865, top500, 0, 0);
    RelativeLayout.LayoutParams txtdocument = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtdocument.setMargins(leftt900, top595, 0, 0);
    RelativeLayout.LayoutParams progdocument = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    progdocument.setMargins(leftt870, top610, 0, 0);

    ImageView borderdocument = (ImageView) findViewById(R.id.documentborder);
    borderdocument.setLayoutParams(bddocument);
    percendocument = (TextView) findViewById(R.id.percendocument);
    percendocument.setLayoutParams(txtdocument);
    percendocument.setTypeface(type);
    percendocument.setText("" + PercenDocument + "%");
    DocumentProgress = (ProgressBar) findViewById(R.id.DocumentProgressbar);
    DocumentProgress.setMax(100);
    DocumentProgress.setProgress(PercenDocument);
    headdocument = (ImageView) findViewById(R.id.headdocument);
    btnDocument = (ImageButton) findViewById(R.id.document_button);
    btnDocument.setLayoutParams(imgdocument);
    btnDocument.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            SlideDocumentLayout();

        }
    });

    RelativeLayout.LayoutParams imgsetting = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    imgsetting.setMargins(left1180, top10, 0, 0);
    RelativeLayout.LayoutParams txtratio = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    txtratio.setMargins(left950, top95, 0, 0);
    RelativeLayout.LayoutParams ratioprog = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    ratioprog.setMargins(left1150, top100, 0, 0);

    Ratiotext = (TextView) findViewById(R.id.ratiotext);
    Ratiotext.setLayoutParams(txtratio);
    RatioProgress = (ProgressBar) findViewById(R.id.ratio);
    RatioProgress.setLayoutParams(ratioprog);
    RatioProgress.setMax(100);
    headsetting = (ImageView) findViewById(R.id.headsetting);
    btnSetting = (ImageButton) findViewById(R.id.setting_button);
    btnSetting.setLayoutParams(imgsetting);
    btnSetting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            SlideSettingLayout();

        }
    });

    // addMob
    LinearLayout layout = (LinearLayout) findViewById(R.id.admob);
    adView = new AdView(getApplicationContext());
    adView.setAdSize(AdSize.LEADERBOARD);
    adView.setAdUnitId(admonId);
    //adView.setAdUnitId("C17E5F3A146EC7E805175C72634D8098");
    // Add the adView to it
    layout.addView(adView);
    // Initiate a generic request to load it with an ad
    AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
    adRequestBuilder.addTestDevice("C17E5F3A146EC7E805175C72634D8098");
    // adRequestBuilder.addTestDevice("9F5DF3C9768A51CB506B68902F766B40");
    adView.loadAd(adRequestBuilder.build());
    // adView.loadAd(new AdRequest.Builder().build());
    SharedPreferences shared = getSharedPreferences("mysettings", Context.MODE_PRIVATE);
    // Log.i("checksum",
    // "before call CheckRatio : " + shared.getInt("checknum", 0));
    CheckRatio();
    // Log.i("checklist", "checking percenpower : " +
    // shared.getInt("PercenPower", -1));

    // restoreProgressCheckList();
}

From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java

@SuppressWarnings("deprecation")
private void initData() {

    DisplayMetrics metric = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metric);
    mPref = getSharedPreferences("text", Context.MODE_PRIVATE);
    String text = mPref.getString("text", "");
    if (!TextUtils.isEmpty(text)) {
        mEditText.setText(text);//from w  w w  . java  2  s  . c om
        mEditText.setSelection(text.length());
    }

    mNavigationLayout.setBackgroundColor(config.navBgColor);

    if (TextUtils.isEmpty(config.searchBoxBgImg)) {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(BitmapFactory.decodeResource(getResources(),
                UZResourcesIDFinder.getResDrawableID("mo_searchbar_bg")));
        mRelativeLayout.setBackgroundDrawable(bitmapDrawable);
    } else {
        BitmapDrawable bitmapDrawable = new BitmapDrawable(generateBitmap(config.searchBoxBgImg));
        mRelativeLayout.setBackgroundDrawable(bitmapDrawable);
    }

    if (config.cancel_bg_bitmap != null) {
        mTextView.setBackgroundDrawable(new BitmapDrawable(config.cancel_bg_bitmap));
    } else {
        mTextView.setBackgroundColor(config.cancel_bg_color);
    }

    mTextView.setTextSize(config.cancel_size);
    mTextView.setTextColor(config.cancal_color);

    LayoutParams params = new LayoutParams(UZUtility.dipToPix(config.searchBoxWidth),
            UZUtility.dipToPix(config.searchBoxHeight));
    params.setMargins(UZUtility.dipToPix(10), 0, 0, 0);

    params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    mEditText.setLayoutParams(params);

    WindowManager wm = this.getWindowManager();
    int width = wm.getDefaultDisplay().getWidth();

    double realWidth = width * 0.80;
    LayoutParams layoutParams = new LayoutParams((int) realWidth, UZUtility.dipToPix(config.searchBoxHeight));

    layoutParams.setMargins(UZUtility.dipToPix(5), 0, 0, 0);
    layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);

    layoutParams.topMargin = UZUtility.dipToPix(8);
    layoutParams.bottomMargin = UZUtility.dipToPix(8);

    mRelativeLayout.setLayoutParams(layoutParams);

    double cancelRealWidth = width * 0.15;

    int space = (width - (int) realWidth - (int) cancelRealWidth - UZUtility.dipToPix(5)) / 2;

    LayoutParams cancalTxtParam = new LayoutParams((int) cancelRealWidth,
            UZUtility.dipToPix(config.searchBoxHeight));

    cancalTxtParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    cancalTxtParam.addRule(RelativeLayout.CENTER_VERTICAL);

    cancalTxtParam.rightMargin = space;
    cancalTxtParam.leftMargin = space;

    mTextView.setLayoutParams(cancalTxtParam);

    mListView.setBackgroundColor(config.list_bg_color);

    listSize = config.list_size;
    mCleanTextColor = config.clear_font_color;
    mCleanTextSize = config.clear_font_size;

    recordCount = config.historyCount;

    /**
     * add clean list item
     */
    int relativeLayoutCleanId = UZResourcesIDFinder.getResLayoutID("mo_searchbar_clean_item");
    relativeLayoutClean = (LinearLayout) View.inflate(getApplicationContext(), relativeLayoutCleanId, null);
    int tv_cleanId = UZResourcesIDFinder.getResIdID("tv_clean");
    mCleanTV = (TextView) relativeLayoutClean.findViewById(tv_cleanId);
    mCleanTV.setTextSize(mCleanTextSize);
    mCleanTV.setTextColor(mCleanTextColor);

    mCleanTV.setText(config.clearText);

    relativeLayoutClean
            .setBackgroundDrawable(addStateDrawable(config.clear_bg_color, config.clear_active_bg_color));
    list.clear();

    list.add(relativeLayoutClean);
    mPref = getSharedPreferences("history" + config.database, Context.MODE_PRIVATE);

    editor = mPref.edit();

    trimHistroyList(config.historyCount);

    @SuppressWarnings("unchecked")
    Map<String, String> map = (Map<String, String>) mPref.getAll();
    if (map != null) {
        if (map.size() != 0) {
            for (int i = 1; i <= map.size(); i++) {

                int listview_item = UZResourcesIDFinder.getResLayoutID("mo_searchbar_listview_item");
                LinearLayout linearLayout = (LinearLayout) View.inflate(SearchBarActivity.this, listview_item,
                        null);
                int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview");
                TextView tv = (TextView) linearLayout.findViewById(tv_listId);
                tv.setTextSize(listSize);
                tv.setTextColor(config.list_color);

                linearLayout.setBackgroundDrawable(
                        addStateDrawable(config.list_bg_color, config.list_item_active_bg_color));

                int itemBorderLineId = UZResourcesIDFinder.getResIdID("item_border_line");
                linearLayout.findViewById(itemBorderLineId).setBackgroundColor(config.list_border_color);

                for (Entry<String, String> iterable_element : map.entrySet()) {
                    String key = iterable_element.getKey();
                    if ((i + "").equals(key)) {
                        tv.setText(iterable_element.getValue());
                    }
                }
                list.addFirst(linearLayout);
            }
            id = map.size();
        }
    }

    adapter = new MyAdapter();
    mListView.setAdapter(adapter);
}

From source file:com.yozio.android.YozioHelper.java

private void setScreenInfo() {
    try {/*from  w ww  . j  a  v a 2  s. com*/
        // This is a backwards compatibility fix for Android 1.5 which has no
        // display metric API.
        // If this is 1.6 or higher, then load the class, otherwise the class
        // never loads and
        // no crash occurs.
        if (Integer.parseInt(android.os.Build.VERSION.SDK) > 3) {
            DisplayMetrics displayMetrics = new DisplayMetrics();
            WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
            windowManager.getDefaultDisplay().getMetrics(displayMetrics);
            Configuration configuration = context.getResources().getConfiguration();

            deviceScreenDensity = "" + displayMetrics.densityDpi;
            deviceScreenLayoutSize = "" + (configuration.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK);
        }
    } catch (Exception e) {
    }
}

From source file:android.content.pm.PackageParser.java

public PackageParser() {
    mMetrics = new DisplayMetrics();
    mMetrics.setToDefaults();
}

From source file:com.frostwire.android.gui.util.UIUtils.java

public static double getScreenInches(Activity activity) {
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    double x_sq = Math.pow(dm.widthPixels / dm.xdpi, 2);
    double y_sq = Math.pow(dm.heightPixels / dm.ydpi, 2);
    // pitagoras//from  www. j  a va 2  s.com
    return Math.sqrt(x_sq + y_sq);
}

From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java

/**
 * Called from both onCreate and onConfigurationChanged
 * (if the user switched layouts)//from www  .jav  a2s .c o  m
 */
private void loadGui() {
    // Inflate our UI from its XML layout description.
    setContentView(R.layout.editor);

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    mDensity = metrics.density;

    mMarkerLeftInset = (int) (46 * mDensity);
    mMarkerRightInset = (int) (48 * mDensity);
    mMarkerTopOffset = (int) (10 * mDensity);
    mMarkerBottomOffset = (int) (10 * mDensity);

    mStartText = (TextView) findViewById(R.id.starttext);
    mStartText.addTextChangedListener(mTextWatcher);
    mEndText = (TextView) findViewById(R.id.endtext);
    mEndText.addTextChangedListener(mTextWatcher);

    mPlayButton = (ImageButton) findViewById(R.id.play);
    mPlayButton.setOnClickListener(mPlayListener);
    //mRewindButton = (ImageButton)findViewById(R.id.rew);
    //mRewindButton.setOnClickListener(mRewindListener);
    //mFfwdButton = (ImageButton)findViewById(R.id.ffwd);
    //mFfwdButton.setOnClickListener(mFfwdListener);

    TextView markStartButton = (TextView) findViewById(R.id.mark_start);
    markStartButton.setOnClickListener(mMarkStartListener);
    TextView markEndButton = (TextView) findViewById(R.id.mark_end);
    markEndButton.setOnClickListener(mMarkStartListener);

    enableDisableButtons();

    mWaveformView = (WaveformView) findViewById(R.id.waveform);
    mWaveformView.setListener(this);

    mInfo = (TextView) findViewById(R.id.info);
    mInfo.setText(mCaption);

    mMaxPos = 0;
    mLastDisplayedStartPos = -1;
    mLastDisplayedEndPos = -1;

    if (mSoundFile != null && !mWaveformView.hasSoundFile()) {
        mWaveformView.setSoundFile(mSoundFile);
        mWaveformView.recomputeHeights(mDensity);
        mMaxPos = mWaveformView.maxPos();
    }

    mStartMarker = (MarkerView) findViewById(R.id.startmarker);
    mStartMarker.setListener(this);
    mStartMarker.setAlpha(255);
    mStartMarker.setFocusable(true);
    mStartMarker.setFocusableInTouchMode(true);
    mStartVisible = true;

    mEndMarker = (MarkerView) findViewById(R.id.endmarker);
    mEndMarker.setListener(this);
    mEndMarker.setAlpha(255);
    mEndMarker.setFocusable(true);
    mEndMarker.setFocusableInTouchMode(true);
    mEndVisible = true;

    updateDisplay();
}

From source file:com.adflake.AdFlakeManager.java

/**
 * Parses the custom section from the specified json string.
 * /*  w w w .j  a  v  a2  s.c  o  m*/
 * @param jsonString
 *            the json string
 * @return the custom
 */
private Custom parseCustomJsonString(String jsonString) {
    Log.d(AdFlakeUtil.ADFLAKE, "Received custom jsonString: " + jsonString);

    Custom custom = new Custom();
    try {
        JSONObject json = new JSONObject(jsonString);

        custom.type = json.getInt("ad_type");
        custom.imageLink = json.getString("img_url");
        custom.link = json.getString("redirect_url");
        custom.description = json.getString("ad_text");

        try {
            custom.imageLink640x100 = json.getString("img_url_640x100");
        } catch (JSONException e) {
            custom.imageLink640x100 = null;
        }
        try {
            custom.imageLink480x75 = json.getString("img_url_480x75");
        } catch (JSONException e) {
            custom.imageLink480x75 = null;
        }

        DisplayMetrics metrics = new DisplayMetrics();
        ((WindowManager) _contextReference.get().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
                .getMetrics(metrics);

        if (metrics.density >= 2.0 && custom.type == AdFlakeUtil.CUSTOM_TYPE_BANNER
                && custom.imageLink640x100 != null && custom.imageLink640x100.length() != 0) {
            custom.image = fetchImageWithURL(custom.imageLink640x100);
        } else if (metrics.density >= 1.5 && custom.type == AdFlakeUtil.CUSTOM_TYPE_BANNER
                && custom.imageLink480x75 != null && custom.imageLink480x75.length() != 0) {
            custom.image = fetchImageWithURL(custom.imageLink480x75);
        } else {
            custom.image = fetchImageWithURL(custom.imageLink);
        }
    } catch (JSONException e) {
        Log.e(AdFlakeUtil.ADFLAKE, "Caught JSONException in parseCustomJsonString()", e);
        return null;
    }

    return custom;
}

From source file:com.malgon.applecrunch.Game3.java

@Override
public void onLoad() {
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);

    atlas = new TextureAtlas(1024, 1024);
    atlas.insert(appleTexture = new Texture(R.drawable.apple));
    atlas.insert(appleCrunchTexture = new Texture(R.drawable.crunch));
    atlas.insert(androidTexture = new Texture(R.drawable.android));
    atlas.insert(androidCrunchTexture = new Texture(R.drawable.android_crunch));
    atlas.insert(backgroundTexture = new Texture(R.drawable.background2));
    atlas.insert(laserTexture = new Texture(R.drawable.laser));
    atlas.insert(canonTexture = new Texture(R.drawable.canon));
    atlas.insert(font = new Font("fonts/256BYTES.TTF"));
    TextureManager.load(atlas);/*from  w  w w  .  j  av a2  s  . c o  m*/

    canonSprite = new Sprite(100, screenHeight - 70, canonTexture);
    canonHotspot = new Hotspot(canonSprite);

    background = new FixedBackground(backgroundTexture);
}

From source file:com.frostwire.android.gui.util.UIUtils.java

public static boolean isPortrait(Activity activity) {
    DisplayMetrics dm = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    return dm.heightPixels > dm.widthPixels;
}

From source file:com.vidinoti.pixlive.PixLive.java

private void resize(final int x, final int y, final int width, final int height, final int ctrlID,
        CallbackContext callbackContext) {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            VDARAnnotationView annotationView = arViews.get(ctrlID);

            if (annotationView != null) {
                DisplayMetrics displaymetrics = new DisplayMetrics();

                cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);

                annotationView.setVisibility(View.VISIBLE);
                FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) annotationView.getLayoutParams();
                params.leftMargin = (int) Math.round(x * displaymetrics.scaledDensity);
                params.topMargin = (int) Math.round(y * displaymetrics.scaledDensity);
                params.width = (int) Math.round(width * displaymetrics.scaledDensity);
                params.height = (int) Math.round(height * displaymetrics.scaledDensity);

                annotationView.setLayoutParams(params);

                annotationView.requestLayout();
            }//www.  j  a va 2s  . c  o  m
        }
    });

}