Search in sources :

Example 11 with CheckResult

use of android.support.annotation.CheckResult in project iosched by google.

the class UIUtils method tintBitmap.

/**
 * Tints a bitmap using a color and {@link PorterDuff.Mode#MULTIPLY} mode.
 */
@CheckResult
static Bitmap tintBitmap(@NonNull Bitmap iconBitmap, @ColorInt int color) {
    Paint paint = new Paint();
    paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
    Bitmap newIcon = Bitmap.createBitmap(iconBitmap.getWidth(), iconBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(newIcon);
    canvas.drawBitmap(iconBitmap, 0, 0, paint);
    return newIcon;
}
Also used : Bitmap(android.graphics.Bitmap) Canvas(android.graphics.Canvas) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Paint(android.graphics.Paint) CheckResult(android.support.annotation.CheckResult)

Example 12 with CheckResult

use of android.support.annotation.CheckResult in project edx-app-android by edx.

the class Iconify method findIconForKey.

/**
 * Retrieve an icon from a key,
 * @return The icon, or null if no icon matches the key.
 */
@CheckResult
@Nullable
static Icon findIconForKey(@NonNull String iconKey) {
    for (int i = 0, iconFontDescriptorsSize = iconFontDescriptors.size(); i < iconFontDescriptorsSize; i++) {
        IconFontDescriptorWrapper iconFontDescriptor = iconFontDescriptors.get(i);
        Icon icon = iconFontDescriptor.getIcon(iconKey);
        if (icon != null)
            return icon;
    }
    return null;
}
Also used : IconFontDescriptorWrapper(com.joanzapata.iconify.internal.IconFontDescriptorWrapper) CheckResult(android.support.annotation.CheckResult) Nullable(android.support.annotation.Nullable)

Example 13 with CheckResult

use of android.support.annotation.CheckResult in project edx-app-android by edx.

the class CustomTypefaceSpan method needMirroring.

// Since the 'mirrorable' flag is only set to true if the SDK
// version supports it, we don't need an explicit check for that
// before calling getLayoutDirection().
@TargetApi(JELLY_BEAN_MR1)
@CheckResult
private boolean needMirroring() {
    if (!mirrorable)
        return false;
    // Passwords fields should be LTR
    if (view.getTransformationMethod() instanceof PasswordTransformationMethod) {
        return false;
    }
    // Always need to resolve layout direction first
    final boolean defaultIsRtl = view.getLayoutDirection() == LAYOUT_DIRECTION_RTL;
    if (SDK_INT < JELLY_BEAN_MR2) {
        return defaultIsRtl;
    }
    // Select the text direction heuristic according to the
    // package-private getTextDirectionHeuristic() method in TextView
    TextDirectionHeuristic textDirectionHeuristic;
    switch(view.getTextDirection()) {
        default:
        case TEXT_DIRECTION_FIRST_STRONG:
            textDirectionHeuristic = defaultIsRtl ? TextDirectionHeuristics.FIRSTSTRONG_RTL : TextDirectionHeuristics.FIRSTSTRONG_LTR;
            break;
        case TEXT_DIRECTION_ANY_RTL:
            textDirectionHeuristic = TextDirectionHeuristics.ANYRTL_LTR;
            break;
        case TEXT_DIRECTION_LTR:
            textDirectionHeuristic = TextDirectionHeuristics.LTR;
            break;
        case TEXT_DIRECTION_RTL:
            textDirectionHeuristic = TextDirectionHeuristics.RTL;
            break;
        case TEXT_DIRECTION_LOCALE:
            textDirectionHeuristic = TextDirectionHeuristics.LOCALE;
            break;
        case TEXT_DIRECTION_FIRST_STRONG_LTR:
            textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_LTR;
            break;
        case TEXT_DIRECTION_FIRST_STRONG_RTL:
            textDirectionHeuristic = TextDirectionHeuristics.FIRSTSTRONG_RTL;
            break;
    }
    CharSequence text = view.getText();
    return textDirectionHeuristic.isRtl(text, 0, text.length());
}
Also used : PasswordTransformationMethod(android.text.method.PasswordTransformationMethod) TextDirectionHeuristic(android.text.TextDirectionHeuristic) CheckResult(android.support.annotation.CheckResult) TargetApi(android.annotation.TargetApi)

Example 14 with CheckResult

use of android.support.annotation.CheckResult in project edx-app-android by edx.

the class ParsingUtil method parse.

@CheckResult
@NonNull
public static CharSequence parse(@NonNull TextView targetView, @NonNull @Size(min = 1) List<IconFontDescriptorWrapper> iconFontDescriptors, @NonNull CharSequence text) {
    final SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(text);
    recursivePrepareSpannableIndexes(targetView, text.toString(), spannableBuilder, iconFontDescriptors, 0);
    return spannableBuilder;
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) CheckResult(android.support.annotation.CheckResult) NonNull(android.support.annotation.NonNull)

Example 15 with CheckResult

use of android.support.annotation.CheckResult in project seven_develop by seven123456.

the class ToastUtils method custom.

@CheckResult
public static Toast custom(@NonNull Context context, @NonNull String message, Drawable icon, @ColorInt int textColor, @ColorInt int tintColor, int duration, boolean withIcon, boolean shouldTint) {
    if (currentToast == null) {
        currentToast = new Toast(context);
    }
    final View toastLayout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.toast_layout, null);
    final ImageView toastIcon = (ImageView) toastLayout.findViewById(R.id.toast_icon);
    final TextView toastTextView = (TextView) toastLayout.findViewById(R.id.toast_text);
    Drawable drawableFrame;
    if (shouldTint) {
        drawableFrame = tint9PatchDrawableFrame(context, tintColor);
    } else {
        drawableFrame = getDrawable(context, R.drawable.toast_frame);
    }
    setBackground(toastLayout, drawableFrame);
    if (withIcon) {
        if (icon == null)
            throw new IllegalArgumentException("Avoid passing 'icon' as null if 'withIcon' is set to true");
        setBackground(toastIcon, icon);
    } else
        toastIcon.setVisibility(View.GONE);
    toastTextView.setTextColor(textColor);
    toastTextView.setText(message);
    toastTextView.setTypeface(Typeface.create(TOAST_TYPEFACE, Typeface.NORMAL));
    currentToast.setView(toastLayout);
    currentToast.setDuration(duration);
    return currentToast;
}
Also used : Toast(android.widget.Toast) LayoutInflater(android.view.LayoutInflater) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) 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) 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