1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

3 CustomLinks bugs have been fixed

git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@1568 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Vasiliy Bout 2010-07-09 13:44:19 +00:00
parent d1f7d2d0cd
commit 554ed2448a
3 changed files with 25 additions and 14 deletions

View file

@ -249,7 +249,9 @@ public class NetworkLibrary {
new NetworkDatabase.ICustomLinksFactory() {
public ICustomNetworkLink createCustomLink(int id, String siteName,
String title, String summary, String icon, Map<String, String> links) {
return reader.createCustomLink(id, siteName, title, summary, icon, links);
final ICustomNetworkLink link = reader.createCustomLink(id, siteName, title, summary, icon, links);
link.setSaveLinkListener(myChangesListener);
return link;
}
}
);
@ -453,20 +455,15 @@ public class NetworkLibrary {
}
};
/**
* @return <code>false</code> if this library already contains link with the specified title
* <code>true</code> if links has been inserted into this library
*/
public boolean addCustomLink(ICustomNetworkLink link) {
public void addCustomLink(ICustomNetworkLink link) {
final int index = Collections.binarySearch(myCustomLinks, link, new LinksComparator());
if (index >= 0) {
return false;
throw new RuntimeException("Unable to add link with duplicated title to the library");
}
final int insertAt = -index - 1;
myCustomLinks.add(insertAt, link);
link.setSaveLinkListener(myChangesListener);
link.saveLink();
return true;
}
public int getCustomLinksNumber() {
@ -486,4 +483,13 @@ public class NetworkLibrary {
NetworkDatabase.Instance().deleteCustomLink(link);
link.setSaveLinkListener(null);
}
public boolean hasCustomLink(String title, ICustomNetworkLink exeptFor) {
for (ICustomNetworkLink link: myCustomLinks) {
if (link != exeptFor && link.getTitle().equals(title)) {
return true;
}
}
return false;
}
}