Example usage for android.app Activity getResources

List of usage examples for android.app Activity getResources

Introduction

In this page you can find the example usage for android.app Activity getResources.

Prototype

@Override
    public Resources getResources() 

Source Link

Usage

From source file:com.rayman.v2ex.viewmodel.main.MainActivityVMModule.java

@Provides
@PerActivity//from   w  w w  . ja  v a 2s.  c  o m
MainActivityVM provideMainActivityVM(MainActivityP presenter, FragmentManager fragmentManager,
        Activity activity) {
    MainPagerAdapter mainPagerAdapter = new MainPagerAdapter(fragmentManager,
            activity.getResources().getStringArray(R.array.main_tab_title));
    MaterialMenuIconToolbar menuIconToolbar = new MaterialMenuIconToolbar(activity, Color.WHITE,
            MaterialMenuDrawable.Stroke.THIN) {
        @Override
        public int getToolbarViewId() {
            return R.id.toolbar;
        }
    };
    menuIconToolbar.setNeverDrawTouch(false);
    return new MainActivityVM(presenter, view, mainPagerAdapter, menuIconToolbar);
}

From source file:org.level28.android.moca.ui.banners.BannerFragment.java

@Override
protected void configureList(Activity activity, ListView listView) {
    super.configureList(activity, listView);

    if (activity.getResources().getBoolean(R.bool.dualPaned)) {
        // Don't show dividers in dual-pane mode, they're really ugly
        listView.setDividerHeight(0);//from w w  w  .j  a v a2  s. co m
    }
}

From source file:org.chromium.chrome.browser.ntp.IncognitoNewTabPage.java

/**
 * Constructs an Incognito NewTabPage./*from   w ww .  j  a v  a2 s.co m*/
 * @param activity The activity used to create the new tab page's View.
 */
public IncognitoNewTabPage(Activity activity) {
    mActivity = activity;

    mTitle = activity.getResources().getString(R.string.button_new_tab);
    mBackgroundColor = NtpStyleUtils.getBackgroundColorResource(activity.getResources(), true);
    mThemeColor = ApiCompatibilityUtils.getColor(activity.getResources(), R.color.incognito_primary_color);

    LayoutInflater inflater = LayoutInflater.from(activity);
    mIncognitoNewTabPageView = (IncognitoNewTabPageView) inflater.inflate(R.layout.new_tab_page_incognito,
            null);
    mIncognitoNewTabPageView.initialize(mIncognitoNewTabPageManager);

    TextView newTabIncognitoMessage = (TextView) mIncognitoNewTabPageView
            .findViewById(R.id.new_tab_incognito_message);
    newTabIncognitoMessage.setText(activity.getResources().getString(R.string.new_tab_incognito_message));
}

From source file:br.com.PartoHumanizado.fragment.base.ResStringArrayListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    stringArray = activity.getResources().getStringArray(this.stringArrayId);
}

From source file:edu.utexas.cs.bevomaps.MapDrawerVC.java

private void displaceIfNeeded(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        int id = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (id > 0) {
            View searchBox = activity.findViewById(R.id.drawer_header);
            ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) searchBox.getLayoutParams();

            params.topMargin = activity.getResources().getDimensionPixelSize(id);
            searchBox.setLayoutParams(params);
        }/*from   w w  w  .  jav a2s .c om*/
    }
}

From source file:com.tinyhydra.botd.BotdServerOperations.java

