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.allperfimages.ui.Ui.java

/**
 * @return Screen Width in Pixels,/*  ww  w  .jav  a  2  s.  c o  m*/
 */
public static int getScreenWidthPixels() {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return metrics.widthPixels;
}

From source file:net.kjmaster.cookiemom.booth.add.AddBoothActivity.java

@AfterViews
void afterViews() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("add_booth");

    if (prev != null) {
        ft.remove(prev);/*  w  w  w.j  a  v a 2  s  .co  m*/
    }

    ft.replace(R.id.content, AddBoothDialogFragment_.builder().build(), "add_booth");

    ActionMode actionMode = startActionMode(this);

    actionMode.setTitle("Add Booth");

    int doneButtonId = Resources.getSystem().getIdentifier("action_mode_close_button", "id", "android");

    View doneButton = this.findViewById(doneButtonId);

    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            saveScoutData();
            finish();
        }
    });

    ft.commit();
}

From source file:com.landenlabs.allperfimages.ui.Ui.java

public static int getScreenHeightPixels() {
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    return metrics.heightPixels;
}

From source file:de.grobox.liberario.activities.TransportrActivity.java

protected static void useLanguage(Context context) {
    String lang = Preferences.getLanguage(context);
    if (!lang.equals(context.getString(R.string.pref_language_value_default))) {
        Locale locale;/*  w  w  w  . j ava 2s  . c  o  m*/
        if (lang.contains("_")) {
            String[] lang_array = lang.split("_");
            locale = new Locale(lang_array[0], lang_array[1]);
        } else {
            locale = new Locale(lang);
        }
        Locale.setDefault(locale);
        Configuration config = context.getResources().getConfiguration();
        config.locale = locale;
        context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
    } else {
        // use default language
        context.getResources().updateConfiguration(Resources.getSystem().getConfiguration(),
                context.getResources().getDisplayMetrics());
    }
}

From source file:com.manoj.macawplayer.SwipeViewActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.drawable.theme_skyblue);// w ww.j av a2  s. c  o m
    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.swipe_view);
    int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    TextView actionBarTextView = (TextView) findViewById(actionBarTitleId);

    if (actionBarTextView != null) {
        Log.i("actionBarTextView :", "not null");
        actionBarTextView.setTextColor(Color.GREEN);
    } else
        Log.i("actionBarTextView :", "null");

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    //to remove the title and icon above the action bar
    getActionBar().setDisplayShowTitleEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    LinearLayout homeScreen = (LinearLayout) findViewById(R.id.swipeviewl);
    utilities = new Utilities();
    utilities.colorSeter(homeScreen, getApplicationContext());

    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
        /*Tab tab = actionBar.getTabAt(i);
        View v  = tab.setgetCustomView();
        v.setBackgroundResource(R.drawable.theme_skyblue);*/
    }
}

From source file:com.aniruddhc.acemusic.player.BrowserSubGridActivity.BrowserSubGridAdapter.java

public BrowserSubGridAdapter(Context context, BrowserSubGridActivity activity,
        HashMap<Integer, String> dbColumnsMap) {

    super(context, -1, activity.getCursor(), new String[] {}, new int[] {}, 0);
    mContext = context;//from  w  w  w  .  j  av  a2  s  . c  o m
    mActivity = activity;
    mApp = (Common) mContext.getApplicationContext();
    mDBColumnsMap = dbColumnsMap;

    //Calculate the height and width of each item image.
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();

    if (mApp.isTabletInPortrait()) {
        //3 column layout.
        mWidth = (metrics.widthPixels) / 3;
        mHeight = mWidth + (mWidth / 4);
    } else if (mApp.isPhoneInLandscape() || mApp.isTabletInLandscape()) {
        //4 column layout.
        mWidth = (metrics.widthPixels) / 4;
        mHeight = mWidth + (mWidth / 5);
    } else {
        //2 column layout.
        mWidth = (metrics.widthPixels) / 2;
        mHeight = mWidth + (mWidth / 3);
    }

}

