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;
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations