Example usage for android.content.res Resources getSystem

List of usage examples for android.content.res Resources getSystem

Introduction

In this page you can find the example usage for android.content.res Resources getSystem.

Prototype

public static Resources getSystem() 

Source Link

Document

Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

Usage

From source file:com.mobicage.rogerthat.plugins.messaging.widgets.PhotoUploadWidget.java

private void handleSelection() {
    if (mUriSavedImage == null) {
        L.bug("PhotoUploadWidget mUriSavedImage was null.. Creating now");
        File image;/* w  w  w.  ja va  2  s.c o m*/
        try {
            image = getTmpUploadPhotoLocation();
        } catch (IOException e) {
            L.d(e.getMessage());
            return;
        }
        mUriSavedImage = Uri.fromFile(image);
    }

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 4;
    Bitmap bitmap = ImageHelper.getBitmapFromFile(mUriSavedImage.getPath(), options);

    Drawable d = new BitmapDrawable(Resources.getSystem(), bitmap);
    mImagePreview.setImageDrawable(d);

    if (!USER_QUALITY.equals(mQuality)) {
        if (BEST_QUALITY.equals(mQuality) || mQuality == null) {
            IOUtils.compressPicture(mUriSavedImage, 0);
        } else {
            IOUtils.compressPicture(mUriSavedImage, Long.parseLong(mQuality));
        }
    } else {
        pickSizePhoto(mUriSavedImage);
    }
    mPhotoSelected = true;
    mSourceButton.setText(R.string.change_picture);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static float getRawSize(final int unit, final float size, final Context context) {
    Resources r;//from w  w w. j  a va2s .c  o m
    if (context != null) {
        r = context.getResources();
    } else {
        r = Resources.getSystem();
    }
    return TypedValue.applyDimension(unit, size, r.getDisplayMetrics());
}

From source file:org.projectbuendia.client.ui.FunctionalTestCase.java

protected void setDateSpinner(String spinnerName, String value) {
    int numberPickerId = Resources.getSystem().getIdentifier("numberpicker_input", "id", "android");
    int spinnerId = Resources.getSystem().getIdentifier(spinnerName, "id", "android");
    LOG.i("%s: %s", spinnerName, value);
    LOG.i("numberPickerId: %d", numberPickerId);
    LOG.i("spinnerId: %d", spinnerId);
    onView(allOf(withId(numberPickerId), withParent(withId(spinnerId)))).check(matches(isDisplayed()))
            .perform(typeText(value));/*from w  w  w .  j a v  a 2 s. c om*/
}

From source file:net.gsantner.opoc.util.ContextUtils.java

/**
 * Get an {@link Locale} out of a android language code
 * The {@code androidLC} may be in any of the forms: de, en, de-rAt
 *//*from w  ww  .  j a v a 2 s .  c o m*/
public Locale getLocaleByAndroidCode(String androidLC) {
    if (!TextUtils.isEmpty(androidLC)) {
        return androidLC.contains("-r") ? new Locale(androidLC.substring(0, 2), androidLC.substring(4, 6)) // de-rAt
                : new Locale(androidLC); // de
    }
    return Resources.getSystem().getConfiguration().locale;
}

From source file:net.gsantner.opoc.util.ContextUtils.java

/**
 * Set the apps language//from   ww  w . jav a2s . c  o m
 * {@code androidLC} may be in any of the forms: en, de, de-rAt
 * If given an empty string, the default (system) locale gets loaded
 */
public void setAppLanguage(String androidLC) {
    Locale locale = getLocaleByAndroidCode(androidLC);
    Configuration config = _context.getResources().getConfiguration();
    config.locale = (locale != null && !androidLC.isEmpty()) ? locale
            : Resources.getSystem().getConfiguration().locale;
    _context.getResources().updateConfiguration(config, null);
}

From source file:de.langerhans.wallet.WalletApplication.java

public void updateLocale() {
    final String locale = config.getLocale();
    Locale loc;//from w w w .  j a  v  a  2s . com
    android.content.res.Configuration configuration = new android.content.res.Configuration();
    if (!locale.equals("0")) {
        if (locale.length() > 2)
            loc = new Locale(locale.substring(0, 1), locale.substring(3, 4));
        else
            loc = new Locale(locale);
    } else {
        loc = Resources.getSystem().getConfiguration().locale;
    }
    Locale.setDefault(loc);
    configuration.locale = loc;
    getBaseContext().getResources().updateConfiguration(configuration,
            getBaseContext().getResources().getDisplayMetrics());
}

From source file:com.softminds.matrixcalculator.base_activities.FillingMatrix.java

private int ConvertTopx(float dp) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return ((int) (dp * ((float) metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT));

}

From source file:edu.ptu.navpattern.tooltip.Tooltip.java

public static float dpToPx(float dp) {
    return dp * Resources.getSystem().getDisplayMetrics().density;
}

From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java

private float dpToPixels(int dp) {
    return Resources.getSystem().getDisplayMetrics().densityDpi / DisplayMetrics.DENSITY_DEFAULT * dp;
}

From source file:com.landenlabs.all_devtool.ConsoleFragment.java

/**
 * @return Convert dp to px, return px/*  ww  w.  j  a va2s  . c  o  m*/
 */
private static int dpToPx(int dp) {
    return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}