androidx.annotation.IntegerRes Java Examples

The following examples show how to use androidx.annotation.IntegerRes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 获取 Integer
 * @param id resource identifier
 * @return Integer
 */
public static int getInteger(@IntegerRes final int id) {
    try {
        return DevUtils.getContext().getResources().getInteger(id);
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getInteger");
    }
    return -1;
}
 
Example #2
Source File: ResourceResolver.java    From litho with Apache License 2.0 5 votes vote down vote up
public int resolveIntRes(@IntegerRes int resId) {
  if (resId != 0) {
    Integer cached = mResourceCache.get(resId);
    if (cached != null) {
      return cached;
    }

    int result = mResources.getInteger(resId);
    mResourceCache.put(resId, result);

    return result;
  }

  return 0;
}
 
Example #3
Source File: ResourceResolver.java    From litho with Apache License 2.0 5 votes vote down vote up
public int resolveIntAttr(@AttrRes int attrResId, @IntegerRes int defResId) {
  TypedArray a = mTheme.obtainStyledAttributes(new int[] {attrResId});

  try {
    return a.getInt(0, resolveIntRes(defResId));
  } finally {
    a.recycle();
  }
}
 
Example #4
Source File: SettingsActivity.java    From TwistyTimer with GNU General Public License v3.0 5 votes vote down vote up
private MaterialDialog createAverageSeekDialog(@StringRes int prefKeyResID,
                                     int minValue, int maxValue, @IntegerRes int defaultValueRes) {

    final View dialogView = LayoutInflater.from(
            getActivity()).inflate(R.layout.dialog_settings_progress, null);
    final AppCompatSeekBar seekBar = dialogView.findViewById(R.id.seekbar);

    int defaultValue = getContext().getResources().getInteger(defaultValueRes);

    seekBar.setMax(maxValue);
    seekBar.setProgress(Prefs.getInt(prefKeyResID, defaultValue));

    return ThemeUtils.roundDialog(mContext, new MaterialDialog.Builder(mContext)
            .customView(dialogView, true)
            .positiveText(R.string.action_done)
            .negativeText(R.string.action_cancel)
            .onPositive((dialog, which) -> {
                final int seekProgress = seekBar.getProgress();

                Prefs.edit()
                        .putInt(prefKeyResID, seekProgress > minValue ? seekProgress : minValue)
                        .apply();
            })
            .neutralText(R.string.action_default)
            .onNeutral((dialog, which) -> Prefs.edit().putInt(prefKeyResID, defaultValue).apply())
            .build());
}
 
Example #5
Source File: AptoideUtils.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
public static int getInt(@IntegerRes int resId, Resources resources) {
  return resources.getInteger(resId);
}
 
Example #6
Source File: IntegerPreferenceProvider.java    From TowerCollector with Mozilla Public License 2.0 4 votes vote down vote up
@Override
Integer getPreferenceDefaultValue(@IntegerRes int defaultValueKey) {
    Resources resources = context.getResources();
    return resources.getInteger(defaultValueKey);
}
 
Example #7
Source File: Prefs.java    From TwistyTimer with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns an {@link Integer} given an {@link IntegerRes}
 * @param res an {@link IntegerRes}
 * @return an {@link Integer} associated with the given {@link IntegerRes}
 */
public static int getDefaultIntValue(@IntegerRes int res) {
    return TwistyTimer.getAppContext().getResources().getInteger(res);
}