Skip to content
This repository was archived by the owner on Nov 28, 2024. It is now read-only.

Commit bb0e3ff

Browse files
authored
Use published field from API (#49)
#fix #33 FreshRSS/FreshRSS#2773 (comment) Use advertised `published` date instead of crawl time.
1 parent 928a241 commit bb0e3ff

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

app/src/main/java/org/freshrss/easyrss/FeedViewCtrl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void run() {
205205

206206
final private static String INTENT_KEY_ID = "id";
207207
final private static String ITEM_PROJECTION[] = new String[] { Item._UID, Item._TITLE, ItemState._ISREAD,
208-
ItemState._ISSTARRED, Item._TIMESTAMP, Item._SOURCETITLE };
208+
ItemState._ISSTARRED, Item._TIMESTAMP, Item._UPDATETIME, Item._SOURCETITLE };
209209

210210
final private static int MSG_DISMISS_DIALOG = 1;
211211
final private static int MSG_ITEM_LONG_CLICK = 0;

app/src/main/java/org/freshrss/easyrss/ItemListWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void setListener(final ItemListWrapperListener listener) {
8585

8686
public void updateItem(final Item item) {
8787
adapter.updateItem(new ListItemItem(item.getUid(), item.getTitle(), item.getSourceTitle(), item.getState()
88-
.isRead(), item.getState().isStarred(), item.getTimestamp()));
88+
.isRead(), item.getState().isStarred(), item.getUpdateTime()));
8989
}
9090

9191
public void updateItemEndDisabled() {

app/src/main/java/org/freshrss/easyrss/VerticalSingleItemView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
public class VerticalSingleItemView implements OnScrollChangedListener, OnTouchListener {
6464
final private static String ITEM_PROJECTION[] = new String[] { Item._UID, Item._TITLE, ItemState._ISCACHED,
65-
ItemState._ISREAD, ItemState._ISSTARRED, Item._TIMESTAMP, Item._SOURCETITLE, Item._AUTHOR, Item._HREF };
65+
ItemState._ISREAD, ItemState._ISSTARRED, Item._TIMESTAMP, Item._UPDATETIME, Item._SOURCETITLE, Item._AUTHOR, Item._HREF };
6666

6767
final private DataMgr dataMgr;
6868
final private Context context;
@@ -240,7 +240,7 @@ public void onClick(final View view) {
240240
final StringBuilder infoText = new StringBuilder();
241241
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
242242
sdf.setTimeZone(TimeZone.getDefault());
243-
infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp())));
243+
infoText.append(sdf.format(Utils.timestampToDate(item.getUpdateTime())));
244244
if (item.getAuthor() != null && item.getAuthor().length() > 0) {
245245
infoText.append(" | By ");
246246
infoText.append(item.getAuthor());

app/src/main/java/org/freshrss/easyrss/WebpageItemViewCtrl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void handleMessage(final Message msg) {
6565
}
6666
}
6767
};
68-
final private static String ITEM_PROJECTION[] = new String[] { Item._UID, Item._TITLE, Item._TIMESTAMP,
68+
final private static String ITEM_PROJECTION[] = new String[] { Item._UID, Item._TITLE, Item._TIMESTAMP, Item._UPDATETIME,
6969
Item._SOURCETITLE, Item._AUTHOR, Item._HREF };
7070
final private static int MSG_LOADING_FINISHED = 0;
7171

@@ -208,7 +208,7 @@ private void showMobilizedPage() {
208208
final StringBuilder infoText = new StringBuilder();
209209
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
210210
sdf.setTimeZone(TimeZone.getDefault());
211-
infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp())));
211+
infoText.append(sdf.format(Utils.timestampToDate(item.getUpdateTime())));
212212
if (item.getAuthor() != null && item.getAuthor().length() > 0) {
213213
infoText.append(" | By ");
214214
infoText.append(item.getAuthor());

app/src/main/java/org/freshrss/easyrss/data/DataMgr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public int removeOutdatedItemsWithLimit(final int limit) {
565565
int ret = 0;
566566
final ContentResolver resolver = context.getContentResolver();
567567
final Cursor cur = resolver.query(Uri.withAppendedPath(Item.CONTENT_URI, "offset/" + limit),
568-
new String[] { Item._UID }, null, null, Item._UPDATETIME + " DESC");
568+
new String[] { Item._UID }, null, null, Item._TIMESTAMP + " DESC");
569569
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
570570
ret += removeItemByUid(Item.fromCursor(cur).getUid());
571571
}

app/src/main/java/org/freshrss/easyrss/data/Item.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ public String getUid() {
160160
}
161161

162162
public long getUpdateTime() {
163-
return updateTime;
163+
return updateTime > 0 ? updateTime : timestamp;
164+
}
165+
public long getUpdateTime(final boolean raw) {
166+
return raw ? updateTime : getUpdateTime();
164167
}
165168

166169
private void init(final String author, final String uid, final String content, final String href,
@@ -174,7 +177,7 @@ private void init(final String author, final String uid, final String content, f
174177
this.sourceTitle = (sourceTitle == null) ? "" : sourceTitle;
175178
this.title = (title == null) ? "" : title;
176179
this.tags = (tags == null) ? new LinkedList<String>() : tags;
177-
this.updateTime = (updateTime == null) ? System.currentTimeMillis() : updateTime;
180+
this.updateTime = (updateTime == null) ? 0 : updateTime;
178181
this.timestamp = (timestamp == null) ? 0 : timestamp;
179182
this.state = (state == null) ? new ItemState() : state;
180183
}

app/src/main/java/org/freshrss/easyrss/data/parser/ItemJSONParser.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ private void parse() throws JsonParseException, IOException {
8080
item.setHref(parser.getText());
8181
}
8282
break;
83+
case VALUE_NUMBER_INT:
84+
if (level == 3) {
85+
if ("updated".equals(name)) {
86+
item.setUpdateTime(parser.getLongValue() * 1000000);
87+
} else if ("published".equals(name)) {
88+
if (item.getUpdateTime(true) <= 0) {
89+
item.setUpdateTime(parser.getLongValue() * 1000000);
90+
}
91+
}
92+
}
93+
break;
8394
case FIELD_NAME:
8495
if (level == 1 && "items".equals(name)) {
8596
found = true;

0 commit comments

Comments
 (0)