Java Code Examples for com.amulyakhare.textdrawable.TextDrawable#IBuilder

The following examples show how to use com.amulyakhare.textdrawable.TextDrawable#IBuilder . 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: WeekdaysDrawableProvider.java    From weekdays-buttons-bar with MIT License 6 votes vote down vote up
public Drawable getRectWithCustomSize(Context context, String leftText, String rightText, boolean selected) {

        TextDrawable.IBuilder builder = TextDrawable.builder()
                .beginConfig()
                .width(toPx(context, 29))
                .withBorder(toPx(context, 2))
                .textColor(selected ? getTextColorSelected() : getTextColorUnselected())
                .endConfig()
                .rect();


        TextDrawable left = builder
                .build(leftText, mGenerator.getColor(leftText));


        TextDrawable right = builder
                .build(rightText, mGenerator.getColor(rightText));


        Drawable[] layerList = {
                new InsetDrawable(left, 0, 0, toPx(context, 31), 0),
                new InsetDrawable(right, toPx(context, 31), 0, 0, 0)
        };
        return new LayerDrawable(layerList);
    }
 
Example 2
Source File: WeekdaysDrawableProvider.java    From weekdays-buttons-bar with MIT License 6 votes vote down vote up
public static Drawable getRectWithAnimation(int count, String label, int delay) {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .rect();


    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int i = count; i > 0; i--) {
        TextDrawable frame = builder.build(label, ColorGenerator.MATERIAL.getRandomColor());
        animationDrawable.addFrame(frame, delay);
    }
    animationDrawable.setOneShot(false);
    animationDrawable.start();


    return animationDrawable;
}
 
Example 3
Source File: DrawableProvider.java    From TextDrawable with MIT License 6 votes vote down vote up
public Drawable getRectWithCustomSize() {
    String leftText = "I";
    String rightText = "J";

    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
                .width(toPx(29))
                .withBorder(toPx(2))
            .endConfig()
            .rect();

    TextDrawable left = builder
            .build(leftText, mGenerator.getColor(leftText));

    TextDrawable right = builder
            .build(rightText, mGenerator.getColor(rightText));

    Drawable[] layerList = {
            new InsetDrawable(left, 0, 0, toPx(31), 0),
            new InsetDrawable(right, toPx(31), 0, 0, 0)
    };
    return new LayerDrawable(layerList);
}
 
Example 4
Source File: CreateFolderView.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
private void setupDrawable(@NonNull String upDrawable) {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
            .endConfig()
            .round();
    String letter = InputHelper.isEmpty(upDrawable) ? "N/A" : InputHelper.getTwoLetters(upDrawable);
    folderImage.setImageDrawable(builder.build(letter.toUpperCase(), selectedColor));
}
 
Example 5
Source File: FloatingFoldersViewHolder.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override public void bind(@NonNull FolderModel folderModel) {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
            .endConfig()
            .round();
    String letter = InputHelper.getTwoLetters(folderModel.getFolderName());
    int color = folderModel.getColor() == 0 ? ColorGenerator.MATERIAL.getRandomColor() : folderModel.getColor();
    imageIcon.setImageDrawable(builder.build(letter.toUpperCase(), color));
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageIcon.getLayoutParams();
    int gap = PrefConstant.getGapSize(imageIcon.getResources());
    if (!isHorizontal) params.setMargins(0, 0, 0, gap);
    else params.setMargins(0, 0, gap, 0);
}
 
Example 6
Source File: FoldersViewHolder.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override public void bind(@NonNull FolderModel folderModel) {
    folderName.setText(folderModel.getFolderName());
    appsCount.setText(String.valueOf(folderModel.getAppsCount()));
    folderImage.setContentDescription(folderModel.getFolderName());
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
            .endConfig()
            .round();
    String letter = InputHelper.getTwoLetters(folderModel.getFolderName());
    int color = folderModel.getColor() == 0 ? ColorGenerator.MATERIAL.getRandomColor() : folderModel.getColor();
    folderImage.setImageDrawable(builder.build(letter.toUpperCase(), color));
    if (getAdapterPosition() == 0) {
        ViewHelper.showTooltip(delete, R.string.delete_folder_hint, this);
    }
}
 
Example 7
Source File: DrawableProvider.java    From TextDrawable with MIT License 5 votes vote down vote up
public Drawable getRectWithAnimation() {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .rect();

    AnimationDrawable animationDrawable = new AnimationDrawable();
    for (int i = 10; i > 0; i--) {
        TextDrawable frame = builder.build(String.valueOf(i), mGenerator.getRandomColor());
        animationDrawable.addFrame(frame, 1200);
    }
    animationDrawable.setOneShot(false);
    animationDrawable.start();

    return animationDrawable;
}