Show last edited time of comments

This commit is contained in:
seven332 committed 2019-06-10 19:41:24 +08:00
1 parent 2e56ba4ed0
commit e68d4ad2c4
7 files changed
+25

No files matched your search

@@ -33,6 +33,7 @@ public class GalleryComment implements Parcelable {
public long time;
public String user;
public String comment;
public long lastEdited;
@Override
public int describeContents() {
@@ -52,6 +53,7 @@ public class GalleryComment implements Parcelable {
dest.writeLong(this.time);
dest.writeString(this.user);
dest.writeString(this.comment);
dest.writeLong(this.lastEdited);
}
public GalleryComment() {
@@ -69,6 +71,7 @@ public class GalleryComment implements Parcelable {
this.time = in.readLong();
this.user = in.readString();
this.comment = in.readString();
this.lastEdited = in.readLong();
}
public static final Creator<GalleryComment> CREATOR = new Creator<GalleryComment>() {
@@ -444,6 +444,14 @@ public class GalleryDetailParser {
comment.user = c3.child(0).text();
// comment
comment.comment = JsoupUtils.getElementByClass(element, "c6").html();
// last edited
Element c8 = JsoupUtils.getElementByClass(element, "c8");
if (c8 != null) {
Element e = c8.children().first();
if (e != null) {
comment.lastEdited = WEB_COMMENT_DATE_FORMAT.parse(temp).getTime();
}
}
return comment;
} catch (Throwable e) {
ExceptionUtils.throwIfFatal(e);
@@ -687,6 +687,16 @@ public final class GalleryCommentsScene extends ToolbarScene
ssb.append(" ").append(ss);
}
if (comment.lastEdited != 0) {
String str = context.getString(R.string.last_edited, ReadableTime.getTimeAgo(comment.lastEdited));
SpannableString ss = new SpannableString(str);
ss.setSpan(new RelativeSizeSpan(0.8f), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new ForegroundColorSpan(AttrResources.getAttrColor(context, android.R.attr.textColorSecondary)),
0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
ssb.append("\n\n").append(ss);
}
return TextUrl.handleTextUrl(ssb);
}