Java Code Examples for android.support.annotation.IntegerRes

The following are top voted examples for showing how to use android.support.annotation.IntegerRes. 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: chromium-for-android-56-debug-video   File: StatusCardViewHolder.java   View source code 6 votes vote down vote up
public void onBindViewHolder(final DataSource item) {
    super.onBindViewHolder();

    mTitleView.setText(item.getHeader());
    mBodyView.setText(item.getDescription());

    @IntegerRes
    int actionLabel = item.getActionLabel();
    if (actionLabel != 0) {
        mActionView.setText(actionLabel);
        mActionView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                item.performAction(v.getContext());
            }
        });
        mActionView.setVisibility(View.VISIBLE);
    } else {
        mActionView.setVisibility(View.GONE);
    }
}
 
Example 2
Project: AndroidChromium   File: StatusCardViewHolder.java   View source code 6 votes vote down vote up
public void onBindViewHolder(final DataSource item) {
    super.onBindViewHolder();

    mTitleView.setText(item.getHeader());
    mBodyView.setText(item.getDescription());

    @IntegerRes
    int actionLabel = item.getActionLabel();
    if (actionLabel != 0) {
        mActionView.setText(actionLabel);
        mActionView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                item.performAction(v.getContext());
            }
        });
        mActionView.setVisibility(View.VISIBLE);
    } else {
        mActionView.setVisibility(View.GONE);
    }
}
 
Example 3
Project: external-resources   File: ExternalResources.java   View source code 6 votes vote down vote up
/**
 * Return an integer associated with a particular resource key.
 * This resource can come from resources you provided via the URL or via default resources.
 *
 * @param key The desired resource key.
 * @return Returns the integer value contained in the resource.
 * @throws NotFoundException Throws NotFoundException if the given key does not exist.
 */
public int getInteger(@NonNull String key) throws NotFoundException {
  Resource resource = resources.get(key);
  if (null != resource && null != resource.getAsInt()) {
    return resource.getAsInt();
  }

  @IntegerRes int resId = getApplicationResourceIdentifier(key, "integer");

  if (0 != resId) {
    int value = context.getResources().getInteger(resId);
    resources.add(key, new Resource(value));

    return value;
  }

  throw new NotFoundException("Integer resource with key: " + key);
}
 
Example 4
Project: 365browser   File: StatusCardViewHolder.java   View source code 6 votes vote down vote up
public void onBindViewHolder(final DataSource item) {
    super.onBindViewHolder();

    mTitleView.setText(item.getHeader());
    mBodyView.setText(item.getDescription());

    @IntegerRes
    int actionLabel = item.getActionLabel();
    if (actionLabel != 0) {
        mActionView.setText(actionLabel);
        mActionView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                SuggestionsMetrics.recordCardActionTapped();
                item.performAction(v.getContext());
            }
        });
        mActionView.setVisibility(View.VISIBLE);
    } else {
        mActionView.setVisibility(View.GONE);
    }
}
 
Example 5
Project: SkinFramework   File: ComposedResources.java   View source code 5 votes vote down vote up
@Override
public int getInteger(@IntegerRes int id) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getInteger(realId);
    }
    return super.getInteger(id);
}
 
Example 6
Project: CameraButton   File: TypedArrayHelper.java   View source code 5 votes vote down vote up
static int getInteger(Context context,
                      TypedArray array,
                      @StyleableRes int attr,
                      @IntegerRes int defaultIntRes) {

    return array.getInteger(
            attr, context.getResources().getInteger(defaultIntRes));
}
 
Example 7
Project: TimeSkyBackground   File: SkyTimeBackgroundView.java   View source code 5 votes vote down vote up
public void setBackgroundGradient(@IntegerRes  int i, @IntegerRes int ii, @IntegerRes int iii) {
    mSkyTime = Time.CUSTOM;

    mDrawables[0] = i;
    mDrawables[1] = ii;
    mDrawables[2] = iii;
}
 
Example 8
Project: TenguChat   File: XmppConnectionService.java   View source code 5 votes vote down vote up
public long getLongPreference(String name, @IntegerRes int res) {
	long defaultValue = getResources().getInteger(res);
	try {
		return Long.parseLong(getPreferences().getString(name,String.valueOf(defaultValue)));
	} catch (NumberFormatException e) {
		return defaultValue;
	}
}
 
Example 9
Project: PageIndicatorView   File: PreferencesHelper.java   View source code 5 votes vote down vote up
/**
 * Get an integer from preferences
 *
 * @param context      application context
 * @param key          preference key
 * @param defaultValue default value
 * @return integer
 */
