Search in sources :

Example 21 with CheckResult

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();
}
Also used : BitmapDrawableTransformation(com.bumptech.glide.load.resource.bitmap.BitmapDrawableTransformation) CheckResult(android.support.annotation.CheckResult)

Example 22 with CheckResult

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);
    }
}
Also used : GifOptions(com.bumptech.glide.load.resource.gif.GifOptions) Options(com.bumptech.glide.load.Options) CheckResult(android.support.annotation.CheckResult)

Example 23 with CheckResult

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;
}
Also used : Toast(android.widget.Toast) LayoutInflater(android.view.LayoutInflater) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) View(android.view.View) AppCompatTextView(android.support.v7.widget.AppCompatTextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) CheckResult(android.support.annotation.CheckResult)

Example 24 with CheckResult

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);
}
Also used : Resources(android.content.res.Resources) CheckResult(android.support.annotation.CheckResult)

Example 25 with CheckResult

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);
}
Also used : Resources(android.content.res.Resources) CheckResult(android.support.annotation.CheckResult)

Aggregations

CheckResult (android.support.annotation.CheckResult)27 NonNull (android.support.annotation.NonNull)9 TextView (android.widget.TextView)5 Cursor (android.database.Cursor)4 LayoutInflater (android.view.LayoutInflater)4 View (android.view.View)4 Toast (android.widget.Toast)4 Drawable (android.graphics.drawable.Drawable)3 NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)3 ImageView (android.widget.ImageView)3 Resources (android.content.res.Resources)2 ContentObserver (android.database.ContentObserver)2 LinearLayout (android.widget.LinearLayout)2 Options (com.bumptech.glide.load.Options)2 StorIOException (com.pushtorefresh.storio.StorIOException)2 OnSubscribeExecuteAsBlockingCompletable (com.pushtorefresh.storio.operations.internal.OnSubscribeExecuteAsBlockingCompletable)2 CompletableOnSubscribeExecuteAsBlocking (com.pushtorefresh.storio3.operations.internal.CompletableOnSubscribeExecuteAsBlocking)2 Completable (io.reactivex.Completable)2 Completable (rx.Completable)2 SuppressLint (android.annotation.SuppressLint)1