From source file:com.coodesoft.notee.MyImageGetter.java

@Override
public Drawable getDrawable(String source) {
    Drawable d = null;//from www . j  a  va  2s .com

    String strSrcLeft5 = source.substring(0, 5);

    // data
    if (strSrcLeft5.equalsIgnoreCase("data:")) {
        InputStream is = new ByteArrayInputStream(source.getBytes());

        //d = Drawable.createFromStream(is, null);
        //d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());

        //Bitmap dBitmap = BitmapFactory.decodeByteArray(data, 0, length);
        int nPosComma = source.indexOf(',');
        if (nPosComma > 0) {
            byte[] arrBuffer = Base64.decode(source.substring(nPosComma + 1), Base64.DEFAULT);
            //byte[] arrBuffer = Base64Coder.decode(source.substring(nPosComma + 1));
            Bitmap dBitmap = BitmapFactory.decodeByteArray(arrBuffer, 0, arrBuffer.length);
            d = new BitmapDrawable(dBitmap);
            d.setBounds(0, 0, dBitmap.getWidth(), dBitmap.getHeight());
        }

    } else {
        // url

        try {

            InputStream is = (InputStream) new URL(source).getContent();
            Bitmap dBitmap = BitmapFactory.decodeStream(is);
            if (dBitmap == null) {
                d = Resources.getSystem().getDrawable(android.R.drawable.picture_frame);
            } else {
                d = new BitmapDrawable(dBitmap);
                d.setBounds(0, 0, dBitmap.getWidth(), dBitmap.getHeight());
            }

            d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());

        } catch (MalformedURLException e) {

            e.printStackTrace();

        } catch (IOException e) {

            e.printStackTrace();

        }

        /*
         URLDrawable urlDrawable = new URLDrawable();
                
         // get the actual source
         ImageGetterAsyncTask asyncTask = 
        new ImageGetterAsyncTask( urlDrawable);
                
         asyncTask.execute(source);
                
         // return reference to URLDrawable where I will change with actual image from
         // the src tag
         return urlDrawable;
         */

    }

    return d;
}

From source file:net.lp.actionbarpoirot.helpers.ActivityHelperHoneycomb.java

/**
 * Constructor/* w w  w . j  a va2 s.com*/
 * 
 * @param activity The {@link Activity} we are helping. It must implement {@link ActivityHelperUser}.
 */
protected ActivityHelperHoneycomb(Activity activity) {//TODO: This has a dependency on some layout elements.
    super(activity);
    actionBarTitleResId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    leftNavActionBarResId = Resources.getSystem().getIdentifier("main", "id", "android");
}

From source file:rus.cpuinfo.AndroidDepedentModel.DevInfo.java

@NonNull
private DisplayMetrics getDisplayMetrics() {

    return Resources.getSystem().getDisplayMetrics();

}

From source file:com.aniruddhc.acemusic.player.GridViewFragment.GridViewCardsAdapter.java

public GridViewCardsAdapter(Context context, GridViewFragment gridViewFragment,
        HashMap<Integer, String> dbColumnsMap) {

    super(context, -1, gridViewFragment.getCursor(), new String[] {}, new int[] {}, 0);
    mContext = context;/*from  ww  w .j  ava2 s.c om*/
    mGridViewFragment = gridViewFragment;
    mApp = (Common) mContext.getApplicationContext();
    mDBColumnsMap = dbColumnsMap;

    //Calculate the height and width of each item image.
    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();

    if (mApp.isTabletInPortrait()) {
        //3 column layout.
        mWidth = (metrics.widthPixels) / 3;
        mHeight = mWidth + (mWidth / 4);
    } else if (mApp.isPhoneInLandscape() || mApp.isTabletInLandscape()) {
        //4 column layout.
        mWidth = (metrics.widthPixels) / 4;
        mHeight = mWidth + (mWidth / 5);
    } else {
        //2 column layout.
        mWidth = (metrics.widthPixels) / 2;
        mHeight = mWidth + (mWidth / 3);
    }

}