forked from nickbutcher/plaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some tweaks to CollapsingTitleLayout.
Fixes nickbutcher#105.
- Loading branch information
1 parent
f594315
commit cc32764
Showing
2 changed files
with
55 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.plaidapp.ui.span; | ||
|
||
import android.support.annotation.ColorInt; | ||
import android.support.annotation.FloatRange; | ||
import android.text.TextPaint; | ||
import android.text.style.ForegroundColorSpan; | ||
|
||
import io.plaidapp.util.ColorUtils; | ||
|
||
/** | ||
* An extension to {@link ForegroundColorSpan} which allows updating the color or alpha component. | ||
* Note that Spans cannot invalidate themselves so consumers must ensure that the Spannable is | ||
* refreshed themselves. | ||
*/ | ||
public class TextColorSpan extends ForegroundColorSpan { | ||
|
||
private @ColorInt int color; | ||
|
||
public TextColorSpan(int color) { | ||
super(color); | ||
this.color = color; | ||
} | ||
|
||
public @ColorInt int getColor() { | ||
return color; | ||
} | ||
|
||
public void setColor(@ColorInt int color) { | ||
this.color = color; | ||
} | ||
|
||
public void setAlpha(@FloatRange(from = 0f, to = 1f) float alpha) { | ||
color = ColorUtils.modifyAlpha(color, alpha); | ||
} | ||
|
||
@Override | ||
public void updateDrawState(TextPaint ds) { | ||
ds.setColor(color); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters