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