Skip to content

Commit

Permalink
Merge branch 'master' of github.com:shts/TriangleLabelView
Browse files Browse the repository at this point in the history
  • Loading branch information
shts committed Apr 2, 2016
2 parents cc6fea4 + 0400bf3 commit 2f590ea
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public float getLabelTopPadding() {

public void setLabelCenterPadding(float dp) {
centerPadding = dp2px(dp);
relayout();
}

public float getLabelCenterPadding() {
Expand All @@ -173,6 +174,7 @@ public float getLabelCenterPadding() {

public void setLabelBottomPadding(float dp) {
bottomPadding = dp2px(dp);
relayout();
}

public float getLabelBottomPadding() {
Expand All @@ -182,11 +184,13 @@ public float getLabelBottomPadding() {
public void setPrimaryText(String text) {
primary.text = text;
primary.resetStatus();
relayout();
}

public void setPrimaryText(@StringRes int textRes) {
primary.text = getContext().getString(textRes);
primary.resetStatus();
relayout();
}

public String getPrimaryText() {
Expand All @@ -196,11 +200,13 @@ public String getPrimaryText() {
public void setSecondaryText(String smallText) {
secondary.text = smallText;
secondary.resetStatus();
relayout();
}

public void setSecondaryText(@StringRes int textRes) {
secondary.text = getContext().getString(textRes);
secondary.resetStatus();
relayout();
}

public String getSecondaryText() {
Expand All @@ -211,32 +217,38 @@ public void setPrimaryTextColor(@ColorInt int color) {
primary.color = color;
primary.initPaint();
primary.resetStatus();
relayout();
}

public void setPrimaryTextColorResource(@ColorRes int colorResource) {
primary.color = ContextCompat.getColor(getContext(), colorResource);
primary.initPaint();
primary.resetStatus();
relayout();
}

public void setSecondaryTextColor(@ColorInt int color) {
secondary.color = color;
secondary.initPaint();
secondary.resetStatus();
relayout();
}

public void setSecondaryTextColorResource(@ColorRes int colorResource) {
secondary.color = ContextCompat.getColor(getContext(), colorResource);
secondary.initPaint();
secondary.resetStatus();
relayout();
}

public void setPrimaryTextSize(float sp) {
primary.size = sp2px(sp);
relayout();
}

public void setSecondaryTextSize(float sp) {
secondary.size = sp2px(sp);
relayout();
}

public float getPrimaryTextSize() {
Expand All @@ -250,11 +262,13 @@ public float getSecondaryTextSize() {
public void setTriangleBackgroundColor(@ColorInt int color) {
backGroundColor = color;
trianglePaint.setColor(backGroundColor);
relayout();
}

public void setTriangleBackgroundColorResource(@ColorRes int colorResource) {
backGroundColor = ContextCompat.getColor(getContext(), colorResource);
trianglePaint.setColor(backGroundColor);
relayout();
}

public int getTriangleBackGroundColor() {
Expand All @@ -263,6 +277,7 @@ public int getTriangleBackGroundColor() {

public void setCorner(Corner corner) {
this.corner = corner;
relayout();
}

public Corner getCorner() {
Expand Down Expand Up @@ -339,4 +354,11 @@ public float sp2px(float spValue) {
return spValue * scale;
}

/**
* Should be called whenever what we're displaying could have changed.
*/
private void relayout() {
invalidate();
requestLayout();
}
}

0 comments on commit 2f590ea

Please sign in to comment.