use of androidx.annotation.CheckResult in project Rocket by mozilla-tw.
the class IntentUtils method openDefaultAppsSettings.
@CheckResult
public static boolean openDefaultAppsSettings(Context context) {
try {
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
// In some cases, a matching Activity may not exist (according to the Android docs).
return false;
}
}
use of androidx.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 androidx.annotation.CheckResult in project prebid-mobile-android by prebid.
the class Util method removeEntryWithoutValue.
@CheckResult
private static JSONArray removeEntryWithoutValue(@NonNull JSONArray array) throws JSONException {
for (int i = 0; i < array.length(); i++) {
Object value = array.opt(i);
if (value != null) {
if (value instanceof JSONObject) {
JSONObject mapValue = (JSONObject) value;
removeEntryWithoutValue(mapValue);
if (mapValue.length() == 0) {
array = getJsonArrayWithoutEntryByIndex(array, i);
}
} else if (value instanceof JSONArray) {
JSONArray arrayValue = (JSONArray) value;
arrayValue = removeEntryWithoutValue(arrayValue);
array.put(i, arrayValue);
if (arrayValue.length() == 0) {
array = getJsonArrayWithoutEntryByIndex(array, i);
}
} else if (value instanceof String) {
String stringValue = (String) value;
if (stringValue.length() == 0) {
array = getJsonArrayWithoutEntryByIndex(array, i);
}
}
}
}
return array;
}
use of androidx.annotation.CheckResult in project Toasty by GrenderG.
the class Toasty method custom.
@SuppressLint("ShowToast")
@CheckResult
public static Toast custom(@NonNull Context context, @NonNull CharSequence message, Drawable icon, @ColorInt int tintColor, @ColorInt int textColor, int duration, boolean withIcon, boolean shouldTint) {
final Toast currentToast = Toast.makeText(context, "", duration);
final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null);
final LinearLayout toastRoot = toastLayout.findViewById(R.id.toast_root);
final ImageView toastIcon = toastLayout.findViewById(R.id.toast_icon);
final TextView toastTextView = toastLayout.findViewById(R.id.toast_text);
Drawable drawableFrame;
if (shouldTint)
drawableFrame = ToastyUtils.tint9PatchDrawableFrame(context, tintColor);
else
drawableFrame = ToastyUtils.getDrawable(context, R.drawable.toast_frame);
ToastyUtils.setBackground(toastLayout, drawableFrame);
if (withIcon) {
if (icon == null)
throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
if (isRTL && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
toastRoot.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
ToastyUtils.setBackground(toastIcon, tintIcon ? ToastyUtils.tintIcon(icon, textColor) : icon);
} else {
toastIcon.setVisibility(View.GONE);
}
toastTextView.setText(message);
toastTextView.setTextColor(textColor);
toastTextView.setTypeface(currentTypeface);
toastTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
currentToast.setView(toastLayout);
if (!allowQueue) {
if (lastToast != null)
lastToast.cancel();
lastToast = currentToast;
}
// Make sure to use default values for non-specified ones.
currentToast.setGravity(toastGravity == -1 ? currentToast.getGravity() : toastGravity, xOffset == -1 ? currentToast.getXOffset() : xOffset, yOffset == -1 ? currentToast.getYOffset() : yOffset);
return currentToast;
}
use of androidx.annotation.CheckResult in project react-native-navigation by wix.
the class Options method copy.
@CheckResult
public Options copy() {
Options result = new Options();
result.topBar.mergeWith(topBar);
result.topTabs.mergeWith(topTabs);
result.topTabOptions.mergeWith(topTabOptions);
result.bottomTabOptions.mergeWith(bottomTabOptions);
result.bottomTabsOptions.mergeWith(bottomTabsOptions);
result.overlayOptions = overlayOptions;
result.fabOptions.mergeWith(fabOptions);
result.sideMenuRootOptions.mergeWith(sideMenuRootOptions);
result.animations.mergeWith(animations);
result.modal.mergeWith(modal);
result.navigationBar.mergeWith(navigationBar);
result.statusBar.mergeWith(statusBar);
result.layout.mergeWith(layout);
result.hardwareBack.mergeWith(hardwareBack);
return result;
}
Aggregations