public static void GetTopTen(final Activity activity, final Handler handler, boolean override) {
    final SharedPreferences settings = activity.getSharedPreferences(Const.GenPrefs, 0);
    final List<JavaShop> TopTen = new ArrayList<JavaShop>();
    for (int i = 0; i < 10; i++) {
        TopTen.add(new JavaShop());
    }/*from   w w  w  .  jav  a 2s .  c o m*/
    if (settings.getLong(Const.LastTopTenQueryTime, 0) > (Calendar.getInstance().getTimeInMillis() - 180000)
            & !override) {
        Message msg = new Message();
        msg.arg1 = Const.CODE_GETTOPTEN;
        handler.sendMessage(msg);
    } else
        new Thread() {
            @Override
            public void run() {
                BufferedReader in = null;
                try {
                    HttpClient client = new DefaultHttpClient();
                    HttpGet request = new HttpGet();
                    request.setURI(new URI(activity.getResources().getString(R.string.server_url)));
                    HttpResponse response = client.execute(request);
                    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                    StringBuffer sb = new StringBuffer("");
                    String line = "";
                    while ((line = in.readLine()) != null) {
                        sb.append(line);
                    }
                    in.close();
                    SharedPreferences.Editor editor = settings.edit();
                    editor.putString(Const.LastTopTenQueryResults, sb.toString());
                    editor.putLong(Const.LastTopTenQueryTime, Calendar.getInstance().getTimeInMillis());
                    editor.commit();

                    Message msg = new Message();
                    msg.arg1 = Const.CODE_GETTOPTEN;
                    handler.sendMessage(msg);

                    // more generic error handling
                    //TODO: implement better error handling
                } catch (URISyntaxException usex) {
                    usex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } catch (ClientProtocolException cpex) {
                    cpex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } catch (IOException iex) {
                    iex.printStackTrace();
                    Utils.PostToastMessageToHandler(handler,
                            "Unable to retrieve Brew of the day. Poor signal? Please try again",
                            Toast.LENGTH_LONG);
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }.start();
}

From source file:com.jeffreyawest.weblogic.monitor.charting.DefaultPieChart.java

protected final TableRow getRow(final Activity pActivity, int pColor, String pValue) {

    TableRow row = new TableRow(pActivity);
    row.setPadding(2, 2, 2, 2);//ww w .j av  a  2 s. c  om

    pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size);

    TextView colorView = new TextView(pActivity);
    colorView.setBackgroundColor(pColor);
    colorView
            .setHeight((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size));
    colorView.setText("   ");
    colorView.setWidth((int) pActivity.getResources().getDimension(R.dimen.graph_fragment_legend_graphic_size));
    row.addView(colorView);

    TextView text = new TextView(pActivity);
    text.setText(pValue);
    text.setPadding(2, 2, 2, 2);
    text.setTextSize(15);
    row.addView(text);

    return row;
}

From source file:com.google.plus.wigwamnow.social.GoogleProvider.java

/**
 * Create an app activity for renting a {@link Wigwam}.
 *//*from  ww  w .j  a v  a 2 s. co  m*/
@Override
public boolean rent(Wigwam wigwam, Activity activity) {
    String host = activity.getResources().getString(R.string.external_host);
    // Write an app activity to Google Plus
    ItemScope target = new ItemScope.Builder().setUrl(host + "/wigwams/" + wigwam.getId()).build();
    ItemScope result = new ItemScope.Builder().setType("http://schemas.google.com/Reservation").build();
    Moment moment = new Moment.Builder().setType("http://schemas.google.com/ReserveActivity").setTarget(target)
            .setResult(result).build();

    PlusClient client = ((WigwamDetailActivity) activity).getPlusClient();

    if (client.isConnected()) {
        client.writeMoment(moment);
        return true;
    } else {
        return false;
    }
}

From source file:com.github.takahirom.motion_app.PhotoAdapter.java

PhotoAdapter(Activity activity, OnItemClickListener onItemClickListener) {
    this.activity = activity;
    this.onItemClickListener = onItemClickListener;
    final int[] placeholderColors = activity.getResources().getIntArray(R.array.loading_placeholders_light);
    loadingPlaceholders = new ColorDrawable[placeholderColors.length];
    for (int i = 0; i < placeholderColors.length; i++) {
        loadingPlaceholders[i] = new ColorDrawable(placeholderColors[i]);
    }/*from www  .  ja va 2 s . c om*/
}

From source file:com.google.plus.wigwamnow.social.GoogleProvider.java

/**
 * Initiate the hybrid authorization flow with Google+ by sending the one time code to the
 * server.  See {@link "https://developers.google.com/+/web/signin/server-side-flow"}
 * /*  ww  w  .ja v a  2 s .c o m*/
 * @param code the one time authorization flow, retrieved from {@link GoogleAuthUtil#getToken}
 */
private void initGoogleHybridFlow(String code, final Activity activity) {
    String host = activity.getResources().getString(R.string.external_host);
    final String endpoint = host + "/auth/gplus/hybrid.json";
    // Send the one time code and the Android redirect uri to the server, so the server can get
    // an access_token
    JSONObject params = new JSONObject();
    try {
        params.put("code", code);
        params.put("redirect_uri", activity.getResources().getString(R.string.redirect_uri));
    } catch (JSONException e1) {
        Log.e(TAG, "JSON Exception", e1);
        return;
    }

    JsonObjectRequest jor = new JsonObjectRequest(Request.Method.POST, endpoint, params,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject json) {
                    mPendingCodeSend = false;
                    // TODO(samstern): Refactor into listener
                    ((MainActivity) activity).recordCodeSent(SocialProviderConstants.GOOGLE, 1);
                    Log.i(TAG, json.toString());
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError e) {
                    mPendingCodeSend = false;
                    Log.e(TAG, "Code seding error", e);
                }
            });
    WigwamNow.getQueue().add(jor);
}