Java Code Examples for android.support.annotation.StringRes

The following are top voted examples for showing how to use android.support.annotation.StringRes. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: play-billing-codelab   File: GamePlayActivity.java   View source code 6 votes vote down vote up
/**
 * Show an alert dialog to the user
 * @param messageId String id to display inside the alert dialog
 * @param optionalParam Optional attribute for the string
 */
@UiThread
void alert(@StringRes int messageId, @Nullable Object optionalParam) {
    if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
        throw new RuntimeException("Dialog could be shown only from the main thread");
    }

    AlertDialog.Builder bld = new AlertDialog.Builder(this);
    bld.setNeutralButton("OK", null);

    if (optionalParam == null) {
        bld.setMessage(messageId);
    } else {
        bld.setMessage(getResources().getString(messageId, optionalParam));
    }

    bld.create().show();
}
 
Example 2
Project: HeadlineNews   File: ToastUtils.java   View source code 5 votes vote down vote up
/**
 * 安全地显示长时吐司
 *
 * @param resId 资源Id
 */
public static void showLongSafe(@StringRes final int resId) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_LONG);
        }
    });
}
 
Example 3
Project: AndProx   File: TextInputDialogFragment.java   View source code 5 votes vote down vote up
public static TextInputDialogFragment newInstance(@StringRes int summary, TextInputDialogListener listener) {
    TextInputDialogFragment f = new TextInputDialogFragment();

    Bundle args = new Bundle();
    args.putInt(SUMMARY_RES, summary);
    f.setArguments(args);

    f.mListener = listener;
    return f;
}
 
Example 4
Project: Rx_java2_soussidev   File: BuilderJoinerAndroid.java   View source code 5 votes vote down vote up
@NonNull @Override
public BuilderJoinerAndroid setPositiveButton(
        @StringRes int textId,
        @Nullable DialogInterface.OnClickListener listener)
{
    return (BuilderJoinerAndroid) super.setPositiveButton(textId, listener);
}
 
Example 5
Project: BrotherWeather   File: ToastUtils.java   View source code 5 votes vote down vote up
/**
 * 安全地显示短时吐司
 *
 * @param resId 资源Id
 * @param args  参数
 */
public static void showShortSafe(final @StringRes int resId, final Object... args) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_SHORT, args);
        }
    });
}
 
Example 6
Project: CleanArchitechture   File: BaseFragmentMvp.java   View source code 5 votes vote down vote up
public void onLoadingEmpty(@StringRes int error){
    if (mTvError != null){
        mTvError.setText(error);
        mTvError.setVisibility(View.VISIBLE);
        mProgressLoading.setVisibility(View.GONE);
        mContainSubView.setVisibility(View.GONE);
    }
}
 
Example 7
Project: SimpleDialogFragments   File: Input.java   View source code 5 votes vote down vote up
/**
 * Provide an array of suggestions to be shown while the user is typing
 * This enables the auto-complete behaviour.
 *
 * @param suggestionStringResArray array of string resources to suggest
 */
public Input suggest(@StringRes int... suggestionStringResArray){
    if (suggestionStringResArray != null && suggestionStringResArray.length > 0) {
        this.suggestionStringResArray = suggestionStringResArray;
    }
    return this;
}
 
Example 8
Project: espresso-support   File: AccessibilityViewMatchers.java   View source code 5 votes vote down vote up
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static Matcher<? super View> withUsageHintOnLongClick(@StringRes final int resourceId) {
    return new TypeSafeMatcher<View>() {

        private String resourceName;
        private String expectedText;

        @Override
        protected boolean matchesSafely(View view) {
            if (!view.isLongClickable()) {
                return false;
            }

            expectedText = view.getResources().getString(resourceId);
            resourceName = view.getResources().getResourceEntryName(resourceId);

            if (expectedText == null) {
                return false;
            }

            AccessibilityNodeInfo.AccessibilityAction clickAction = findAction(view, AccessibilityNodeInfo.ACTION_LONG_CLICK);
            return expectedText.equals(clickAction.getLabel());
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("is long clickable and has custom usage hint for ACTION_LONG_CLICK from resource id: ").appendValue(resourceId);
            appendResourceNameAndExpectedTextToDescription(description, resourceName, expectedText);
        }
    };
}
 
Example 9
Project: AndroidDevSamples   File: ToastUtil.java   View source code 5 votes vote down vote up
@UiThread
public static void showLong(Context context, @StringRes int message) {
    Toast toast = getToast(context);
    if (toast != null) {
        toast.setText(message);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.show();
    }
}
 
