List of usage examples for android.app Activity getString
@NonNull public final String getString(@StringRes int resId)
From source file:com.hybris.mobile.app.commerce.helper.CartHelperBase.java
/** * Called after adding/updating an item to the cart * * @param activity The activity that calls the method * @param requestId Identifier for the call * @param onAddToCart Listener for success/error after update * @param response Response data//from w w w . j a v a 2s . c o m */ private static void onReceiveAddToCartResponse(Activity activity, final String requestId, OnAddToCart onAddToCart, Response<CartModification> response) { UIUtils.showLoadingActionBar(activity, false); // Out of stock, we print an error if (response.getData().isOutOfStock()) { if (StringUtils.isNotBlank(response.getData().getStatusMessage())) { Alert.showError(activity, response.getData().getStatusMessage()); } if (onAddToCart != null) { onAddToCart.onAddToCartError(true); } } // Quantity not fulfilled, we print a warning else if (response.getData().isQuantityAddedNotFulfilled()) { if (StringUtils.isNotBlank(response.getData().getStatusMessage())) { Alert.showWarning(activity, response.getData().getStatusMessage()); } if (onAddToCart != null) { onAddToCart.onAddToCartError(false); } } // Otherwise success message else { Alert.showSuccess(activity, activity.getString(R.string.cart_update_item_confirm_message)); } if (onAddToCart != null) { onAddToCart.onAddToCart(response.getData()); } // Update the cart SessionHelper.updateCart(activity, requestId, false); }
From source file:pl.wasat.smarthma.ui.dialogs.LoginDialogFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/* ww w. j ava 2 s. c o m*/ mListener = (OnLoginDialogFragmentListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + activity.getString(R.string.must_implement) + OnLoginDialogFragmentListener.class.getSimpleName()); } }
From source file:com.christophergs.mbientbasic.ModuleFragmentBase.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Activity owner = getActivity(); if (!(owner instanceof FragmentBus)) { throw new ClassCastException(String.format(Locale.US, "%s %s", owner.toString(), owner.getString(R.string.error_fragment_bus))); }/* w w w . j a va 2 s . co m*/ fragBus = (FragmentBus) owner; owner.getApplicationContext().bindService(new Intent(owner, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:com.mbientlab.metawear.app.ModuleFragmentBase.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!(activity instanceof FragmentBus)) { throw new ClassCastException(String.format(Locale.US, "%s %s", activity.toString(), activity.getString(R.string.error_fragment_bus))); }// www . j av a 2 s .c o m fragBus = (FragmentBus) activity; activity.getApplicationContext().bindService(new Intent(activity, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:org.creativecommons.thelist.fragments.ExplainerFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {//from ww w . j a va2 s .c om mCallback = (OnClickListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + activity.getString(R.string.terms_callback_exception_message)); } }
From source file:org.creativecommons.thelist.fragments.TermsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from ww w .j a v a2 s. co m*/ mCallback = (TermsClickListener) activity; } catch (ClassCastException e) { throw new ClassCastException( activity.toString() + activity.getString(R.string.terms_callback_exception_message)); } }
From source file:com.todoroo.astrid.taskrabbit.TaskRabbitControlSet.java
/** Fire task rabbit if assigned **/ @Override/*from w w w . j av a 2 s . c om*/ public boolean showTaskRabbitForUser(String name, JSONObject json) { Activity fragActivity = fragment.getActivity(); if (fragActivity != null && name.equals(fragActivity.getString(R.string.actfm_EPA_task_rabbit))) { showTaskRabbitActivity(); return true; } return false; }
From source file:com.dnielfe.manager.utils.SimpleUtils.java
public static void createShortcut(Activity main, String path) { File file = new File(path); try {//w ww . j a va2 s .c om // Create the intent that will handle the shortcut Intent shortcutIntent = new Intent(main, Browser.class); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); shortcutIntent.putExtra(Browser.EXTRA_SHORTCUT, path); // The intent to send to broadcast for register the shortcut intent Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, file.getName()); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(main, R.drawable.ic_launcher)); intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); main.sendBroadcast(intent); Toast.makeText(main, main.getString(R.string.shortcutcreated), Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(main, main.getString(R.string.error), Toast.LENGTH_SHORT).show(); } }
From source file:com.bellman.bible.android.control.page.PageControl.java
/** send the current verse via social applications installed on user's device */// w w w.j a v a 2 s . co m public void shareVerse(VerseRange verseRange) { try { Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument(); String text = verseRange.getName() + "\n" + SwordContentFacade.getInstance().getCanonicalText(book, verseRange); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, text); // subject is used when user chooses to send verse via e-mail sendIntent.putExtra(Intent.EXTRA_SUBJECT, CurrentActivityHolder.getInstance().getApplication().getText(R.string.share_verse_subject)); Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity(); activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse))); } catch (Exception e) { Log.e(TAG, "Error sharing verse", e); Dialogs.getInstance().showErrorMsg("Error sharing verse"); } }
From source file:net.bible.android.control.page.PageControl.java
/** send the current verse via social applications installed on user's device *//* w w w . ja v a2 s . co m*/ public void shareVerse() { try { Book book = getCurrentPageManager().getCurrentPage().getCurrentDocument(); Key key = getCurrentPageManager().getCurrentPage().getSingleKey(); String text = key.getName() + "\n" + SwordContentFacade.getInstance().getCanonicalText(book, key); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, text); // subject is used when user chooses to send verse via e-mail sendIntent.putExtra(Intent.EXTRA_SUBJECT, BibleApplication.getApplication().getText(R.string.share_verse_subject)); Activity activity = CurrentActivityHolder.getInstance().getCurrentActivity(); activity.startActivity(Intent.createChooser(sendIntent, activity.getString(R.string.share_verse))); } catch (Exception e) { Log.e(TAG, "Error sharing verse", e); Dialogs.getInstance().showErrorMsg("Error sharing verse"); } }