com.gianlu.commonutils.typography.FontsManager Java Examples

The following examples show how to use com.gianlu.commonutils.typography.FontsManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileTypeTextView.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
public FileTypeTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setWillNotDraw(false);

    textPaint = new TextPaint();
    FontsManager.set(context, textPaint, R.font.roboto_black);
    textPaint.setAntiAlias(true);

    mDefaultTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, context.getResources().getDisplayMetrics());

    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FileTypeTextView, defStyleAttr, 0);
    try {
        mMaxHeight = a.getDimensionPixelSize(R.styleable.FileTypeTextView_maxHeight, (int) mDefaultTextSize);
        textPaint.setColor(a.getColor(R.styleable.FileTypeTextView_textColor, Color.BLACK));
    } finally {
        a.recycle();
    }

    if (isInEditMode()) setExtension("XML");
}
 
Example #2
Source File: DonutProgress.java    From Aria2App with GNU General Public License v3.0 6 votes vote down vote up
public DonutProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setLayerType(LAYER_TYPE_SOFTWARE, null);

    arcPaint = new Paint();
    arcPaint.setColor(Color.WHITE);
    arcPaint.setAntiAlias(true);

    textPaint = new Paint();
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, getResources().getDisplayMetrics()));
    FontsManager.set(getContext(), textPaint, R.font.roboto_light);
    textPaint.setAntiAlias(true);

    transparentPaint = new Paint();
    transparentPaint.setColor(Color.TRANSPARENT);
    transparentPaint.setAlpha(0xFF);
    transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));

    padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());

    if (isInEditMode())
        setProgress(new Random().nextInt(100));
    else
        setProgress(0);
}
 
Example #3
Source File: DrawingHelper.java    From CommonUtils with Apache License 2.0 5 votes vote down vote up
public DrawingHelper(@NonNull Context context) {
    lettersPaintWithCircle = new Paint();
    lettersPaintWithCircle.setAntiAlias(true);
    FontsManager.set(context, lettersPaintWithCircle, R.font.roboto_light);
    lettersPaintWithCircle.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 20, context.getResources().getDisplayMetrics()));

    lettersPaintNoCircle = new Paint(lettersPaintWithCircle);
    lettersPaintNoCircle.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
    lettersPaintWithCircle.setColor(ContextCompat.getColor(context, R.color.white));

    shapePaint = new Paint();
    shapePaint.setAntiAlias(true);
    shapePaint.setColor(ContextCompat.getColor(context, R.color.colorPrimary));
    shapePaint.setShadowLayer(SHADOW_RADIUS, 0, 4, CommonUtils.manipulateAlpha(ContextCompat.getColor(context, R.color.colorPrimary), 0.8f));
}
 
Example #4
Source File: GameCardView.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 5 votes vote down vote up
private GameCardView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @Nullable BaseCard card, @Nullable Action primary, @Nullable Action secondary, @Nullable CardListener listener) {
    super(context, attrs, defStyleAttr);
    this.card = card;
    this.primary = primary;
    this.secondary = secondary;
    this.listener = listener;

    LayoutInflater.from(getContext()).inflate(R.layout.pyx_card, this, true);
    mWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, WIDTH_DIP, getResources().getDisplayMetrics());
    setCardElevation((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()));

    text = findViewById(R.id.pyxCard_text);
    FontsManager.set(R.font.roboto_medium, text);

    watermark = findViewById(R.id.pyxCard_watermark);
    numPick = findViewById(R.id.pyxCard_numPick);
    numDraw = findViewById(R.id.pyxCard_numDraw);
    primaryAction = findViewById(R.id.pyxCard_primaryAction);
    secondaryAction = findViewById(R.id.pyxCard_secondaryAction);

    notText = findViewById(R.id.pyxCard_notText);
    loading = notText.findViewById(R.id.pyxCard_loading);
    image = notText.findViewById(R.id.pyxCard_image);
    unknown = notText.findViewById(R.id.pyxCard_unknown);

    init();
}
 
Example #5
Source File: SuperTextView.java    From CommonUtils with Apache License 2.0 4 votes vote down vote up
public void setTypeface(@FontRes int res) {
    FontsManager.set(res, this);
}
 
Example #6
Source File: GameRoundSummary.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
public GameRoundSummary(@NonNull Context context, @NonNull GameRound round, boolean rotate) {
    this.round = round;
    this.rotate = rotate;

    blackPaint = new Paint();
    blackPaint.setColor(Color.BLACK);
    blackPaint.setAntiAlias(true);
    blackPaint.setShadowLayer(SHADOW_RADIUS, SHADOW_DX, SHADOW_DY, SHADOW_COLOR);

    blackTextPaint = new TextPaint();
    blackTextPaint.setAntiAlias(true);
    blackTextPaint.setColor(Color.BLACK);
    FontsManager.set(context, blackTextPaint, R.font.roboto_medium);

    whitePaint = new Paint();
    whitePaint.setColor(Color.WHITE);
    whitePaint.setAntiAlias(true);
    whitePaint.setShadowLayer(SHADOW_RADIUS, SHADOW_DX, SHADOW_DY, SHADOW_COLOR);

    whiteTextPaint = new TextPaint();
    whiteTextPaint.setColor(Color.WHITE);
    whiteTextPaint.setAntiAlias(true);
    FontsManager.set(context, whiteTextPaint, R.font.roboto_medium);

    winnerPaint = new Paint();
    winnerPaint.setColor(WINNER_COLOR);
    winnerPaint.setAntiAlias(true);
    winnerPaint.setShadowLayer(SHADOW_RADIUS, SHADOW_DX, SHADOW_DY, SHADOW_COLOR);

    grayTextPaint = new TextPaint();
    grayTextPaint.setColor(Color.DKGRAY);
    grayTextPaint.setAntiAlias(true);
    FontsManager.set(context, grayTextPaint, R.font.roboto_medium);

    backgroundPaint = new Paint();
    backgroundPaint.setColor(BACKGROUND_COLOR);

    boxPaint = new Paint();
    boxPaint.setColor(Color.GRAY);

    bitmap = Bitmap.createBitmap(measureWidth(), measureHeight(), Bitmap.Config.ARGB_8888);
    canvas = new Canvas(bitmap);
    draw();

    ThisApplication.sendAnalytics(Utils.ACTION_SHOW_ROUND);
}