Example 10
Project: Pocket-Plays-for-Twitch   File: DialogService.java   View source code 5 votes vote down vote up
private static MaterialSimpleListItem getThemeDialogAdapterItem(@StringRes int title, @DrawableRes int icon, String currentTheme, Activity activity) {
	MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(activity)
			.content(title)
			.icon(icon);

	return builder.build();
}
 
Example 11
Project: Phoenix-for-VK   File: GifPagerFragment.java   View source code 5 votes vote down vote up
@Override
public void setToolbarSubtitle(@StringRes int titleRes, Object... params) {
    ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
    if (Objects.nonNull(actionBar)) {
        actionBar.setSubtitle(getString(titleRes, params));
    }
}
 
Example 12
Project: AndroidMuseumBleManager   File: MyAlertDialog.java   View source code 5 votes vote down vote up
/**
 * 单个按钮,显示需要调用show()
 *
 * @param context
 * @param messageResId
 * @param postBtResId
 * @param postListener
 */
public static AlertDialog getDialog(final Context context, @StringRes int messageResId, @StringRes int postBtResId
        , DialogInterface.OnClickListener postListener, boolean cancelable) {
    AlertDialog dialog = new AlertDialog.Builder(context)
            .setPositiveButton(postBtResId, postListener)
            .setCancelable(cancelable)
            .setMessage(messageResId)
            .create();
    return dialog;
}
 
Example 13
Project: AndroidDevSamples   File: ToastUtil.java   View source code 5 votes vote down vote up
@UiThread
public static void showShort(Context context, @StringRes int message) {
    Toast toast = getToast(context);
    if (toast != null) {
        toast.setText(message);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.show();
    }
}
 
Example 14
Project: Android-DialogExperiment   File: AwesomeDialogFragment.java   View source code 5 votes vote down vote up
public static AwesomeDialogFragment newInstance(@StringRes int message, @StringRes int positive, @StringRes int negative) {
    AwesomeDialogFragment fragment = new AwesomeDialogFragment();
    Bundle bundle = new Bundle();
    bundle.putInt(KEY_MESSAGE, message);
    bundle.putInt(KEY_POSITIVE, positive);
    bundle.putInt(KEY_NEGATIVE, negative);
    fragment.setArguments(bundle);
    return fragment;
}
 
Example 15
Project: Android-UtilCode   File: ToastUtils.java   View source code 5 votes vote down vote up
/**
 * 安全地显示短时吐司
 *
 * @param resId 资源Id
 */
public static void showShortSafe(final @StringRes int resId) {
    sHandler.post(new Runnable() {
        @Override
        public void run() {
            show(resId, Toast.LENGTH_SHORT);
        }
    });
}
 
Example 16
Project: valifi   File: ValiFieldText.java   View source code 4 votes vote down vote up
public ValiFieldText addMinLengthValidator(@StringRes int errorResource, int minLength) {
	String errorMessage = getString(errorResource, minLength);
	return addMinLengthValidator(errorMessage, minLength);
}
 
Example 17
Project: AppUpdate   File: CheckAppUpdate.java   View source code 4 votes vote down vote up
private void setButtonText(@StringRes int buttonText) {
    this.buttonText = buttonText;
}
 
Example 18
Project: boohee_v5.6   File: ActionBarDrawerToggle.java   View source code 4 votes vote down vote up
public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, @DrawableRes int drawerImageRes, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) {
    this(activity, drawerLayout, !assumeMaterial(activity), drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes);
}
 
Example 19
Project: disclosure-android-app   File: LibraryDetailActivity.java   View source code 4 votes vote down vote up
@Override public void notify(@StringRes int id) {
  Toast.makeText(this, id, Toast.LENGTH_SHORT).show();
}
 
Example 20
Project: javaide   File: ProgressDialog.java   View source code 4 votes vote down vote up
public ProgressDialog(Context context, @StringRes int titleRes) {
    this(context, context.getString(titleRes));
}
 
Example 21
Project: DOUSalaries   File: BaseFragment.java   View source code 4 votes vote down vote up
@Override
public void onError(@StringRes int resId) {
    if (baseActivity != null) {
        baseActivity.onError(resId);
    }
}
 
Example 22
Project: EasySP   File: EasySP.java   View source code 4 votes vote down vote up
public Set<String> getStringSet(@StringRes int key) {
    return getStringSet(mContext.getString(key));
}
 
