import java.awt.event.WindowEvent;
import java.beans.PropertyChangeListener;
import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
public class BlogReader extends GBlogReader
{
- private JButton buttonAbout = new JButton();
-
private JButton buttonRefresh = new JButton();
private JToolBar toolBar = new JToolBar();
private JPanel bottomPanel = new JPanel();
- private BorderLayout borderLayout2 = new BorderLayout();
-
- private BorderLayout borderLayout3 = new BorderLayout();
-
private JSplitPane topBottomSplitPane = new JSplitPane();
private JList listItems = new JList(new DefaultListModel());
*/
private boolean checkForNew(Channel chan, boolean updateItems)
{
+
if (!updating || updateItems)
{
newsnew = false;
}
+ java.util.Date earliest=null;
+ try {
+ earliest = new SimpleDateFormat("YYYY-MM-DD").parse(chan.getHTTPLastModified());
+ } catch (Exception x) {};
if (chan != null && chan.getItems() != null)
{
+ Cache.log.debug("Scanning news items: newsnew="+newsnew+" and lastDate is "+lastDate);
for (Item i : (List<Item>) chan.getItems())
{
- boolean isread = (lastDate != null && i.getPublishDate() != null && !lastDate
+ boolean isread = lastDate==null ? false : (i.getPublishDate() != null && !lastDate
.before(i.getPublishDate()));
- if (i.getPublishDate() != null && (!updating || updateItems))
+ if (!updating || updateItems)
{
newsnew |= !isread;
}
{
i.setRead(isread);
}
+ if (i.getPublishDate()!=null && !i.isRead())
+ {
+ if (earliest==null || earliest.after(i.getPublishDate()))
+ {
+ earliest=i.getPublishDate();
+ }
+ }
}
}
+ if (!updateItems && !updating && lastDate==null)
+ {
+ lastDate=earliest;
+ }
return newsnew;
}
private void saveLastM(Item item)
{
- if (item != null && item.getPublishDate() != null
- && (lastDate == null || item.getPublishDate().after(lastDate)))
+ if (item != null)
{
- lastDate = item.getPublishDate();
- if (lastDate != null)
+ if (item.getPublishDate() != null)
{
- jalview.bin.Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED",
- lastDate);
- jalview.bin.Cache.log.info("Saved last read date as "
- + jalview.bin.Cache.date_format.format(lastDate));
-
+ if (lastDate==null || item.getPublishDate().after(lastDate))
+ {
+ lastDate = item.getPublishDate();
+ }
}
+
if (_channelModel.getElementAt(0) != null)
{
checkForNew((Channel) _channelModel.getElementAt(0), false);
}
+ if (lastDate != null)
+ {
+ jalview.bin.Cache.setDateProperty(
+ "JALVIEW_NEWS_RSS_LASTMODIFIED", lastDate);
+ jalview.bin.Cache.log.info("Saved last read date as "
+ + jalview.bin.Cache.date_format.format(lastDate));
+
+ }
}
}