use of android.support.annotation.CheckResult in project Rocket by mozilla-tw.
the class RequestOptions method optionalTransform.
/**
* Applies the given {@link Transformation} for
* {@link Bitmap Bitmaps} to the default types ({@link Bitmap},
* {@link android.graphics.drawable.BitmapDrawable}, and ignores unknown types.
*
* <p>This will override previous calls to {@link #dontTransform()}.
*
* @param transformation Any {@link Transformation} for {@link Bitmap}s.
* @see #transform(Transformation)
* @see #transform(Class, Transformation)
*/
// Guaranteed to modify the current object by the isAutoCloneEnabledCheck.
@SuppressWarnings("CheckResult")
@CheckResult
public RequestOptions optionalTransform(Transformation<Bitmap> transformation) {
if (isAutoCloneEnabled) {
return clone().optionalTransform(transformation);
}
optionalTransform(Bitmap.class, transformation);
// TODO: remove BitmapDrawable decoder and this transformation.
optionalTransform(BitmapDrawable.class, new BitmapDrawableTransformation(transformation));
return selfOrThrowIfLocked();
}
use of android.support.annotation.CheckResult in project glide by bumptech.
the class RequestOptions method clone.
/**
* Returns a copy of this request builder with all of the options put so far on this builder.
*
* <p> This method returns a "deep" copy in that all non-immutable arguments are copied such that
* changes to one builder will not affect the other builder. However, in addition to immutable
* arguments, the current model is not copied copied so changes to the model will affect both
* builders. </p>
*
* <p> Even if this object was locked, the cloned object returned from this method will not be
* locked. </p>
*/
@SuppressWarnings({ "unchecked", // we don't want to throw to be user friendly
"PMD.CloneThrowsCloneNotSupportedException" })
@CheckResult
@Override
public RequestOptions clone() {
try {
RequestOptions result = (RequestOptions) super.clone();
result.options = new Options();
result.options.putAll(options);
result.transformations = new CachedHashCodeArrayMap<>();
result.transformations.putAll(transformations);
result.isLocked = false;
result.isAutoCloneEnabled = false;
return result;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
use of android.support.annotation.CheckResult in project MaterialFBook by ZeeRooo.
the class CookingAToast method cooking.
@CheckResult
public static Toast cooking(Context context, CharSequence message_to_show, int text_color, int background, int icon_toast, boolean duration) {
View view = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.cooking_a_toast, null);
view.setBackgroundColor(background);
AppCompatImageView icon = (AppCompatImageView) view.findViewById(R.id.icon);
icon.setImageResource(icon_toast);
AppCompatTextView message = (AppCompatTextView) view.findViewById(R.id.message);
message.setText(message_to_show);
message.setTextColor(text_color);
Toast toast = new Toast(context);
toast.setView(view);
toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0);
if (duration) {
toast.setDuration(Toast.LENGTH_LONG);
} else {
toast.setDuration(Toast.LENGTH_SHORT);
}
return toast;
}
use of android.support.annotation.CheckResult in project edx-app-android by edx.
the class ParsingUtil method getColorFromResource.
@CheckResult
public static int getColorFromResource(@NonNull Context context, @NonNull String packageName, @NonNull String resName) {
Resources resources = context.getResources();
int resId = resources.getIdentifier(resName, "color", packageName);
if (resId <= 0)
return Integer.MAX_VALUE;
return resources.getColor(resId);
}
use of android.support.annotation.CheckResult in project edx-app-android by edx.
the class ParsingUtil method getPxFromDimen.
@CheckResult
public static float getPxFromDimen(@NonNull Context context, @NonNull String packageName, @NonNull String resName) {
Resources resources = context.getResources();
int resId = resources.getIdentifier(resName, "dimen", packageName);
if (resId <= 0)
return -1;
return resources.getDimension(resId);
}
Aggregations