Skip to content

Commit

Permalink
TextParams 增加CharSequence
Browse files Browse the repository at this point in the history
  • Loading branch information
hupei committed Mar 30, 2020
1 parent 97adfa8 commit 331139c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 引入

```xml
compile 'com.mylhyl:circleDialog:2.6.16'
compile 'com.mylhyl:circleDialog:2.6.17'
```

[下载APK体验](https://fir.im/sbvq)或手机扫描下面二维码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
Expand All @@ -20,7 +24,9 @@
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mylhyl.circledialog.CircleDialog;
import com.mylhyl.circledialog.callback.ConfigText;
import com.mylhyl.circledialog.params.ProgressParams;
import com.mylhyl.circledialog.params.TextParams;
import com.mylhyl.circledialog.res.drawable.CircleDrawable;
import com.mylhyl.circledialog.res.values.CircleColor;
import com.mylhyl.circledialog.res.values.CircleDimen;
Expand Down Expand Up @@ -79,7 +85,18 @@ public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
case 0:
new CircleDialog.Builder()
.setTitle("标题")
.setText("提示框")
.configText(new ConfigText() {
@Override
public void onConfig(TextParams params) {
SpannableString spannableString = new SpannableString("我是红色");
spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#FF0000")), 2,
spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
params.textCharSequence = spannableString;
// String text = "我是<font color='#FF0000'>红色</font>";
// params.textCharSequence = Html.fromHtml(text);

}
})
.setPositive("确定", null)
.setOnShowListener(dialog ->
Toast.makeText(MainActivity.this, "显示了!", Toast.LENGTH_SHORT).show())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public TextParams[] newArray(int size) {
*/
public int styleText = Typeface.NORMAL;

public CharSequence textCharSequence;

public TextParams() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ else if (titleParams == null && negativeParams == null && positiveParams == null
setMinHeight(textParams.height);
setTextColor(textParams.textColor);
setTextSize(textParams.textSize);
setText(textParams.text);
if (textParams.textCharSequence != null) {
setText(textParams.textCharSequence);
} else {
setText(textParams.text);
}
setTypeface(getTypeface(), textParams.styleText);

int[] padding = textParams.padding;
Expand Down
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ ext {
]

publish = [
version: "2.6.16"
version: "2.6.17"
]
}

0 comments on commit 331139c

Please sign in to comment.