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.landenlabs.flipanimation.Ui.java

/**
 * @return Convert px to dp, return dp/*from www  .ja v a 2 s.co m*/
 */
public static float pxToDp(int px) {
    return (px / Resources.getSystem().getDisplayMetrics().density);
}

From source file:librerias.ActivityProgress_detalle.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*  w w w  . jav  a 2s.  com*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle("Detalle del Trmite");

    int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    if (titleId == 0)
        titleId = com.actionbarsherlock.R.id.abs__action_bar_title;

    TextView custom = (TextView) findViewById(titleId);
    custom.setTypeface(CustomTypeFace.getInstance(this).getTypeFace());

    Bundle bundle = getIntent().getExtras();
    datos_tramite = bundle.getStringArray("datos_tramite");

    //verifica si tienes coneccin a internet
    if (verifica_internet.checkConex(getApplicationContext())) {
        Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
        if (fragment == null) {
            fragment = Detalle_tramite.newInstance();
            Bundle args = new Bundle();
            args.putStringArray("datos_tramite", datos_tramite);
            fragment.setArguments(args);
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
        }
        //getSupportActionBar().setTitle("Lista de Trmites");

    } else {
        Toast.makeText(getApplicationContext(), "Verifique estar conectado a INTERNET", Toast.LENGTH_LONG)
                .show();
        finish();
    }

}

From source file:Main.java

/**
 * Set the original text size of the View.
 *
 * @see TextView#setTextSize(int, float)
 *//*  ww w .j a  va  2s. com*/
public void setTextSize(int unit, float size) {
    if (mIsAutofitting) {
        // We don't want to update the TextView's actual textSize while we're autofitting
        // since it'd get set to the autofitTextSize
        return;
    }
    Context context = mTextView.getContext();
    Resources r = Resources.getSystem();

    if (context != null) {
        r = context.getResources();
    }

    setRawTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
}

From source file:com.arlib.floatingsearchview.util.Util.java

public static int dpToPx(int dp) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return (int) (dp * metrics.density);
}

From source file:librerias.ProgressActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*from   ww  w  . j  av  a 2s. com*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getIntent().getExtras();
    cadena_buscada = bundle.getString("cadena_buscada");

    getSupportActionBar().setTitle("Lista de Trmites");
    int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    if (titleId == 0)
        titleId = com.actionbarsherlock.R.id.abs__action_bar_title;

    TextView custom = (TextView) findViewById(titleId);
    custom.setTypeface(CustomTypeFace.getInstance(this).getTypeFace());

    //verifica si tienes coneccin a internet
    if (verifica_internet.checkConex(getApplicationContext())) {
        Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
        if (fragment == null) {
            fragment = Tramites.newInstance();
            Bundle args = new Bundle();
            args.putString("cadena_buscada", cadena_buscada);
            fragment.setArguments(args);
            getSupportFragmentManager().beginTransaction().add(android.R.id.content, fragment).commit();
        }
        //getSupportActionBar().setTitle("Lista de Trmites");

    } else {
        Toast.makeText(getApplicationContext(), "Verifique estar conectado a INTERNET", Toast.LENGTH_LONG)
                .show();
        finish();
    }

}

From source file:ru.tlrs.vincent.VincentView.java

public VincentView(Context context, AttributeSet attrs) {
    this(context, attrs, Resources.getSystem().getIdentifier("src", "attr", "android"));
}

From source file:com.arlib.floatingsearchview.util.Util.java

public static int pxToDp(int px) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return (int) (px / metrics.density);
}

From source file:com.arlib.floatingsearchview.util.Util.java

public static int spToPx(int sp) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, metrics);
}

From source file:com.arlib.floatingsearchview.util.Util.java

public static int pxToSp(int px) {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return px / (int) metrics.scaledDensity;
}

From source file:jahirfiquitiva.iconshowcase.utilities.utils.NotificationUtils.java

public static void sendFirebaseNotification(Context context, Class mainActivity, Map<String, String> data,
        String title, String content) {
    Preferences mPrefs = new Preferences(context);
    if (!(mPrefs.getNotifsEnabled()))
        return;/* w w  w .  j a va  2  s .  c  om*/

    int ledColor = ThemeUtils.darkOrLight(context, R.color.dark_theme_accent, R.color.light_theme_accent);

    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_notifications).setContentTitle(title).setTicker(title)
            .setContentText(content).setAutoCancel(true).setOngoing(false).setColor(ledColor);

    Intent intent = new Intent();
    int flag = 0;
    if (mPrefs.getLauncherIconShown()) {
        intent = new Intent(context, mainActivity);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        if (data != null) {
            if (data.size() > 0) {
                for (int i = 0; i < data.size(); i++) {
                    String[] dataValue = data.toString().replace("{", "").replace("}", "").split(",")[i]
                            .split("=");
                    Timber.d("Key: " + dataValue[0] + " - Value: " + dataValue[1]);
                    intent.putExtra(dataValue[0], dataValue[1]);
                }
            }
        }
        flag = PendingIntent.FLAG_ONE_SHOT;
    }
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* Request code
                                                                       */, intent, flag);
    notificationBuilder.setContentIntent(pendingIntent);

    Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    Resources resources = context.getResources(), systemResources = Resources.getSystem();

    notificationBuilder.setSound(mPrefs.getNotifsSoundEnabled() ? ringtoneUri : null);
    notificationBuilder.setVibrate(mPrefs.getNotifsVibrationEnabled() ? new long[] { 500, 500 } : null);

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Notification notification = notificationBuilder.build();

    if (mPrefs.getNotifsEnabled()) {
        notification.flags |= Notification.FLAG_SHOW_LIGHTS;
        notification.ledARGB = ledColor;
        notification.ledOnMS = resources.getInteger(
                systemResources.getIdentifier("config_defaultNotificationLedOn", "integer", "android"));
        notification.ledOffMS = resources.getInteger(
                systemResources.getIdentifier("config_defaultNotificationLedOff", "integer", "android"));
    } else {
        notification.ledOnMS = 0;
        notification.ledOffMS = 0;
    }

    notificationManager.notify(1 /* ID of notification */, notificationBuilder.build());
}