public static int getInteger(@NonNull Context context, @StringRes int key, @IntegerRes int defaultValue) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE);
    String integerAsString = sharedPreferences.getString(context.getString(key), null);

    if (integerAsString == null) {
        return context.getResources().getInteger(defaultValue);
    } else {
        return Integer.valueOf(integerAsString);
    }
}
 
Example 10
Project: external-resources   File: ExternalResources.java   View source code 5 votes vote down vote up
/**
 * Return an integer associated with a particular resource ID.
 * This resource can come from resources you provided via the URL or via default resources.
 *
 * @param resId The desired resource identifier, as generated by the aapt
 * tool. This integer encodes the package, type, and resource
 * entry. The value 0 is an invalid identifier.
 * @return Returns the integer value contained in the resource.
 * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
 */
public int getInteger(@IntegerRes int resId) throws NotFoundException {
  String key = getApplicationResourceEntryName(resId);

  if (null != key) {
    Resource resource = resources.get(key);
    if (null != resource && null != resource.getAsInt()) {
      return resource.getAsInt();
    }
  }

  throw new NotFoundException("Integer resource with resId: " + resId);
}
 
Example 11
Project: PracticeDemo   File: BitmapUtils.java   View source code 5 votes vote down vote up
/**
 * 给bitmap着色
 * @param sourceBitmap
 * @param color  rgb
 * @return
 */
public static Bitmap changeBitmapColor(@NonNull Bitmap sourceBitmap, @IntegerRes int color) {

    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
            sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
    Paint p = new Paint();
    ColorFilter filter = new LightingColorFilter(color, 1);
    p.setColorFilter(filter);

    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, p);
    return resultBitmap;
}
 
Example 12
Project: Pix-Art-Messenger   File: XmppConnectionService.java   View source code 5 votes vote down vote up
public long getLongPreference(String name, @IntegerRes int res) {
    long defaultValue = getResources().getInteger(res);
    try {
        return Long.parseLong(getPreferences().getString(name,String.valueOf(defaultValue)));
    } catch (NumberFormatException e) {
        return defaultValue;
    }
}
 
Example 13
Project: Conversations   File: XmppConnectionService.java   View source code 5 votes vote down vote up
public long getLongPreference(String name, @IntegerRes int res) {
	long defaultValue = getResources().getInteger(res);
	try {
		return Long.parseLong(getPreferences().getString(name, String.valueOf(defaultValue)));
	} catch (NumberFormatException e) {
		return defaultValue;
	}
}
 
Example 14
Project: Material-Motion   File: BaseFragment.java   View source code 4 votes vote down vote up
protected int duration(@IntegerRes int resource){
    return getResources().getInteger(resource);
}
 
Example 15
Project: disclosure-android-app   File: AppIconLoader.java   View source code 4 votes vote down vote up
public Builder withPlaceholder(@IntegerRes Integer placeholderRes) {
  this.placeholderRes = placeholderRes;
  return this;
}
 
Example 16
Project: RLibrary   File: UIIViewImpl.java   View source code 4 votes vote down vote up
public int getInteger(@IntegerRes int id) {
    return getResources().getInteger(id);
}
 
Example 17
Project: tribbble   File: TribbbleApp.java   View source code 4 votes vote down vote up
public static int integer(@IntegerRes int resId) {
  return sContext.getResources().getInteger(resId);
}
 
Example 18
Project: CanDialog   File: CanDialog.java   View source code 4 votes vote down vote up
public Builder setIcon(@IntegerRes int resId) {
    mDialog.setIcon(resId);

    return this;
}
 
Example 19
Project: CanDialog   File: CanDialog.java   View source code 4 votes vote down vote up
public Builder setFullBackgroundResource(@IntegerRes int rid) {
    mDialog.setFullBackgroundResource(rid);

    return this;
}
 
Example 20
Project: xowa_android   File: ShareHandler.java   View source code 4 votes vote down vote up
private int getInteger(@IntegerRes int id) {
    return getResources().getInteger(id);
}
 
Example 21
Project: RoseBase   File: SPUtil.java   View source code 4 votes vote down vote up
@IntegerRes
public static int getInt(Context context, String key, int defaultInt) {
    return getSharedPreferences(context).getInt(key, defaultInt);
}
 
Example 22
Project: aptoide-client-v8   File: AptoideUtils.java   View source code 4 votes vote down vote up
public static int getInt(@IntegerRes int resId, Resources resources) {
  return resources.getInteger(resId);
}
 
Example 23
Project: StraaS-android-sdk-sample   File: Utils.java   View source code 4 votes vote down vote up
public static void fadeOutView(@NonNull final View view, @IntegerRes int durationRes, Animator.AnimatorListener listener) {
    fadeOutView(view, durationRes, listener, 0);
}
 
