Search in sources :

Example 1 with CheckResult

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;
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) CheckResult(androidx.annotation.CheckResult)

Example 2 with CheckResult

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);
    }
}
Also used : Options(com.bumptech.glide.load.Options) CheckResult(androidx.annotation.CheckResult)

Example 3 with CheckResult

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;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject) CheckResult(androidx.annotation.CheckResult)

Example 4 with CheckResult

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;
}
Also used : Toast(android.widget.Toast) LayoutInflater(android.view.LayoutInflater) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) LinearLayout(android.widget.LinearLayout) CheckResult(androidx.annotation.CheckResult) SuppressLint(android.annotation.SuppressLint)

Example 5 with CheckResult

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;
}
Also used : LayoutOptions(com.reactnativenavigation.options.layout.LayoutOptions) CheckResult(androidx.annotation.CheckResult)

Aggregations

CheckResult (androidx.annotation.CheckResult)8 LayoutOptions (com.reactnativenavigation.options.layout.LayoutOptions)2 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Intent (android.content.Intent)1 Drawable (android.graphics.drawable.Drawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 Nullable (androidx.annotation.Nullable)1 Options (com.bumptech.glide.load.Options)1 BitmapDrawableTransformation (com.bumptech.glide.load.resource.bitmap.BitmapDrawableTransformation)1 Metadata (com.google.android.exoplayer2.metadata.Metadata)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1 TrackSelectorResult (com.google.android.exoplayer2.trackselection.TrackSelectorResult)1 JSONArray (org.json.JSONArray)1