1 25 26 29 package net.killingar.forum.actions.comic; 30 31 import net.killingar.forum.internal.Comic; 32 33 import java.util.ArrayList ; 34 35 public class List extends ActionComicsSupport 36 { 37 39 java.util.List subscribed = new ArrayList (); 41 java.util.List ignored = new ArrayList (); 42 boolean showIgnored = false; 43 44 46 static class ComicData implements Comparable 48 { 49 Comic comic; 50 boolean unread; 51 long position; 52 53 public ComicData(Comic comic, boolean unread, long position) 54 { 55 this.comic = comic; 56 this.unread = unread; 57 this.position = position; 58 } 59 60 public Comic getComic() { return comic; } 61 public boolean getUnread() { return unread; } 62 public long getPosition() { return position; } 63 64 public int compareTo(Object _o) 65 { 66 ComicData o = (ComicData)_o; 67 return comic.compareTo(o.comic); 68 } 69 } 70 71 public void setShowIgnored(boolean showIgnored) { this.showIgnored = showIgnored; } 73 74 public java.util.List getSubscribed() { return subscribed; } 76 public java.util.List getIgnored() { return ignored; } 77 public boolean getShowIgnored() { return showIgnored; } 78 79 80 protected String doExecute() 82 { 83 try 84 { 85 Comic comics[] = comicmgr.getComics(); 86 87 for (int i = 0; i < comics.length; i++) 88 { 89 Comic c = comics[i]; 90 long pos = comicmgr.getPosition(manager.getUserID(), comics[i].ID); 91 if (pos == 0 || pos == -1) 92 pos = c.firstID; 93 94 if (itemLists.hasItem("comics hotlist", Long.toString(comics[i].ID))) 95 { 96 subscribed.add(new ComicData(comics[i], pos < c.latestID, pos)); 97 } 98 else 99 { 100 ignored.add(new ComicData(comics[i], pos < c.latestID, pos)); 101 } 102 } 103 104 java.util.Collections.sort(subscribed); 105 java.util.Collections.sort(ignored); 106 107 if (subscribed.size() == 0) 108 showIgnored = true; 109 } 110 catch (Exception e) 111 { 112 e.printStackTrace(); 113 addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString()); 114 return ERROR; 115 } 116 117 return SUCCESS; 118 } 119 } 120 | Popular Tags |