mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
library tree summaries
This commit is contained in:
parent
b2019b17c3
commit
3d7fd1b52a
28 changed files with 272 additions and 84 deletions
|
@ -27,7 +27,7 @@ import android.view.*;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
import org.geometerplus.zlibrary.core.resources.ZLResource;
|
||||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
||||||
final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
|
final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
|
||||||
pattern = pattern.toLowerCase();
|
pattern = pattern.toLowerCase();
|
||||||
for (Bookmark b : myAllBooksBookmarks) {
|
for (Bookmark b : myAllBooksBookmarks) {
|
||||||
if (ZLMiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
|
if (MiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
|
||||||
bookmarks.add(b);
|
bookmarks.add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,6 +299,50 @@ public class BookCollectionShadow extends AbstractBookCollection implements Serv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized List<String> titlesForAuthor(Author author, int limit) {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return myInterface.titlesForAuthor(Util.authorToString(author), limit);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized List<String> titlesForSeries(String series, int limit) {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return myInterface.titlesForSeries(series, limit);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized List<String> titlesForTag(Tag tag, int limit) {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return myInterface.titlesForTag(Util.tagToString(tag), limit);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized List<String> titlesForTitlePrefix(String prefix, int limit) {
|
||||||
|
if (myInterface == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return myInterface.titlesForTitlePrefix(prefix, limit);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized boolean saveBook(Book book, boolean force) {
|
public synchronized boolean saveBook(Book book, boolean force) {
|
||||||
if (myInterface == null) {
|
if (myInterface == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,6 +26,10 @@ interface LibraryInterface {
|
||||||
List<String> series();
|
List<String> series();
|
||||||
List<String> tags();
|
List<String> tags();
|
||||||
List<String> titles();
|
List<String> titles();
|
||||||
|
List<String> titlesForAuthor(in String author, int limit);
|
||||||
|
List<String> titlesForSeries(in String series, int limit);
|
||||||
|
List<String> titlesForTag(in String tag, int limit);
|
||||||
|
List<String> titlesForTitlePrefix(in String prefix, int limit);
|
||||||
|
|
||||||
boolean saveBook(in String book, in boolean force);
|
boolean saveBook(in String book, in boolean force);
|
||||||
void removeBook(in String book, in boolean deleteFromDisk);
|
void removeBook(in String book, in boolean deleteFromDisk);
|
||||||
|
|
|
@ -189,6 +189,22 @@ public class LibraryService extends Service {
|
||||||
return myCollection.titles();
|
return myCollection.titles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForAuthor(String author, int limit) {
|
||||||
|
return myCollection.titlesForAuthor(Util.stringToAuthor(author), limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForSeries(String series, int limit) {
|
||||||
|
return myCollection.titlesForSeries(series, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForTag(String tag, int limit) {
|
||||||
|
return myCollection.titlesForTag(Util.stringToTag(tag), limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForTitlePrefix(String prefix, int limit) {
|
||||||
|
return myCollection.titlesForTitlePrefix(prefix, limit);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean saveBook(String book, boolean force) {
|
public boolean saveBook(String book, boolean force) {
|
||||||
return myCollection.saveBook(SerializerUtil.deserializeBook(book), force);
|
return myCollection.saveBook(SerializerUtil.deserializeBook(book), force);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ import java.io.IOException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
|
||||||
import org.geometerplus.zlibrary.core.filesystem.*;
|
import org.geometerplus.zlibrary.core.filesystem.*;
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
import org.geometerplus.zlibrary.text.view.ZLTextPosition;
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ public class Book {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
if (!ZLMiscUtil.equals(myTitle, title)) {
|
if (!MiscUtil.equals(myTitle, title)) {
|
||||||
myTitle = title;
|
myTitle = title;
|
||||||
myIsSaved = false;
|
myIsSaved = false;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ public class Book {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguage(String language) {
|
public void setLanguage(String language) {
|
||||||
if (!ZLMiscUtil.equals(myLanguage, language)) {
|
if (!MiscUtil.equals(myLanguage, language)) {
|
||||||
myLanguage = language;
|
myLanguage = language;
|
||||||
myIsSaved = false;
|
myIsSaved = false;
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ public class Book {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEncoding(String encoding) {
|
public void setEncoding(String encoding) {
|
||||||
if (!ZLMiscUtil.equals(myEncoding, encoding)) {
|
if (!MiscUtil.equals(myEncoding, encoding)) {
|
||||||
myEncoding = encoding;
|
myEncoding = encoding;
|
||||||
myIsSaved = false;
|
myIsSaved = false;
|
||||||
}
|
}
|
||||||
|
@ -391,27 +391,27 @@ public class Book {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(String pattern) {
|
public boolean matches(String pattern) {
|
||||||
if (myTitle != null && ZLMiscUtil.matchesIgnoreCase(myTitle, pattern)) {
|
if (myTitle != null && MiscUtil.matchesIgnoreCase(myTitle, pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (mySeriesInfo != null && ZLMiscUtil.matchesIgnoreCase(mySeriesInfo.Title, pattern)) {
|
if (mySeriesInfo != null && MiscUtil.matchesIgnoreCase(mySeriesInfo.Title, pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (myAuthors != null) {
|
if (myAuthors != null) {
|
||||||
for (Author author : myAuthors) {
|
for (Author author : myAuthors) {
|
||||||
if (ZLMiscUtil.matchesIgnoreCase(author.DisplayName, pattern)) {
|
if (MiscUtil.matchesIgnoreCase(author.DisplayName, pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (myTags != null) {
|
if (myTags != null) {
|
||||||
for (Tag tag : myTags) {
|
for (Tag tag : myTags) {
|
||||||
if (ZLMiscUtil.matchesIgnoreCase(tag.Name, pattern)) {
|
if (MiscUtil.matchesIgnoreCase(tag.Name, pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ZLMiscUtil.matchesIgnoreCase(File.getLongName(), pattern)) {
|
if (MiscUtil.matchesIgnoreCase(File.getLongName(), pattern)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -344,6 +344,81 @@ public class BookCollection extends AbstractBookCollection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForAuthor(Author author, int limit) {
|
||||||
|
if (limit <= 0) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
final ArrayList<String> titles = new ArrayList<String>(limit);
|
||||||
|
final boolean isNull = Author.NULL.equals(author);
|
||||||
|
synchronized (myBooksByFile) {
|
||||||
|
for (Book b : myBooksByFile.values()) {
|
||||||
|
if (isNull ? b.authors().isEmpty() : b.authors().contains(author)) {
|
||||||
|
titles.add(b.getTitle());
|
||||||
|
if (--limit == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return titles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForSeries(String series, int limit) {
|
||||||
|
if (limit <= 0) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
final ArrayList<String> titles = new ArrayList<String>(limit);
|
||||||
|
synchronized (myBooksByFile) {
|
||||||
|
for (Book b : myBooksByFile.values()) {
|
||||||
|
final SeriesInfo info = b.getSeriesInfo();
|
||||||
|
if (info != null && series.equals(info.Title)) {
|
||||||
|
titles.add(b.getTitle());
|
||||||
|
if (--limit == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return titles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForTag(Tag tag, int limit) {
|
||||||
|
if (limit <= 0) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
final ArrayList<String> titles = new ArrayList<String>(limit);
|
||||||
|
final boolean isNull = Tag.NULL.equals(tag);
|
||||||
|
synchronized (myBooksByFile) {
|
||||||
|
for (Book b : myBooksByFile.values()) {
|
||||||
|
if (isNull ? b.tags().isEmpty() : b.tags().contains(tag)) {
|
||||||
|
titles.add(b.getTitle());
|
||||||
|
if (--limit == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return titles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> titlesForTitlePrefix(String prefix, int limit) {
|
||||||
|
if (limit <= 0) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
final ArrayList<String> titles = new ArrayList<String>(limit);
|
||||||
|
synchronized (myBooksByFile) {
|
||||||
|
for (Book b : myBooksByFile.values()) {
|
||||||
|
if (prefix.equals(TitleUtil.firstTitleLetter(b))) {
|
||||||
|
titles.add(b.getTitle());
|
||||||
|
if (--limit == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return titles;
|
||||||
|
}
|
||||||
|
|
||||||
public Book getRecentBook(int index) {
|
public Book getRecentBook(int index) {
|
||||||
List<Long> recentIds = myDatabase.loadRecentBookIds();
|
List<Long> recentIds = myDatabase.loadRecentBookIds();
|
||||||
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
|
return recentIds.size() > index ? getBookById(recentIds.get(index)) : null;
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.fbreader.book;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
import org.geometerplus.zlibrary.core.filesystem.*;
|
import org.geometerplus.zlibrary.core.filesystem.*;
|
||||||
|
|
||||||
public final class FileInfoSet {
|
public final class FileInfoSet {
|
||||||
|
@ -48,7 +48,7 @@ public final class FileInfoSet {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Pair p = (Pair)o;
|
Pair p = (Pair)o;
|
||||||
return (myName.equals(p.myName)) && ZLMiscUtil.equals(myParent, p.myParent);
|
return myName.equals(p.myName) && MiscUtil.equals(myParent, p.myParent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,10 @@ public interface IBookCollection {
|
||||||
List<String> series();
|
List<String> series();
|
||||||
List<Tag> tags();
|
List<Tag> tags();
|
||||||
List<String> titles();
|
List<String> titles();
|
||||||
|
List<String> titlesForAuthor(Author author, int limit);
|
||||||
|
List<String> titlesForSeries(String series, int limit);
|
||||||
|
List<String> titlesForTag(Tag tag, int limit);
|
||||||
|
List<String> titlesForTitlePrefix(String prefix, int limit);
|
||||||
|
|
||||||
boolean saveBook(Book book, boolean force);
|
boolean saveBook(Book book, boolean force);
|
||||||
void removeBook(Book book, boolean deleteFromDisk);
|
void removeBook(Book book, boolean deleteFromDisk);
|
||||||
|
|
|
@ -22,6 +22,8 @@ package org.geometerplus.fbreader.library;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
public class AuthorTree extends LibraryTree {
|
public class AuthorTree extends LibraryTree {
|
||||||
|
@ -43,6 +45,11 @@ public class AuthorTree extends LibraryTree {
|
||||||
? Library.resource().getResource("unknownAuthor").getValue() : Author.DisplayName;
|
? Library.resource().getResource("unknownAuthor").getValue() : Author.DisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return MiscUtil.join(Collection.titlesForAuthor(Author, 5), ", ");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return "@AuthorTree" + getSortKey();
|
return "@AuthorTree" + getSortKey();
|
||||||
|
|
|
@ -47,6 +47,11 @@ public class BookTree extends LibraryTree {
|
||||||
return Book.getTitle();
|
return Book.getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Book getBook() {
|
public Book getBook() {
|
||||||
return Book;
|
return Book;
|
||||||
|
|
|
@ -31,6 +31,11 @@ class RootTree extends LibraryTree {
|
||||||
return Library.resource().getValue();
|
return Library.resource().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return Library.resource().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return "@FBReaderLibraryRoot";
|
return "@FBReaderLibraryRoot";
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
public final class SeriesTree extends LibraryTree {
|
public final class SeriesTree extends LibraryTree {
|
||||||
|
@ -41,6 +43,11 @@ public final class SeriesTree extends LibraryTree {
|
||||||
return Series;
|
return Series;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return MiscUtil.join(Collection.titlesForSeries(Series, 5), ", ");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return "@SeriesTree " + getName();
|
return "@SeriesTree " + getName();
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
public final class TagTree extends LibraryTree {
|
public final class TagTree extends LibraryTree {
|
||||||
|
@ -42,6 +44,11 @@ public final class TagTree extends LibraryTree {
|
||||||
? Library.resource().getResource("booksWithNoTags").getValue() : Tag.Name;
|
? Library.resource().getResource("booksWithNoTags").getValue() : Tag.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return MiscUtil.join(Collection.titlesForTag(Tag, 5), ", ");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return "@TagTree " + getName();
|
return "@TagTree " + getName();
|
||||||
|
|
|
@ -19,34 +19,41 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
|
|
||||||
public final class TitleTree extends LibraryTree {
|
public final class TitleTree extends LibraryTree {
|
||||||
public final String Title;
|
public final String Prefix;
|
||||||
|
|
||||||
TitleTree(IBookCollection collection, String title) {
|
TitleTree(IBookCollection collection, String prefix) {
|
||||||
super(collection);
|
super(collection);
|
||||||
Title = title;
|
Prefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleTree(LibraryTree parent, String title, int position) {
|
TitleTree(LibraryTree parent, String prefix, int position) {
|
||||||
super(parent, position);
|
super(parent, position);
|
||||||
Title = title;
|
Prefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return Title;
|
return Prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return MiscUtil.join(Collection.titlesForTitlePrefix(Prefix, 5), ", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return "@TitleTree " + getName();
|
return "@PrefixTree " + getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsBook(Book book) {
|
public boolean containsBook(Book book) {
|
||||||
return Title.equals(TitleUtil.firstTitleLetter(book));
|
return Prefix.equals(TitleUtil.firstTitleLetter(book));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,7 +65,7 @@ public final class TitleTree extends LibraryTree {
|
||||||
public void waitForOpening() {
|
public void waitForOpening() {
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
for (Book b : Collection.booksForTitlePrefix(Title)) {
|
for (Book b : Collection.booksForTitlePrefix(Prefix)) {
|
||||||
createBookWithAuthorsSubTree(b);
|
createBookWithAuthorsSubTree(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +75,7 @@ public final class TitleTree extends LibraryTree {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case Added:
|
case Added:
|
||||||
return
|
return
|
||||||
Title.equals(TitleUtil.firstTitleLetter(book)) &&
|
Prefix.equals(TitleUtil.firstTitleLetter(book)) &&
|
||||||
createBookWithAuthorsSubTree(book);
|
createBookWithAuthorsSubTree(book);
|
||||||
case Removed:
|
case Removed:
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
|
|
|
@ -39,6 +39,22 @@ public abstract class NetworkTree extends FBTree {
|
||||||
super(parent, position);
|
super(parent, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
int count = 0;
|
||||||
|
for (FBTree subtree : subTrees()) {
|
||||||
|
if (count++ > 0) {
|
||||||
|
builder.append(", ");
|
||||||
|
}
|
||||||
|
builder.append(subtree.getName());
|
||||||
|
if (count == 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public INetworkLink getLink() {
|
public INetworkLink getLink() {
|
||||||
final NetworkTree parent = (NetworkTree)Parent;
|
final NetworkTree parent = (NetworkTree)Parent;
|
||||||
return parent != null ? parent.getLink() : null;
|
return parent != null ? parent.getLink() : null;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.network.BasketItem;
|
import org.geometerplus.fbreader.network.BasketItem;
|
||||||
import org.geometerplus.fbreader.network.urlInfo.*;
|
import org.geometerplus.fbreader.network.urlInfo.*;
|
||||||
|
@ -54,7 +54,7 @@ class OPDSBasketItem extends BasketItem {
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
url = url.replace("{ids}", ZLMiscUtil.listToString(ids, ","));
|
url = url.replace("{ids}", MiscUtil.join(ids, ","));
|
||||||
|
|
||||||
final OPDSCatalogItem.State state = opdsLink.createOperationData(loader);
|
final OPDSCatalogItem.State state = opdsLink.createOperationData(loader);
|
||||||
doLoadChildren(state, opdsLink.createNetworkData(url, MimeType.APP_ATOM_XML, state));
|
doLoadChildren(state, opdsLink.createNetworkData(url, MimeType.APP_ATOM_XML, state));
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.network.*;
|
import org.geometerplus.zlibrary.core.network.*;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.network.ICustomNetworkLink;
|
import org.geometerplus.fbreader.network.ICustomNetworkLink;
|
||||||
import org.geometerplus.fbreader.network.NetworkException;
|
import org.geometerplus.fbreader.network.NetworkException;
|
||||||
|
@ -60,17 +60,17 @@ public class OPDSCustomNetworkLink extends OPDSNetworkLink implements ICustomNet
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setSiteName(String name) {
|
public final void setSiteName(String name) {
|
||||||
myHasChanges = myHasChanges || !ZLMiscUtil.equals(mySiteName, name);
|
myHasChanges = myHasChanges || !MiscUtil.equals(mySiteName, name);
|
||||||
mySiteName = name;
|
mySiteName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setSummary(String summary) {
|
public final void setSummary(String summary) {
|
||||||
myHasChanges = myHasChanges || !ZLMiscUtil.equals(mySummary, summary);
|
myHasChanges = myHasChanges || !MiscUtil.equals(mySummary, summary);
|
||||||
mySummary = summary;
|
mySummary = summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setTitle(String title) {
|
public final void setTitle(String title) {
|
||||||
myHasChanges = myHasChanges || !ZLMiscUtil.equals(myTitle, title);
|
myHasChanges = myHasChanges || !MiscUtil.equals(myTitle, title);
|
||||||
myTitle = title;
|
myTitle = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import java.io.UnsupportedEncodingException;
|
||||||
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
|
||||||
import org.geometerplus.zlibrary.core.network.ZLNetworkRequest;
|
import org.geometerplus.zlibrary.core.network.ZLNetworkRequest;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
|
||||||
|
|
||||||
import org.geometerplus.fbreader.network.*;
|
import org.geometerplus.fbreader.network.*;
|
||||||
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
|
import org.geometerplus.fbreader.network.authentication.NetworkAuthenticationManager;
|
||||||
|
|
|
@ -110,8 +110,8 @@ class URLRewritingRule {
|
||||||
final URLRewritingRule rule = (URLRewritingRule) o;
|
final URLRewritingRule rule = (URLRewritingRule) o;
|
||||||
if (Type != rule.Type
|
if (Type != rule.Type
|
||||||
|| Apply != rule.Apply
|
|| Apply != rule.Apply
|
||||||
|| !ZLMiscUtil.equals(Name, rule.Name)
|
|| !MiscUtil.equals(Name, rule.Name)
|
||||||
|| !ZLMiscUtil.equals(Value, rule.Value)) {
|
|| !MiscUtil.equals(Value, rule.Value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -36,6 +36,11 @@ public final class RootTree extends NetworkTree {
|
||||||
return NetworkLibrary.resource().getValue();
|
return NetworkLibrary.resource().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSummary() {
|
||||||
|
return NetworkLibrary.resource().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getStringId() {
|
protected String getStringId() {
|
||||||
return myId;
|
return myId;
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.fbreader.network.urlInfo;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
|
|
||||||
public class UrlInfo implements Serializable {
|
public class UrlInfo implements Serializable {
|
||||||
|
@ -71,11 +71,11 @@ public class UrlInfo implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final UrlInfo info = (UrlInfo)o;
|
final UrlInfo info = (UrlInfo)o;
|
||||||
return InfoType == info.InfoType && ZLMiscUtil.equals(Url, info.Url);
|
return InfoType == info.InfoType && MiscUtil.equals(Url, info.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return InfoType.hashCode() + ZLMiscUtil.hashCode(Url);
|
return InfoType.hashCode() + MiscUtil.hashCode(Url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.geometerplus.fbreader.network.urlInfo;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.MimeType;
|
import org.geometerplus.zlibrary.core.util.MimeType;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
public final class UrlInfoWithDate extends UrlInfo {
|
public final class UrlInfoWithDate extends UrlInfo {
|
||||||
private static final long serialVersionUID = -896768978957787222L;
|
private static final long serialVersionUID = -896768978957787222L;
|
||||||
|
@ -52,13 +52,13 @@ public final class UrlInfoWithDate extends UrlInfo {
|
||||||
final UrlInfoWithDate info = (UrlInfoWithDate)o;
|
final UrlInfoWithDate info = (UrlInfoWithDate)o;
|
||||||
return
|
return
|
||||||
InfoType == info.InfoType &&
|
InfoType == info.InfoType &&
|
||||||
ZLMiscUtil.equals(Url, info.Url) &&
|
MiscUtil.equals(Url, info.Url) &&
|
||||||
ZLMiscUtil.equals(Mime, info.Mime) &&
|
MiscUtil.equals(Mime, info.Mime) &&
|
||||||
ZLMiscUtil.equals(Updated, info.Updated);
|
MiscUtil.equals(Updated, info.Updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return InfoType.hashCode() + ZLMiscUtil.hashCode(Url) + ZLMiscUtil.hashCode(Mime) + ZLMiscUtil.hashCode(Updated);
|
return InfoType.hashCode() + MiscUtil.hashCode(Url) + MiscUtil.hashCode(Mime) + MiscUtil.hashCode(Updated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ package org.geometerplus.fbreader.tree;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.tree.ZLTree;
|
|
||||||
import org.geometerplus.zlibrary.core.image.ZLImage;
|
import org.geometerplus.zlibrary.core.image.ZLImage;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.tree.ZLTree;
|
||||||
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree> {
|
public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree> {
|
||||||
public static class Key implements Serializable {
|
public static class Key implements Serializable {
|
||||||
|
@ -49,7 +49,7 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Key key = (Key)other;
|
final Key key = (Key)other;
|
||||||
return Id.equals(key.Id) && ZLMiscUtil.equals(Parent, key.Parent);
|
return Id.equals(key.Id) && MiscUtil.equals(Parent, key.Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -170,20 +170,7 @@ public abstract class FBTree extends ZLTree<FBTree> implements Comparable<FBTree
|
||||||
return compareStringsIgnoreCase(key0, key1);
|
return compareStringsIgnoreCase(key0, key1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSummary() {
|
public abstract String getSummary();
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
int count = 0;
|
|
||||||
for (FBTree subtree : subTrees()) {
|
|
||||||
if (count++ > 0) {
|
|
||||||
builder.append(", ");
|
|
||||||
}
|
|
||||||
builder.append(subtree.getName());
|
|
||||||
if (count == 5) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ZLImage createCover() {
|
protected ZLImage createCover() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
public class Money implements Comparable<Money>, Serializable {
|
public class Money implements Comparable<Money>, Serializable {
|
||||||
public static final Money ZERO = new Money();
|
public static final Money ZERO = new Money();
|
||||||
|
@ -133,12 +133,12 @@ public class Money implements Comparable<Money>, Serializable {
|
||||||
if (Amount.equals(ZERO.Amount)) {
|
if (Amount.equals(ZERO.Amount)) {
|
||||||
return m.Amount.equals(ZERO.Amount);
|
return m.Amount.equals(ZERO.Amount);
|
||||||
}
|
}
|
||||||
return Amount.equals(m.Amount) && ZLMiscUtil.equals(Currency, m.Currency);
|
return Amount.equals(m.Amount) && MiscUtil.equals(Currency, m.Currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Amount.hashCode() + ZLMiscUtil.hashCode(Currency);
|
return Amount.hashCode() + MiscUtil.hashCode(Currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.http.params.*;
|
||||||
import org.apache.http.protocol.HttpContext;
|
import org.apache.http.protocol.HttpContext;
|
||||||
import org.apache.http.protocol.BasicHttpContext;
|
import org.apache.http.protocol.BasicHttpContext;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
import org.geometerplus.zlibrary.core.util.ZLNetworkUtil;
|
import org.geometerplus.zlibrary.core.util.ZLNetworkUtil;
|
||||||
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
||||||
|
|
||||||
|
@ -76,9 +76,9 @@ public class ZLNetworkManager {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
myScope.getPort() == scope.getPort() &&
|
myScope.getPort() == scope.getPort() &&
|
||||||
ZLMiscUtil.equals(myScope.getHost(), scope.getHost()) &&
|
MiscUtil.equals(myScope.getHost(), scope.getHost()) &&
|
||||||
ZLMiscUtil.equals(myScope.getScheme(), scope.getScheme()) &&
|
MiscUtil.equals(myScope.getScheme(), scope.getScheme()) &&
|
||||||
ZLMiscUtil.equals(myScope.getRealm(), scope.getRealm());
|
MiscUtil.equals(myScope.getRealm(), scope.getRealm());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -87,9 +87,9 @@ public class ZLNetworkManager {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
myScope.getPort() +
|
myScope.getPort() +
|
||||||
ZLMiscUtil.hashCode(myScope.getHost()) +
|
MiscUtil.hashCode(myScope.getHost()) +
|
||||||
ZLMiscUtil.hashCode(myScope.getScheme()) +
|
MiscUtil.hashCode(myScope.getScheme()) +
|
||||||
ZLMiscUtil.hashCode(myScope.getRealm());
|
MiscUtil.hashCode(myScope.getRealm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,17 +199,17 @@ public class ZLNetworkManager {
|
||||||
}
|
}
|
||||||
final Key k = (Key)o;
|
final Key k = (Key)o;
|
||||||
return
|
return
|
||||||
ZLMiscUtil.equals(Domain, k.Domain) &&
|
MiscUtil.equals(Domain, k.Domain) &&
|
||||||
ZLMiscUtil.equals(Path, k.Path) &&
|
MiscUtil.equals(Path, k.Path) &&
|
||||||
ZLMiscUtil.equals(Name, k.Name);
|
MiscUtil.equals(Name, k.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return
|
return
|
||||||
ZLMiscUtil.hashCode(Domain) +
|
MiscUtil.hashCode(Domain) +
|
||||||
ZLMiscUtil.hashCode(Path) +
|
MiscUtil.hashCode(Path) +
|
||||||
ZLMiscUtil.hashCode(Name);
|
MiscUtil.hashCode(Name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.zlibrary.core.options;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.util.ZLMiscUtil;
|
import org.geometerplus.zlibrary.core.util.MiscUtil;
|
||||||
|
|
||||||
public class ZLStringListOption extends ZLOption {
|
public class ZLStringListOption extends ZLOption {
|
||||||
private final List<String> myDefaultValue;
|
private final List<String> myDefaultValue;
|
||||||
|
@ -44,9 +44,9 @@ public class ZLStringListOption extends ZLOption {
|
||||||
|
|
||||||
public List<String> getValue() {
|
public List<String> getValue() {
|
||||||
if (!myIsSynchronized) {
|
if (!myIsSynchronized) {
|
||||||
final String value = getConfigValue(ZLMiscUtil.listToString(myDefaultValue, myDelimiter));
|
final String value = getConfigValue(MiscUtil.join(myDefaultValue, myDelimiter));
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
myValue = ZLMiscUtil.stringToList(value, myDelimiter);
|
myValue = MiscUtil.split(value, myDelimiter);
|
||||||
}
|
}
|
||||||
myIsSynchronized = true;
|
myIsSynchronized = true;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class ZLStringListOption extends ZLOption {
|
||||||
if (value.equals(myDefaultValue)) {
|
if (value.equals(myDefaultValue)) {
|
||||||
unsetConfigValue();
|
unsetConfigValue();
|
||||||
} else {
|
} else {
|
||||||
setConfigValue(ZLMiscUtil.listToString(value, myDelimiter));
|
setConfigValue(MiscUtil.join(value, myDelimiter));
|
||||||
}
|
}
|
||||||
myIsSynchronized = true;
|
myIsSynchronized = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,17 +149,17 @@ public final class MimeType {
|
||||||
}
|
}
|
||||||
final MimeType type = (MimeType)o;
|
final MimeType type = (MimeType)o;
|
||||||
return
|
return
|
||||||
ZLMiscUtil.equals(Name, type.Name) &&
|
MiscUtil.equals(Name, type.Name) &&
|
||||||
ZLMiscUtil.mapsEquals(myParameters, type.myParameters);
|
MiscUtil.mapsEquals(myParameters, type.myParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean weakEquals(MimeType type) {
|
public boolean weakEquals(MimeType type) {
|
||||||
return ZLMiscUtil.equals(Name, type.Name);
|
return MiscUtil.equals(Name, type.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return ZLMiscUtil.hashCode(Name);
|
return MiscUtil.hashCode(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.geometerplus.zlibrary.core.util;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class ZLMiscUtil {
|
public abstract class MiscUtil {
|
||||||
public static <T> boolean equals(T o0, T o1) {
|
public static <T> boolean equals(T o0, T o1) {
|
||||||
return o0 == null ? o1 == null : o0.equals(o1);
|
return o0 == null ? o1 == null : o0.equals(o1);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public abstract class ZLMiscUtil {
|
||||||
(text.toLowerCase().indexOf(lowerCasePattern) >= 0);
|
(text.toLowerCase().indexOf(lowerCasePattern) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String listToString(List<String> list, String delimiter) {
|
public static String join(List<String> list, String delimiter) {
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public abstract class ZLMiscUtil {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> stringToList(String str, String delimiter) {
|
public static List<String> split(String str, String delimiter) {
|
||||||
if (str == null || "".equals(str)) {
|
if (str == null || "".equals(str)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue