Example usage for android.content Context getText

List of usage examples for android.content Context getText

Introduction

In this page you can find the example usage for android.content Context getText.

Prototype

@NonNull
public final CharSequence getText(@StringRes int resId) 

Source Link

Document

Return a localized, styled CharSequence from the application's package's default string table.

Usage

From source file:de.mrapp.android.bottomsheet.model.Item.java

/**
 * Creates a new item./* ww  w .  j a  v  a2 s.c  om*/
 *
 * @param context
 *         The context, which should be used, as an instance of the class {@link Context}. The
 *         context may not be null
 * @param id
 *         The item's id as an {@link Integer} value
 * @param resourceId
 *         The resource id of the item's title as an {@link Integer} value. The resource id must
 *         correspond to a valid string resource
 */
public Item(@NonNull final Context context, final int id, @StringRes final int resourceId) {
    this(id, context.getText(resourceId));
}

From source file:de.mrapp.android.validation.validators.AbstractValidator.java

/**
 * Sets the error message, which should be shown, if the validation fails.
 *
 * @param context/* ww w  .  j  a  va2 s. com*/
 *         The context, which should be used to retrieve the error message, as an instance of
 *         the class {@link Context}. The context may not be null
 * @param resourceId
 *         The resource ID of the string resource, which contains the error message, which
 *         should be set, as an {@link Integer} value. The resource ID must correspond to a
 *         valid string resource
 */
public final void setErrorMessage(@NonNull final Context context, @StringRes final int resourceId) {
    ensureNotNull(context, "The context may not be null");
    this.errorMessage = context.getText(resourceId);
}

From source file:com.google.android.gcm.demo.logic.quicktest.DownstreamHttpJsonQuickTest.java

@Override
public void execute(final Logger logger, final Context context, SimpleArrayMap<Integer, String> params) {
    final String apiKey = params.get(R.id.home_api_key);
    final String destination = params.get(R.id.home_destination);
    logger.log(Log.INFO, context.getText(R.string.quicktest_downstream_http_json).toString());
    new AsyncTask<Void, Void, Void>() {
        @Override//from  ww w .j  a  va 2 s .  co m
        protected Void doInBackground(Void... params) {
            final Message.Builder messageBuilder = new Message.Builder();
            GcmServerSideSender sender = new GcmServerSideSender(apiKey, logger);
            try {
                String response = sender.sendHttpJsonDownstreamMessage(destination, messageBuilder.build());
                MainActivity.showToast(context, R.string.downstream_toast_success, response);
            } catch (IOException ex) {
                logger.log(Log.INFO, "Downstream HTTP JSON failed:\nerror: " + ex.getMessage());
                MainActivity.showToast(context, R.string.downstream_toast_failure, ex.getMessage());
            }
            return null;
        }
    }.execute();
}

From source file:com.robwilliamson.healthyesther.fragment.dialog.AbstractAddNamedDialogFragment.java

@Override
public void onResume() {
    super.onResume();

    View view = Utils.checkNotNull(getView());
    Context context = Utils.checkNotNull(view.getContext());
    getNameTitle().setText(context.getText(valueNameId()));

    AutoCompleteTextView name = getNameTextView();
    name.setCompletionHint(getView().getContext().getText(valueCompletionHintId()));
    name.addTextChangedListener(new TextWatcher() {
        @Override//from w  ww.  j a v  a  2  s .  c  o  m
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String text = s.toString();
            AbstractAddNamedDialogFragment.this.newNameEntered(text);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    name.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String suggestion = (String) parent.getAdapter().getItem(position);
            AbstractAddNamedDialogFragment.this.suggestionSelected(suggestion, mSuggestions.get(suggestion));
        }
    });
    getOkButton().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onOk();
            dismiss();
        }
    });

    if (contentLayoutId() != null && !mInflatedContent) {
        View.inflate(getView().getContext(), contentLayoutId(), getContentArea());
        mInflatedContent = true;
    }

    updateSuggestionAdapter();
}

From source file:de.mrapp.android.bottomsheet.model.Item.java

/**
 * Sets the title of the item.//from  w  w w . j  a  va2  s  . c om
 *
 * @param context
 *         The context, which should be used, as an instance of the class {@link Context}. The
 *         context may not be null
 * @param resourceId
 *         The resource id of the title, which should be set, as an {@link Integer} value. The
 *         resource id must correspond to a valid string resource
 */
public final void setTitle(@NonNull final Context context, @StringRes final int resourceId) {
    ensureNotNull(context, "The context may not be null");
    setTitle(context.getText(resourceId));
}

From source file:org.failedprojects.anjaroot.InstallFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setHasOptionsMenu(true);// w  w  w .java  2 s  .com

    Context ctx = getActivity();
    installer = new Installer(ctx);

    // prepare dialog
    dialog = new ProgressDialog(ctx);
    dialog.setTitle(ctx.getText(R.string.installer_working_title));
    dialog.setMessage(ctx.getText(R.string.installer_working_message));
    dialog.setIndeterminate(true);
}

From source file:org.wahtod.wififixer.utility.NotifUtil.java

private static NotificationCompat.Builder generateBuilder(Context context, NotificationHolder holder) {
    /*/*from  w w  w .  j a va  2 s  . c  o m*/
     * If contentIntent != NULL, parcel existing contentIntent
    */
    Intent intent = new Intent(ACTION_POP_NOTIFICATION);
    /*
     * Create the delete intent, which pops the notification stack
     */
    PendingIntent delete = PendingIntent.getBroadcast(context, getPendingIntentCode(), intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    if (holder.contentIntent != null)
        intent.putExtra(PENDINGPARCEL, holder.contentIntent);
    else {
        throw new NullPointerException("Null contentIntent in NotifUtil.show");
    }
    /*
     * Set content intent to the prior intent, but with contentIntent as a parcel
     */
    PendingIntent content = PendingIntent.getBroadcast(context, getPendingIntentCode(), intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setTicker(holder.tickerText)
            .setWhen(System.currentTimeMillis()).setContentTitle(context.getText(R.string.app_name))
            .setContentIntent(content).setDeleteIntent(delete).setContentText(holder.message)
            .setAutoCancel(true).setSmallIcon(R.drawable.icon);

    if (getStackSize() > 1)
        builder = largeText(context, builder);
    return builder;
}

From source file:org.andstatus.app.msg.MessageViewItem.java

private void setRecipientName(Context context, StringBuilder messageDetails) {
    if (!TextUtils.isEmpty(recipientName)) {
        messageDetails.append(//from w ww .  ja  va 2 s.  c  om
                " " + String.format(context.getText(R.string.message_source_to).toString(), recipientName));
    }
}

From source file:com.gbozza.android.popularmovies.fragments.MovieGridFragment.java

/**
 * Display the specific error message in the TextView
 *
 * @param messageId the resource id of the error string
 *///from  w  ww .  jav  a  2  s  .co  m
public void showErrorMessage(int messageId, Context context) {
    mErrorMessageDisplay.setText(context.getText(messageId));
    mErrorMessageDisplay.setVisibility(View.VISIBLE);
}

From source file:com.silentcircle.contacts.list.PhoneNumberListAdapter.java

public PhoneNumberListAdapter(Context context) {
    super(context);
    setDefaultFilterHeaderText(R.string.list_filter_phones);
    mUnknownNameText = context.getText(android.R.string.unknownName);
}