Combine some spannable concat calls

Delete email
captchafix
Florens Douwes 11 years ago
parent 87d3006908
commit 7c25618534
  1. 34
      Clover/app/src/main/java/org/floens/chan/core/loader/ChanParser.java
  2. 4
      Clover/app/src/main/java/org/floens/chan/core/manager/ThreadManager.java
  3. 2
      Clover/app/src/main/java/org/floens/chan/core/model/Post.java
  4. 19
      Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java
  5. 27
      Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java

@ -28,10 +28,10 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
import org.floens.chan.ChanApplication;
import org.floens.chan.R;
import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.PostLinkable;
import org.floens.chan.utils.ThemeHelper;
@ -92,6 +92,18 @@ public class ChanParser {
}
private void parseSpans(Post post, TypedArray ta) {
boolean anonymize = ChanPreferences.getAnonymize();
boolean anonymizeIds = ChanPreferences.getAnonymizeIds();
if (anonymize) {
post.name = ChanApplication.getInstance().getString(R.string.default_name);
post.tripcode = "";
}
if (anonymizeIds) {
post.id = "";
}
int detailSize = ta.getDimensionPixelSize(R.styleable.PostView_detail_size, 0);
if (!TextUtils.isEmpty(post.subject)) {
@ -102,9 +114,6 @@ public class ChanParser {
if (!TextUtils.isEmpty(post.name)) {
post.nameSpan = new SpannableString(post.name);
post.nameSpan.setSpan(new ForegroundColorSpan(ta.getColor(R.styleable.PostView_name_color, 0)), 0, post.nameSpan.length(), 0);
if (!TextUtils.isEmpty(post.email)) {
post.nameSpan.setSpan(new UnderlineSpan(), 0, post.nameSpan.length(), 0);
}
}
if (!TextUtils.isEmpty(post.tripcode)) {
@ -137,6 +146,23 @@ public class ChanParser {
post.capcodeSpan.setSpan(new ForegroundColorSpan(ta.getColor(R.styleable.PostView_capcode_color, 0)), 0, post.capcodeSpan.length(), 0);
post.capcodeSpan.setSpan(new AbsoluteSizeSpan(detailSize), 0, post.capcodeSpan.length(), 0);
}
post.nameTripcodeIdCapcodeSpan = new SpannableString("");
if (post.nameSpan != null) {
post.nameTripcodeIdCapcodeSpan = TextUtils.concat(post.nameTripcodeIdCapcodeSpan, post.nameSpan, " ");
}
if (post.tripcodeSpan != null) {
post.nameTripcodeIdCapcodeSpan = TextUtils.concat(post.nameTripcodeIdCapcodeSpan, post.tripcodeSpan, " ");
}
if (post.idSpan != null) {
post.nameTripcodeIdCapcodeSpan = TextUtils.concat(post.nameTripcodeIdCapcodeSpan, post.idSpan, " ");
}
if (post.capcodeSpan != null) {
post.nameTripcodeIdCapcodeSpan = TextUtils.concat(post.nameTripcodeIdCapcodeSpan, post.capcodeSpan, " ");
}
}
private CharSequence parseComment(Post post, String commentRaw) {

@ -351,10 +351,6 @@ public class ThreadManager implements Loader.LoaderListener {
text += "\nId: " + post.id;
}
if (!TextUtils.isEmpty(post.email)) {
text += "\nEmail: " + post.email;
}
if (!TextUtils.isEmpty(post.tripcode)) {
text += "\nTripcode: " + post.tripcode;
}

@ -56,7 +56,6 @@ public class Post {
public String country = "";
public String countryName = "";
public long time = -1;
public String email = "";
public boolean isSavedReply = false;
public String title = "";
public int fileSize;
@ -82,6 +81,7 @@ public class Post {
public SpannableString tripcodeSpan;
public SpannableString idSpan;
public SpannableString capcodeSpan;
public CharSequence nameTripcodeIdCapcodeSpan;
/**
* The PostView the Post is currently bound to.

@ -23,9 +23,7 @@ import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import org.floens.chan.ChanApplication;
import org.floens.chan.R;
import org.floens.chan.chan.ChanUrls;
import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.model.Loadable;
import org.floens.chan.core.model.Post;
@ -87,10 +85,6 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> {
}
private List<Post> processPosts(List<Post> serverList) throws Exception {
boolean anonymize = ChanPreferences.getAnonymize();
boolean anonymizeIds = ChanPreferences.getAnonymizeIds();
String name = ChanApplication.getInstance().getString(R.string.default_name);
List<Post> totalList = new ArrayList<>(serverList.size());
if (cached.size() > 0) {
@ -178,16 +172,6 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> {
for (Post post : totalList) {
post.isSavedReply = ChanApplication.getDatabaseManager().isSavedReply(post.board, post.no);
if (anonymize) {
post.name = name;
post.email = "";
post.tripcode = "";
}
if (anonymizeIds) {
post.id = "";
}
}
return totalList;
@ -317,9 +301,6 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> {
case "time":
post.time = reader.nextLong();
break;
case "email":
post.email = reader.nextString();
break;
case "ext":
post.ext = reader.nextString().replace(".", "");
break;

@ -147,33 +147,12 @@ public class PostView extends LinearLayout implements View.OnClickListener {
}
if (isList()) {
if (post.subjectSpan != null) {
total = TextUtils.concat(total, "\n");
}
if (post.nameSpan != null) {
total = TextUtils.concat(total, post.nameSpan, " ");
}
if (post.tripcodeSpan != null) {
total = TextUtils.concat(total, post.tripcodeSpan, " ");
}
if (post.idSpan != null) {
total = TextUtils.concat(total, post.idSpan, " ");
}
if (post.capcodeSpan != null) {
total = TextUtils.concat(total, post.capcodeSpan, " ");
}
CharSequence relativeTime = DateUtils.getRelativeTimeSpanString(post.time * 1000L, Time.get(),
DateUtils.SECOND_IN_MILLIS, 0);
CharSequence relativeTime = DateUtils.getRelativeTimeSpanString(post.time * 1000L, Time.get(), DateUtils.SECOND_IN_MILLIS, 0);
SpannableString date = new SpannableString("No." + post.no + " " + relativeTime);
date.setSpan(new ForegroundColorSpan(dateColor), 0, date.length(), 0);
date.setSpan(new AbsoluteSizeSpan(detailSize), 0, date.length(), 0);
total = TextUtils.concat(total, date, " ");
total = TextUtils.concat(total, post.subjectSpan == null ? "" : "\n", post.nameTripcodeIdCapcodeSpan, date, " ");
}
if (!TextUtils.isEmpty(total)) {

Loading…
Cancel
Save