mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
added rounded span background for labels, fixed repo readme where mistakenly set to wrap.
This commit is contained in:
parent
108b6ac927
commit
d58b3bf08c
@ -13,10 +13,10 @@ import com.fastaccess.data.dao.LabelModel;
|
||||
import com.fastaccess.data.dao.types.IssueEventType;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.ParseDateFormat;
|
||||
import com.fastaccess.helper.ViewHelper;
|
||||
import com.fastaccess.ui.widgets.AvatarLayout;
|
||||
import com.fastaccess.ui.widgets.FontTextView;
|
||||
import com.fastaccess.ui.widgets.ForegroundImageView;
|
||||
import com.fastaccess.ui.widgets.RoundBackgroundSpan;
|
||||
import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
|
||||
@ -59,8 +59,9 @@ public class IssueTimelineViewHolder extends BaseViewHolder<IssueEventAdapterMod
|
||||
int color = Color.parseColor("#" + labelModel.getColor());
|
||||
spannableBuilder
|
||||
.append(" ")
|
||||
.background(SpannableBuilder.builder().foreground(" " + labelModel.getName() + " "
|
||||
, ViewHelper.generateTextColor(color)), color);
|
||||
.background(SpannableBuilder.builder()
|
||||
.append(" " + labelModel.getName() + " ",
|
||||
new RoundBackgroundSpan(color, 4)), color);
|
||||
} else if (event == IssueEventType.assigned || event == IssueEventType.unassigned) {
|
||||
spannableBuilder
|
||||
.append(" ")
|
||||
|
||||
@ -13,10 +13,10 @@ import com.fastaccess.data.dao.PullRequestAdapterModel;
|
||||
import com.fastaccess.data.dao.types.IssueEventType;
|
||||
import com.fastaccess.helper.InputHelper;
|
||||
import com.fastaccess.helper.ParseDateFormat;
|
||||
import com.fastaccess.helper.ViewHelper;
|
||||
import com.fastaccess.ui.widgets.AvatarLayout;
|
||||
import com.fastaccess.ui.widgets.FontTextView;
|
||||
import com.fastaccess.ui.widgets.ForegroundImageView;
|
||||
import com.fastaccess.ui.widgets.RoundBackgroundSpan;
|
||||
import com.fastaccess.ui.widgets.SpannableBuilder;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseRecyclerAdapter;
|
||||
import com.fastaccess.ui.widgets.recyclerview.BaseViewHolder;
|
||||
@ -59,8 +59,9 @@ public class PullRequestTimelineViewHolder extends BaseViewHolder<PullRequestAda
|
||||
int color = Color.parseColor("#" + labelModel.getColor());
|
||||
spannableBuilder
|
||||
.append(" ")
|
||||
.background(SpannableBuilder.builder().foreground(" " + labelModel.getName() + " "
|
||||
, ViewHelper.generateTextColor(color)), color);
|
||||
.background(SpannableBuilder.builder()
|
||||
.append(" " + labelModel.getName() + " ",
|
||||
new RoundBackgroundSpan(color, 4)), color);
|
||||
} else if (event == IssueEventType.assigned || event == IssueEventType.unassigned) {
|
||||
spannableBuilder
|
||||
.append(" ")
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package com.fastaccess.ui.widgets;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.FontMetricsInt;
|
||||
import android.graphics.RectF;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.style.ReplacementSpan;
|
||||
|
||||
public class RoundBackgroundSpan extends ReplacementSpan {
|
||||
private Paint mPaint = new Paint();
|
||||
private float mRadius;
|
||||
private RectF mRectF = new RectF();
|
||||
private int mWidth = -1;
|
||||
|
||||
public RoundBackgroundSpan(int i, float f) {
|
||||
this.mPaint.setColor(i);
|
||||
this.mPaint.setAntiAlias(true);
|
||||
this.mRadius = f;
|
||||
}
|
||||
|
||||
public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i2, FontMetricsInt fontMetricsInt) {
|
||||
this.mWidth = Math.round((float) ((int) paint.measureText(charSequence, i, i2)));
|
||||
this.mWidth = (int) (((float) this.mWidth) + (this.mRadius * 4.0f));
|
||||
return this.mWidth;
|
||||
}
|
||||
|
||||
public void draw(@NonNull Canvas canvas, CharSequence charSequence, int i, int i2, float f, int i3, int i4, int i5, @NonNull Paint paint) {
|
||||
canvas.drawRoundRect(new RectF(f, (float) i3, ((float) this.mWidth) + f, (float) i5), this.mRadius, this.mRadius, this.mPaint);
|
||||
canvas.drawText(charSequence, i, i2, f + (this.mRadius * 2.0f), (float) i4, paint);
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class PrettifyWebView extends NestedWebView {
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl) {
|
||||
setGithubContent(source, baseUrl, true);
|
||||
setGithubContent(source, baseUrl, false);
|
||||
}
|
||||
|
||||
public void setGithubContent(@NonNull String source, @Nullable String baseUrl, boolean wrap) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user