Fixed some bugs
- Removed Feed duplication bug - Removed Article duplication in FeedData - Removed table updating in UpdaterThread
This commit is contained in:
parent
9186406a97
commit
9c3f700fc1
3 changed files with 23 additions and 10 deletions
|
@ -222,6 +222,20 @@ public class FeedData extends AbstractTableModel {
|
|||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Megnézi hogy egy magadott cikk megtalálható-e a cikklistában
|
||||
* @param a a keresett cikk
|
||||
* @return logikai érték az alapján,hogy a megadott cikk meg lett-e találva
|
||||
* Megjegyzés: Ez egy lineáris keresést hajt végre
|
||||
*/
|
||||
public boolean hasAricle(Article a) {
|
||||
for (Article art : articleList) {
|
||||
if (art.getURL() != null && art.getURL().equals(a.getURL()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A listában található összes hírcsatorna frissítése
|
||||
*/
|
||||
|
@ -229,7 +243,9 @@ public class FeedData extends AbstractTableModel {
|
|||
for (int i = 0; i < feeds.size(); i++) {
|
||||
feeds.get(i).updateFeed();
|
||||
for (int j = 0; j < feeds.get(i).getArticleCount(); j++) {
|
||||
articleList.add(feeds.get(i).get(j));
|
||||
Article a = feeds.get(i).get(j);
|
||||
if(!hasAricle(a))
|
||||
articleList.add(feeds.get(i).get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +284,7 @@ public class FeedData extends AbstractTableModel {
|
|||
});
|
||||
xStream.processAnnotations(Article.class);
|
||||
xStream.processAnnotations(Feed.class);
|
||||
xStream.alias("feedGroup", FeedGroup.class);
|
||||
xStream.processAnnotations(FeedGroup.class);
|
||||
xStream.addImplicitArray(FeedList.class, "list", Feed.class);
|
||||
return xStream;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.awt.datatransfer.Transferable;
|
|||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
@ -34,7 +33,7 @@ public class FeedFrame extends JFrame {
|
|||
setMinimumSize(new Dimension(900, 600));
|
||||
initData();
|
||||
initComponents();
|
||||
UpdaterThread updater = new UpdaterThread(data, this);
|
||||
UpdaterThread updater = new UpdaterThread(data);
|
||||
updater.start();
|
||||
}
|
||||
|
||||
|
@ -199,12 +198,14 @@ public class FeedFrame extends JFrame {
|
|||
initSearchBar();
|
||||
initMenuBar();
|
||||
initTree();
|
||||
UpdaterThread updaterThread = new UpdaterThread(data);
|
||||
updaterThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Frissiíti a táblázatot
|
||||
*/
|
||||
public void updateTable() {
|
||||
public synchronized void updateTable() {
|
||||
sorter.setModel(data);
|
||||
table.setRowSorter(sorter);
|
||||
table.updateUI();
|
||||
|
@ -231,7 +232,6 @@ public class FeedFrame extends JFrame {
|
|||
}
|
||||
data.addFeed(f);
|
||||
treeRoot.add(f.getTreeNode());
|
||||
data.addFeed(f);
|
||||
table.updateUI();
|
||||
feeds.updateUI();
|
||||
}
|
||||
|
|
|
@ -8,13 +8,11 @@ import java.io.IOException;
|
|||
*/
|
||||
public class UpdaterThread extends Thread{
|
||||
FeedData data;
|
||||
FeedFrame frame;
|
||||
//Tíz perc várakozás
|
||||
private static long updateInterval = 10*60*1000;
|
||||
|
||||
public UpdaterThread(FeedData data,FeedFrame frame){
|
||||
public UpdaterThread(FeedData data){
|
||||
this.data = data;
|
||||
this.frame =frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +24,6 @@ public class UpdaterThread extends Thread{
|
|||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
frame.updateTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue