Skip to content

Commit

Permalink
Replace to CharSequence
Browse files Browse the repository at this point in the history
  • Loading branch information
k2wanko committed Feb 2, 2016
1 parent bd21a82 commit 978d0f6
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.MovementMethod;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import java.util.ArrayList;
Expand Down Expand Up @@ -53,7 +52,7 @@ public static LinkBuilder on(TextView tv) {
private Context context;

private TextView textView;
private String text;
private CharSequence text;

private List<Link> links = new ArrayList<>();

Expand All @@ -80,10 +79,10 @@ public LinkBuilder(TextView textView) {

public LinkBuilder setTextView(TextView textView) {
this.textView = textView;
return setText(textView.getText().toString());
return setText(textView.getText());
}

public LinkBuilder setText(String text) {
public LinkBuilder setText(CharSequence text) {
this.text = text;
return this;
}
Expand Down Expand Up @@ -255,14 +254,14 @@ private void applyAppendedAndPrependedText() {
if (link.getPrependedText() != null) {
String totalText = link.getPrependedText() + " " + link.getText();

text = text.replace(link.getText(), totalText);
text = TextUtils.replace(text, new String[]{link.getText()}, new CharSequence[]{totalText});
links.get(i).setText(totalText);
}

if (link.getAppendedText() != null) {
String totalText = link.getText() + " " + link.getAppendedText();

text = text.replace(link.getText(), totalText);
text = TextUtils.replace(text, new String[]{link.getText()}, new CharSequence[]{totalText});
links.get(i).setText(totalText);
}
}
Expand Down

0 comments on commit 978d0f6

Please sign in to comment.