Search in sources :

Example 6 with CheckResult

use of android.support.annotation.CheckResult in project AndroidUtilLib by SiberiaDante.

the class SDToastUtil method showTranslucentText.

/**
 * Toast 无背景透明的文本
 *
 * @param content  内容
 * @param duration 显示时长 {@code Toast.LENGTH_LONG} {@code Toast.LENGTH_SHORT}
 */
@CheckResult
private static Toast showTranslucentText(String content, int duration, float textSize, int textColor) {
    if (toast == null) {
        toast = Toast.makeText(SDAndroidLib.getContext(), "", Toast.LENGTH_LONG);
    }
    toastList.add(toast);
    // 创建线性布局
    LinearLayout linearLayout = new LinearLayout(SDAndroidLib.getContext());
    // 设置布局垂直
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    TextView textView = new TextView(SDAndroidLib.getContext());
    if (textSize == TEXT_SIZE_NULL) {
        textView.setTextSize(DEFAULT_TEXT_SIZE);
    } else {
        textView.setTextSize(textSize);
    }
    if (textColor == TEXT_COLOR_NULL) {
        textView.setTextColor(DEFAULT_TEXT_COLOR_BLACK);
    } else {
        textView.setTextColor(textColor);
    }
    textView.setText(content);
    linearLayout.addView(textView);
    toast.setView(linearLayout);
    if (DURATION_NULL == duration) {
        toast.setDuration(Toast.LENGTH_LONG);
    } else {
        toast.setDuration(duration);
    }
    toast.show();
    return toast;
}
Also used : TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) CheckResult(android.support.annotation.CheckResult)

Example 7 with CheckResult

use of android.support.annotation.CheckResult in project Shuttle by timusus.

the class Aesthetic method colorNavigationBarAuto.

@CheckResult
public Aesthetic colorNavigationBarAuto(boolean auto) {
    String navBarKey = String.format(KEY_NAV_BAR_COLOR, key(context));
    String primaryColorKey = String.format(KEY_PRIMARY_COLOR, key(context));
    if (auto) {
        int color = prefs.getInt(primaryColorKey, resolveColor(context, R.attr.colorPrimary));
        editor.putInt(navBarKey, isColorLight(color) ? Color.BLACK : color);
    } else {
        editor.remove(navBarKey);
    }
    return this;
}
Also used : SuppressLint(android.annotation.SuppressLint) CheckResult(android.support.annotation.CheckResult)

Example 8 with CheckResult

use of android.support.annotation.CheckResult in project weiui by kuaifan.

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 HashMap<>();
        result.transformations.putAll(transformations);
        result.isLocked = false;
        result.isAutoCloneEnabled = false;
        return result;
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
}
Also used : GifOptions(vip.kuaifan.weiui.extend.integration.glide.load.resource.gif.GifOptions) Options(vip.kuaifan.weiui.extend.integration.glide.load.Options) CheckResult(android.support.annotation.CheckResult)

Example 9 with CheckResult

use of android.support.annotation.CheckResult in project Rocket by mozilla-tw.

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")
@CheckResult
@Override
public RequestOptions clone() {
    try {
        RequestOptions result = (RequestOptions) super.clone();
        result.options = new Options();
        result.options.putAll(options);
        result.transformations = new HashMap<>();
        result.transformations.putAll(transformations);
        result.isLocked = false;
        result.isAutoCloneEnabled = false;
        return result;
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
}
Also used : Options(com.bumptech.glide.load.Options) CheckResult(android.support.annotation.CheckResult)

Example 10 with CheckResult

use of android.support.annotation.CheckResult in project Rocket by mozilla-tw.

the class MainActivity method runPromotionFromIntent.

// return true if promotion is already handled
@CheckResult
private boolean runPromotionFromIntent(final SafeIntent intent) {
    if (intent == null) {
        return false;
    }
    final Bundle bundle = intent.getExtras();
    if (bundle == null) {
        return false;
    }
    // When we receive this action, it means we need to show "Love Rocket" dialog
    final boolean loveRocket = bundle.getBoolean(IntentUtils.EXTRA_SHOW_RATE_DIALOG, false);
    if (loveRocket) {
        DialogUtils.showRateAppDialog(this);
        NotificationManagerCompat.from(this).cancel(NotificationId.LOVE_FIREFOX);
        // Reset extra after dialog displayed.
        bundle.putBoolean(IntentUtils.EXTRA_SHOW_RATE_DIALOG, false);
        return true;
    }
    return false;
}
Also used : Bundle(android.os.Bundle) 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