Example 24
Project: StraaS-android-sdk-sample   File: Utils.java   View source code 4 votes vote down vote up
public static void fadeOutView(@NonNull final View view, @IntegerRes int durationRes, Animator.AnimatorListener listener, long startDelay) {
    long duration = view.getResources().getInteger(durationRes);
    fadeOutView(view, duration, listener, startDelay);
}
 
Example 25
Project: StraaS-android-sdk-sample   File: Utils.java   View source code 4 votes vote down vote up
public static void fadeInView(@NonNull final View view, @IntegerRes int durationRes, Animator.AnimatorListener listener) {
    long duration = view.getResources().getInteger(durationRes);
    fadeInView(view, duration, listener);
}
 
Example 26
Project: Images-to-PDF   File: Home.java   View source code 4 votes vote down vote up
public int integer(@IntegerRes int resId) {
    return getResources().getInteger(resId);
}
 
Example 27
Project: orz   File: BaseUtils.java   View source code 4 votes vote down vote up
public static int getIntOfRes(Context context, @IntegerRes int res) {
    return context.getResources().getInteger(res);
}
 
Example 28
Project: rose   File: SPUtil.java   View source code 4 votes vote down vote up
@IntegerRes
public static int getInt(Context context, String key, int defaultInt) {
    return getSharedPreferences(context).getInt(key, defaultInt);
}
 
Example 29
Project: Android-App-Template   File: ResourcesUtil.java   View source code 4 votes vote down vote up
public static int getInteger(@IntegerRes int integerRes) {
    return ContextUtil.getResources().getInteger(integerRes);
}
 
Example 30
Project: EnumResources   File: EnumResources.java   View source code 4 votes vote down vote up
public EnumAssociation assocInteger(@IntegerRes final int integerRes) {
    _associations.put(INTEGER_FIELD_INDEX, integerRes);

    return this;
}
 
Example 31
Project: EnumResources   File: EnumResources.java   View source code 4 votes vote down vote up
public EnumAssociation assocInteger(@IntegerRes final int integerRes, final Enum<?> enumValue) {
    _enumAssociations.put(enumValue.ordinal(), integerRes);

    return this;
}
 
Example 32
Project: EnumResources   File: EnumResources.java   View source code 4 votes vote down vote up
@IntegerRes public int getIntegerRes() {
	return _associations.get(INTEGER_FIELD_INDEX);
}
 
Example 33
Project: EnumResources   File: EnumResources.java   View source code 4 votes vote down vote up
@IntegerRes public int getIntegerRes(final Enum<?> enumValue) {
	return _enumAssociations.get(enumValue.ordinal());
}
 
Example 34
Project: DebugDrawer   File: DebugDrawer.java   View source code 4 votes vote down vote up
/**
 * Set the background color for the Slider from a Resource.
 * This is the view containing the list.
 */
public Builder backgroundColorRes(@IntegerRes int sliderBackgroundColorRes) {
    this.sliderBackgroundColorRes = sliderBackgroundColorRes;
    return this;
}
 
Example 35
Project: sprockets-android   File: Animators.java   View source code 4 votes vote down vote up
private static ViewPropertyAnimator scale(View view, float size, TimeInterpolator interpolator,
                                          @IntegerRes int duration) {
    return view.animate().scaleX(size).scaleY(size).setInterpolator(interpolator)
            .setDuration(view.getResources().getInteger(duration));
}
 
Example 36
Project: Print   File: PrintView.java   View source code 4 votes vote down vote up
@Override
public void setIconCodeRes(@IntegerRes int resId) {
    getIcon().setIconCodeRes(resId);
}
 
Example 37
Project: Print   File: PrintDrawable.java   View source code 4 votes vote down vote up
@Override
public void setIconCodeRes(@IntegerRes int resId) {
    setIconCode(mContext.getResources().getInteger(resId));
}
 
Example 38
Project: Print   File: PrintDrawable.java   View source code 4 votes vote down vote up
public Builder iconCodeRes(@IntegerRes int resId) {
    return iconCode(mContext.getResources().getInteger(resId));
}
 
Example 39
Project: Print   File: PrintButton.java   View source code 4 votes vote down vote up
@Override
public void setIconCodeRes(@IntegerRes int resId) {
    getIcon().setIconCodeRes(resId);
}
 
Example 40
Project: Qiitanium   File: AppFragment.java   View source code 4 votes vote down vote up
protected int getInteger(@IntegerRes int resId) {
  return ResUtils.getInteger(getContext(), resId);
}