List of usage examples for android.app Activity getResources
@Override
public Resources getResources()
From source file:dev.drsoran.moloko.fragments.dialogs.RecurrencePickerDialogFragment.java
private void initEvAftWheel(boolean isEvery) { final Activity activity = getSherlockActivity(); final Resources res = activity.getResources(); evAftWheel.setViewAdapter(new ArrayWheelAdapter<String>(activity, new String[] { res.getString(R.string.dlg_recurr_picker_every), res.getString(R.string.dlg_recurr_picker_after) })); evAftWheel.setCurrentItem(isEvery ? 0 : 1); }
From source file:com.pomelodesign.cordova.metaio.MetaioPlugin.java
public String GetConfigFilePath(Activity action) { if (action == null) { return null; }/*w w w . j a va2s . c o m*/ int id = action.getResources().getIdentifier("config", "xml", action.getClass().getPackage().getName()); if (id == 0) { id = action.getResources().getIdentifier("cordova", "xml", action.getPackageName()); return null; } if (id == 0) { return null; } XmlResourceParser xml = action.getResources().getXml(id); int eventType = -1; while (eventType != XmlResourceParser.END_DOCUMENT) { if (eventType == XmlResourceParser.START_TAG) { String strNode = xml.getName(); if (strNode.equals("preference")) { String name = xml.getAttributeValue(null, "name").toLowerCase(Locale.getDefault()); if (name.equalsIgnoreCase("arelConfigPath")) { String arelConfigPath = xml.getAttributeValue(null, "value"); return arelConfigPath; } } } try { eventType = xml.next(); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } return null; }
From source file:com.firebase.ui.auth.provider.FacebookProvider.java
@Override public void startLogin(Activity activity) { mCallbackManager = CallbackManager.Factory.create(); LoginManager loginManager = LoginManager.getInstance(); loginManager.registerCallback(mCallbackManager, this); String[] permissions = activity.getResources().getStringArray(R.array.facebook_permissions); List<String> permissionsList = new ArrayList<>(Arrays.asList(permissions)); // Ensure we have email and public_profile scopes if (!permissionsList.contains(EMAIL)) { permissionsList.add(EMAIL);//from www . j a v a 2 s . c o m } if (!permissionsList.contains(PUBLIC_PROFILE)) { permissionsList.add(PUBLIC_PROFILE); } // Log in with permissions loginManager.logInWithReadPermissions(activity, permissionsList); }
From source file:github.daneren2005.dsub.activity.EditPlayActionActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.tasker_start_playing_title); setContentView(R.layout.edit_play_action); final Activity context = this; doNothing = context.getResources().getString(R.string.tasker_edit_do_nothing); shuffleCheckbox = (CheckBox) findViewById(R.id.edit_shuffle_checkbox); shuffleCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override// w w w. j a v a 2 s. c om public void onCheckedChanged(CompoundButton view, boolean isChecked) { startYearCheckbox.setEnabled(isChecked); endYearCheckbox.setEnabled(isChecked); genreButton.setEnabled(isChecked); } }); startYearCheckbox = (CheckBox) findViewById(R.id.edit_start_year_checkbox); startYearBox = (EditText) findViewById(R.id.edit_start_year); // Disable/enable number box if checked startYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { startYearBox.setEnabled(isChecked); } }); endYearCheckbox = (CheckBox) findViewById(R.id.edit_end_year_checkbox); endYearBox = (EditText) findViewById(R.id.edit_end_year); endYearCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { endYearBox.setEnabled(isChecked); } }); genreButton = (Button) findViewById(R.id.edit_genre_spinner); genreButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new LoadingTask<List<Genre>>(context, true) { @Override protected List<Genre> doInBackground() throws Throwable { MusicService musicService = MusicServiceFactory.getMusicService(context); return musicService.getGenres(false, context, this); } @Override protected void done(final List<Genre> genres) { List<String> names = new ArrayList<String>(); String blank = context.getResources().getString(R.string.select_genre_blank); names.add(doNothing); names.add(blank); for (Genre genre : genres) { names.add(genre.getName()); } final List<String> finalNames = names; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.shuffle_pick_genre).setItems( names.toArray(new CharSequence[names.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 1) { genreButton.setText(""); } else { genreButton.setText(finalNames.get(which)); } } }); AlertDialog dialog = builder.create(); dialog.show(); } @Override protected void error(Throwable error) { String msg; if (error instanceof OfflineException || error instanceof ServerTooOldException) { msg = getErrorMessage(error); } else { msg = context.getResources().getString(R.string.playlist_error) + " " + getErrorMessage(error); } Util.toast(context, msg, false); } }.execute(); } }); genreButton.setText(doNothing); offlineSpinner = (Spinner) findViewById(R.id.edit_offline_spinner); ArrayAdapter<CharSequence> offlineAdapter = ArrayAdapter.createFromResource(this, R.array.editServerOptions, android.R.layout.simple_spinner_item); offlineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); offlineSpinner.setAdapter(offlineAdapter); // Setup default for everything Bundle extras = getIntent().getBundleExtra(Constants.TASKER_EXTRA_BUNDLE); if (extras != null) { if (extras.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE)) { shuffleCheckbox.setChecked(true); } String startYear = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, null); if (startYear != null) { startYearCheckbox.setEnabled(true); startYearBox.setText(startYear); } String endYear = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, null); if (endYear != null) { endYearCheckbox.setEnabled(true); endYearBox.setText(endYear); } String genre = extras.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, doNothing); if (genre != null) { genreButton.setText(genre); } int offline = extras.getInt(Constants.PREFERENCES_KEY_OFFLINE, 0); if (offline != 0) { offlineSpinner.setSelection(offline); } } drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); }
From source file:com.vuze.android.remote.AndroidUtils.java
public static void showDialog(Activity activity, int titleID, CharSequence msg) { String title = activity.getResources().getString(titleID); showDialog(activity, title, msg);/*from w w w.ja v a 2 s .co m*/ }
From source file:com.android.argb.edhlc.Utils.java
public static Drawable getRoundedImage(Activity activity, String playerName, String playerDeck) { File p1CroppedImageFile = new File(activity.getFilesDir(), "image_" + playerName + "_" + playerDeck + ".png"); Bitmap bitmap;//from ww w . j a v a 2 s . co m if (p1CroppedImageFile.isFile()) bitmap = BitmapFactory.decodeFile(p1CroppedImageFile.getAbsolutePath()); else bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.avatar_holder); RoundedAvatarDrawable roundedImage = new RoundedAvatarDrawable(Utils.getSquareBitmap(bitmap)); roundedImage.setAntiAlias(true); return roundedImage; }
From source file:com.camnter.easyrecyclerview.widget.decorator.EasyDividerItemDecoration.java
/** * set divider color//from w ww .ja v a 2 s. c om * * @param activity activity * @param drawableId drawableId */ private void setDivider(Activity activity, int drawableId) { try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { this.mDivider = activity.getTheme().getDrawable(drawableId); } else { this.mDivider = activity.getResources().getDrawable(drawableId); } } catch (Exception e) { e.printStackTrace(); } /** * set default divider color */ if (this.mDivider == null) this.setDefaultDivider(activity); }
From source file:com.vuze.android.remote.AndroidUtils.java
public static void showConnectionError(Activity activity, int errMsgID, boolean allowContinue) { String errMsg = activity.getResources().getString(errMsgID); showConnectionError(activity, errMsg, allowContinue); }
From source file:com.hartcode.hartweather.search.SearchItemViewHolder.java
public SearchItemViewHolder(@NonNull View itemView, @NonNull Activity activity) { super(itemView); this.view = itemView; this.txtCityName = (TextView) this.view.findViewById(R.id.txtCityName); this.txtWeatherTemp = (TextView) this.view.findViewById(R.id.txtWeatherTemp); this.activity = activity; this.view.setOnClickListener(this); this.resources = activity.getResources(); }
From source file:sg.com.utrix.skeleton.app.sample.util.ImageLoader.java
/** * Creates an ImageLoader with Bitmap memory cache. No default placeholder image will be shown * while the image is being fetched and loaded. *//*from ww w.j a va 2s . c o m*/ public ImageLoader(Activity activity) { super(newRequestQueue(activity), BitmapCache.getInstance(activity.getFragmentManager())); mResources = activity.getResources(); }