Example 23
Project: ReplyMessage   File: SharedPreferencesUtils.java   View source code 4 votes vote down vote up
public boolean contains(@StringRes int key) {
    return contains(mContext.getString(key));
}
 
Example 24
Project: LiteReader   File: Toaster.java   View source code 4 votes vote down vote up
public static void toast(Context context, @StringRes int stringRes) {
    toast(context, context.getResources().getString(stringRes), Toast.LENGTH_SHORT);
}
 
Example 25
Project: OpenYOLO-Android   File: RetrieveTestPageFragment.java   View source code 4 votes vote down vote up
private void showSnackbar(@StringRes int messageId) {
    Snackbar.make(getView(), messageId, Snackbar.LENGTH_SHORT).show();
}
 
Example 26
Project: cortado   File: Negated.java   View source code 4 votes vote down vote up
@IdeSuggestion
@Override
public final Cortado.And.ViewInteraction withHint(@StringRes int resourceId) {
    return super.withHint(resourceId);
}
 
Example 27
Project: CurrentActivity   File: ClipboardUtils.java   View source code 4 votes vote down vote up
public static void copyToClipboard(@NonNull Context context, @StringRes int resId, String text) {
    copyToClipboard(context, context.getString(resId), text);
}
 
Example 28
Project: GitHub   File: BaseSubView.java   View source code 4 votes vote down vote up
@Override
public void showMessage(@StringRes int resId) {
    if (mParentMvpView != null) {
        mParentMvpView.showMessage(resId);
    }
}
 
Example 29
Project: GitHub   File: MaterialDialog.java   View source code 4 votes vote down vote up
@UiThread
public final void setContent(@StringRes int newContentRes, @Nullable Object... formatArgs) {
    setContent(builder.context.getString(newContentRes, formatArgs));
}
 
Example 30
Project: cortado   File: Negated.java   View source code 4 votes vote down vote up
@IdeSuggestion
@Override
public final Cortado.Or.ViewInteraction withHint(@StringRes int resourceId) {
    return super.withHint(resourceId);
}
 
Example 31
Project: MultiSelecter   File: BaseViewHolder.java   View source code 4 votes vote down vote up
public BaseViewHolder setText(@IdRes int viewId, @StringRes int strId) {
    TextView view = getView(viewId);
    view.setText(strId);
    return this;
}
 
Example 32
Project: CoachMarks   File: PopUpCoachMarkPresenter.java   View source code 4 votes vote down vote up
protected void setMessageForCoachMarkText(@StringRes int messageForCoachMarkTextRes) {
    mPresentation.setCoachMarkMessage(
            mStringResourceProvider.getStringFromResource(messageForCoachMarkTextRes));
}
 
Example 33
Project: GitHub   File: MaterialDialog.java   View source code 4 votes vote down vote up
@UiThread
public final void setTitle(@StringRes int newTitleRes, @Nullable Object... formatArgs) {
    setTitle(builder.context.getString(newTitleRes, formatArgs));
}
 
Example 34
Project: ImageSaveandShare   File: BottomDialog.java   View source code 4 votes vote down vote up
public Builder setTitle(@StringRes int titleRes) {
    setTitle(this.context.getString(titleRes));
    return this;
}
 
Example 35
Project: GitHub   File: BaseViewHolder.java   View source code 4 votes vote down vote up
public BaseViewHolder setText(@IdRes int viewId, @StringRes int strId) {
    TextView view = getView(viewId);
    view.setText(strId);
    return this;
}
 
Example 36
Project: memetastic   File: AppSettingsBase.java   View source code 4 votes vote down vote up
public int getColor(@StringRes int keyResourceId, @ColorRes int defaultColor, final SharedPreferences... pref) {
    return gp(pref).getInt(rstr(keyResourceId), rcolor(defaultColor));
}
 
Example 37
Project: AIMSICDL   File: SmsDetector.java   View source code 4 votes vote down vote up
@StringRes
public int getTitle() {
    return title;
}
 
Example 38
Project: lex   File: LexList.java   View source code 4 votes vote down vote up
@NonNull
public LexList twoItemSeparator(@StringRes int stringRes) {
    return twoItemSeparator(Lex.resources.getString(stringRes));
}
 
Example 39
Project: NotificationStyles   File: BigText.java   View source code 4 votes vote down vote up
public BigText bigContentTitle (@StringRes int title) {
    return bigContentTitle(getCenter().getContext().getText(title));
}
 
Example 40
Project: Programmers   File: ContextMenuItem.java   View source code 4 votes vote down vote up
public void setLabel(@StringRes int label) {
    this.label = label;
}