mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
BigDecimal for series index
This commit is contained in:
parent
ad37400b9b
commit
1b31f8f7e4
16 changed files with 96 additions and 51 deletions
|
@ -18,7 +18,7 @@ litres: author photos
|
||||||
* rtf: underline & strikethrough
|
* rtf: underline & strikethrough
|
||||||
* fb2 plugins: compare native & java
|
* fb2 plugins: compare native & java
|
||||||
* java fb2 plugin: use Base64InputStream technique
|
* java fb2 plugin: use Base64InputStream technique
|
||||||
* language codes in ZLTextHyphenator and ZLLanguageUtil
|
* language codes in ZLTextHyphenator and ZLLanguageUtil (java & cpp)
|
||||||
* resources synchronization
|
* resources synchronization
|
||||||
* in library: search more on network
|
* in library: search more on network
|
||||||
* ePubs in zips
|
* ePubs in zips
|
||||||
|
|
|
@ -58,7 +58,11 @@ static void fillMetaInfo(JNIEnv* env, jobject javaBook, Book &book) {
|
||||||
|
|
||||||
javaString = AndroidUtil::createJavaString(env, book.seriesTitle());
|
javaString = AndroidUtil::createJavaString(env, book.seriesTitle());
|
||||||
if (javaString != 0) {
|
if (javaString != 0) {
|
||||||
AndroidUtil::Method_Book_setSeriesInfo->call(javaBook, javaString, (jfloat)book.indexInSeries());
|
jstring indexString = AndroidUtil::createJavaString(env, book.indexInSeries());
|
||||||
|
AndroidUtil::Method_Book_setSeriesInfo->call(javaBook, javaString, indexString);
|
||||||
|
if (indexString != 0) {
|
||||||
|
env->DeleteLocalRef(indexString);
|
||||||
|
}
|
||||||
env->DeleteLocalRef(javaString);
|
env->DeleteLocalRef(javaString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@ void FB2MetaInfoReader::startElementHandler(int tag, const char **attributes) {
|
||||||
std::string seriesTitle = name;
|
std::string seriesTitle = name;
|
||||||
ZLStringUtil::stripWhiteSpaces(seriesTitle);
|
ZLStringUtil::stripWhiteSpaces(seriesTitle);
|
||||||
const char *number = attributeValue(attributes, "number");
|
const char *number = attributeValue(attributes, "number");
|
||||||
myBook.setSeries(seriesTitle, number != 0 ? atoi(number) : 0);
|
myBook.setSeries(seriesTitle, number != 0 ? std::string(number) : std::string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
const std::string Book::AutoEncoding = "auto";
|
const std::string Book::AutoEncoding = "auto";
|
||||||
|
|
||||||
Book::Book(const ZLFile &file, int id) : myBookId(id), myFile(file), myIndexInSeries(0) {
|
Book::Book(const ZLFile &file, int id) : myBookId(id), myFile(file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Book::~Book() {
|
Book::~Book() {
|
||||||
|
@ -273,7 +273,7 @@ void Book::setEncoding(const std::string &encoding) {
|
||||||
myEncoding = encoding;
|
myEncoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Book::setSeries(const std::string &title, int index) {
|
void Book::setSeries(const std::string &title, const std::string &index) {
|
||||||
mySeriesTitle = title;
|
mySeriesTitle = title;
|
||||||
myIndexInSeries = index;
|
myIndexInSeries = index;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public: // unmodifiable book methods
|
||||||
const std::string &language() const;
|
const std::string &language() const;
|
||||||
const std::string &encoding() const;
|
const std::string &encoding() const;
|
||||||
const std::string &seriesTitle() const;
|
const std::string &seriesTitle() const;
|
||||||
int indexInSeries() const;
|
const std::string &indexInSeries() const;
|
||||||
|
|
||||||
const TagList &tags() const;
|
const TagList &tags() const;
|
||||||
const AuthorList &authors() const;
|
const AuthorList &authors() const;
|
||||||
|
@ -75,7 +75,7 @@ public: // modifiable book methods
|
||||||
void setTitle(const std::string &title);
|
void setTitle(const std::string &title);
|
||||||
void setLanguage(const std::string &language);
|
void setLanguage(const std::string &language);
|
||||||
void setEncoding(const std::string &encoding);
|
void setEncoding(const std::string &encoding);
|
||||||
void setSeries(const std::string &title, int index);
|
void setSeries(const std::string &title, const std::string &index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool addTag(shared_ptr<Tag> tag);
|
bool addTag(shared_ptr<Tag> tag);
|
||||||
|
@ -102,7 +102,7 @@ private:
|
||||||
std::string myLanguage;
|
std::string myLanguage;
|
||||||
std::string myEncoding;
|
std::string myEncoding;
|
||||||
std::string mySeriesTitle;
|
std::string mySeriesTitle;
|
||||||
int myIndexInSeries;
|
std::string myIndexInSeries;
|
||||||
TagList myTags;
|
TagList myTags;
|
||||||
AuthorList myAuthors;
|
AuthorList myAuthors;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ inline const ZLFile &Book::file() const { return myFile; }
|
||||||
inline const std::string &Book::language() const { return myLanguage; }
|
inline const std::string &Book::language() const { return myLanguage; }
|
||||||
inline const std::string &Book::encoding() const { return myEncoding; }
|
inline const std::string &Book::encoding() const { return myEncoding; }
|
||||||
inline const std::string &Book::seriesTitle() const { return mySeriesTitle; }
|
inline const std::string &Book::seriesTitle() const { return mySeriesTitle; }
|
||||||
inline int Book::indexInSeries() const { return myIndexInSeries; }
|
inline const std::string &Book::indexInSeries() const { return myIndexInSeries; }
|
||||||
|
|
||||||
inline const TagList &Book::tags() const { return myTags; }
|
inline const TagList &Book::tags() const { return myTags; }
|
||||||
inline const AuthorList &Book::authors() const { return myAuthors; }
|
inline const AuthorList &Book::authors() const { return myAuthors; }
|
||||||
|
|
|
@ -30,7 +30,7 @@ bool BookComparator::operator() (
|
||||||
int comp = seriesTitle0.compare(seriesTitle1);
|
int comp = seriesTitle0.compare(seriesTitle1);
|
||||||
if (comp == 0) {
|
if (comp == 0) {
|
||||||
if (!seriesTitle0.empty()) {
|
if (!seriesTitle0.empty()) {
|
||||||
comp = book0->indexInSeries() - book1->indexInSeries();
|
comp = book0->indexInSeries().compare(book1->indexInSeries());
|
||||||
if (comp != 0) {
|
if (comp != 0) {
|
||||||
return comp < 0;
|
return comp < 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ bool AndroidUtil::init(JavaVM* jvm) {
|
||||||
Method_Book_getLanguage = new StringMethod(Class_Book, "getLanguage", "()");
|
Method_Book_getLanguage = new StringMethod(Class_Book, "getLanguage", "()");
|
||||||
Method_Book_getEncodingNoDetection = new StringMethod(Class_Book, "getEncodingNoDetection", "()");
|
Method_Book_getEncodingNoDetection = new StringMethod(Class_Book, "getEncodingNoDetection", "()");
|
||||||
Method_Book_setTitle = new VoidMethod(Class_Book, "setTitle", "(Ljava/lang/String;)");
|
Method_Book_setTitle = new VoidMethod(Class_Book, "setTitle", "(Ljava/lang/String;)");
|
||||||
Method_Book_setSeriesInfo = new VoidMethod(Class_Book, "setSeriesInfo", "(Ljava/lang/String;F)");
|
Method_Book_setSeriesInfo = new VoidMethod(Class_Book, "setSeriesInfo", "(Ljava/lang/String;Ljava/lang/String;)");
|
||||||
Method_Book_setLanguage = new VoidMethod(Class_Book, "setLanguage", "(Ljava/lang/String;)");
|
Method_Book_setLanguage = new VoidMethod(Class_Book, "setLanguage", "(Ljava/lang/String;)");
|
||||||
Method_Book_setEncoding = new VoidMethod(Class_Book, "setEncoding", "(Ljava/lang/String;)");
|
Method_Book_setEncoding = new VoidMethod(Class_Book, "setEncoding", "(Ljava/lang/String;)");
|
||||||
Method_Book_addAuthor = new VoidMethod(Class_Book, "addAuthor", "(Ljava/lang/String;Ljava/lang/String;)");
|
Method_Book_addAuthor = new VoidMethod(Class_Book, "addAuthor", "(Ljava/lang/String;Ljava/lang/String;)");
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
public ** getLanguage();
|
public ** getLanguage();
|
||||||
public ** getEncodingNoDetection();
|
public ** getEncodingNoDetection();
|
||||||
public void setTitle(**);
|
public void setTitle(**);
|
||||||
public void setSeriesInfo(**,float);
|
public void setSeriesInfo(**,**);
|
||||||
public void setLanguage(**);
|
public void setLanguage(**);
|
||||||
public void setEncoding(**);
|
public void setEncoding(**);
|
||||||
public void addAuthor(**,**);
|
public void addAuthor(**,**);
|
||||||
|
|
|
@ -235,12 +235,8 @@ public class BookInfoActivity extends Activity {
|
||||||
final SeriesInfo series = book.getSeriesInfo();
|
final SeriesInfo series = book.getSeriesInfo();
|
||||||
setupInfoPair(R.id.book_series, "series", series == null ? null : series.Name);
|
setupInfoPair(R.id.book_series, "series", series == null ? null : series.Name);
|
||||||
String seriesIndexString = null;
|
String seriesIndexString = null;
|
||||||
if (series != null && series.Index > 0) {
|
if (series != null && series.Index != null) {
|
||||||
if (Math.abs(series.Index - Math.round(series.Index)) < 0.01) {
|
seriesIndexString = series.Index.toString();
|
||||||
seriesIndexString = String.valueOf(Math.round(series.Index));
|
|
||||||
} else {
|
|
||||||
seriesIndexString = String.format("%.1f", series.Index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setupInfoPair(R.id.book_series_index, "indexInSeries", seriesIndexString);
|
setupInfoPair(R.id.book_series_index, "indexInSeries", seriesIndexString);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.geometerplus.android.fbreader.library;
|
package org.geometerplus.android.fbreader.library;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
@ -70,7 +71,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
|
|
||||||
private void migrate(Context context) {
|
private void migrate(Context context) {
|
||||||
final int version = myDatabase.getVersion();
|
final int version = myDatabase.getVersion();
|
||||||
final int currentVersion = 18;
|
final int currentVersion = 19;
|
||||||
if (version >= currentVersion) {
|
if (version >= currentVersion) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +116,8 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
updateTables16();
|
updateTables16();
|
||||||
case 17:
|
case 17:
|
||||||
updateTables17();
|
updateTables17();
|
||||||
|
case 18:
|
||||||
|
updateTables18();
|
||||||
}
|
}
|
||||||
myDatabase.setTransactionSuccessful();
|
myDatabase.setTransactionSuccessful();
|
||||||
myDatabase.endTransaction();
|
myDatabase.endTransaction();
|
||||||
|
@ -255,9 +258,9 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
Book book = booksById.get(cursor.getLong(0));
|
Book book = booksById.get(cursor.getLong(0));
|
||||||
if (book != null) {
|
if (book != null) {
|
||||||
String series = seriesById.get(cursor.getLong(1));
|
final String series = seriesById.get(cursor.getLong(1));
|
||||||
if (series != null) {
|
if (series != null) {
|
||||||
setSeriesInfo(book, series, cursor.getFloat(2));
|
setSeriesInfo(book, series, cursor.getString(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +503,10 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
}
|
}
|
||||||
myInsertBookSeriesStatement.bindLong(1, bookId);
|
myInsertBookSeriesStatement.bindLong(1, bookId);
|
||||||
myInsertBookSeriesStatement.bindLong(2, seriesId);
|
myInsertBookSeriesStatement.bindLong(2, seriesId);
|
||||||
myInsertBookSeriesStatement.bindDouble(3, seriesInfo.Index);
|
SQLiteUtil.bindString(
|
||||||
|
myInsertBookSeriesStatement, 3,
|
||||||
|
seriesInfo.Index != null ? seriesInfo.Index.toString() : null
|
||||||
|
);
|
||||||
myInsertBookSeriesStatement.execute();
|
myInsertBookSeriesStatement.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +515,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
final Cursor cursor = myDatabase.rawQuery("SELECT Series.name,BookSeries.book_index FROM BookSeries INNER JOIN Series ON Series.series_id = BookSeries.series_id WHERE BookSeries.book_id = ?", new String[] { "" + bookId });
|
final Cursor cursor = myDatabase.rawQuery("SELECT Series.name,BookSeries.book_index FROM BookSeries INNER JOIN Series ON Series.series_id = BookSeries.series_id WHERE BookSeries.book_id = ?", new String[] { "" + bookId });
|
||||||
SeriesInfo info = null;
|
SeriesInfo info = null;
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
info = new SeriesInfo(cursor.getString(0), cursor.getFloat(1));
|
info = new SeriesInfo(cursor.getString(0), SeriesInfo.createIndex(cursor.getString(1)));
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
return info;
|
return info;
|
||||||
|
@ -1236,4 +1242,37 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
||||||
"pages_full INTEGER NOT NULL," +
|
"pages_full INTEGER NOT NULL," +
|
||||||
"page_current INTEGER NOT NULL)");
|
"page_current INTEGER NOT NULL)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTables18() {
|
||||||
|
myDatabase.execSQL("ALTER TABLE BookSeries RENAME TO BookSeries_Obsolete");
|
||||||
|
myDatabase.execSQL(
|
||||||
|
"CREATE TABLE BookSeries(" +
|
||||||
|
"series_id INTEGER NOT NULL REFERENCES Series(series_id)," +
|
||||||
|
"book_id INTEGER NOT NULL UNIQUE REFERENCES Books(book_id)," +
|
||||||
|
"book_index TEXT)");
|
||||||
|
final SQLiteStatement insert = myDatabase.compileStatement(
|
||||||
|
"INSERT INTO BookSeries (series_id,book_id,book_index) VALUES (?,?,?)"
|
||||||
|
);
|
||||||
|
final Cursor cursor = myDatabase.rawQuery("SELECT series_id,book_id,book_index FROM BookSeries_Obsolete", null);
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
insert.bindLong(1, cursor.getLong(0));
|
||||||
|
insert.bindLong(2, cursor.getLong(1));
|
||||||
|
final float index = cursor.getFloat(2);
|
||||||
|
final String stringIndex;
|
||||||
|
if (index == 0.0f) {
|
||||||
|
stringIndex = null;
|
||||||
|
} else {
|
||||||
|
if (Math.abs(index - Math.round(index)) < 0.01) {
|
||||||
|
stringIndex = String.valueOf(Math.round(index));
|
||||||
|
} else {
|
||||||
|
stringIndex = String.format("%.1f", index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final BigDecimal bdIndex = SeriesInfo.createIndex(stringIndex);
|
||||||
|
SQLiteUtil.bindString(insert, 3, bdIndex != null ? bdIndex.toString() : null);
|
||||||
|
insert.executeInsert();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
myDatabase.execSQL("DROP TABLE BookSeries_Obsolete");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,15 +117,7 @@ public class FB2MetaInfoReader extends ZLXMLReaderAdapter {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
name.trim();
|
name.trim();
|
||||||
if (name.length() != 0) {
|
if (name.length() != 0) {
|
||||||
int index = 0;
|
myBook.setSeriesInfo(name, attributes.getValue("number"));
|
||||||
try {
|
|
||||||
final String sIndex = attributes.getValue("number");
|
|
||||||
if (sIndex != null) {
|
|
||||||
index = Integer.parseInt(sIndex);
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
myBook.setSeriesInfo(name, index);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
||||||
private final Book myBook;
|
private final Book myBook;
|
||||||
|
|
||||||
private String mySeriesTitle = "";
|
private String mySeriesTitle = "";
|
||||||
private float mySeriesIndex = 0;
|
private String mySeriesIndex = null;
|
||||||
|
|
||||||
private final ArrayList<String> myAuthorList = new ArrayList<String>();
|
private final ArrayList<String> myAuthorList = new ArrayList<String>();
|
||||||
private final ArrayList<String> myAuthorList2 = new ArrayList<String>();
|
private final ArrayList<String> myAuthorList2 = new ArrayList<String>();
|
||||||
|
@ -47,7 +47,7 @@ class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
||||||
void readMetaInfo(ZLFile file) throws BookReadingException {
|
void readMetaInfo(ZLFile file) throws BookReadingException {
|
||||||
myReadState = ReadState.Nothing;
|
myReadState = ReadState.Nothing;
|
||||||
mySeriesTitle = "";
|
mySeriesTitle = "";
|
||||||
mySeriesIndex = 0;
|
mySeriesIndex = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ZLXMLProcessor.read(this, file, 512);
|
ZLXMLProcessor.read(this, file, 512);
|
||||||
|
@ -122,11 +122,7 @@ class OEBMetaInfoReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
||||||
if (attributes.getValue("name").equals("calibre:series")) {
|
if (attributes.getValue("name").equals("calibre:series")) {
|
||||||
mySeriesTitle = attributes.getValue("content");
|
mySeriesTitle = attributes.getValue("content");
|
||||||
} else if (attributes.getValue("name").equals("calibre:series_index")) {
|
} else if (attributes.getValue("name").equals("calibre:series_index")) {
|
||||||
final String strIndex = attributes.getValue("content");
|
mySeriesIndex = attributes.getValue("content");
|
||||||
try {
|
|
||||||
mySeriesIndex = Float.parseFloat(strIndex);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -276,11 +277,15 @@ public class Book {
|
||||||
return mySeriesInfo;
|
return mySeriesInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSeriesInfoWithNoCheck(String name, float index) {
|
void setSeriesInfoWithNoCheck(String name, BigDecimal index) {
|
||||||
mySeriesInfo = new SeriesInfo(name, index);
|
mySeriesInfo = new SeriesInfo(name, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSeriesInfo(String name, float index) {
|
public void setSeriesInfo(String name, String index) {
|
||||||
|
setSeriesInfo(name, SeriesInfo.createIndex(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeriesInfo(String name, BigDecimal index) {
|
||||||
if (mySeriesInfo == null) {
|
if (mySeriesInfo == null) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
mySeriesInfo = new SeriesInfo(name, index);
|
mySeriesInfo = new SeriesInfo(name, index);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.tree.FBTree;
|
import org.geometerplus.fbreader.tree.FBTree;
|
||||||
|
|
||||||
public final class BookInSeriesTree extends BookTree {
|
public final class BookInSeriesTree extends BookTree {
|
||||||
|
@ -33,11 +35,12 @@ public final class BookInSeriesTree extends BookTree {
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(FBTree tree) {
|
public int compareTo(FBTree tree) {
|
||||||
if (tree instanceof BookInSeriesTree) {
|
if (tree instanceof BookInSeriesTree) {
|
||||||
final float difference =
|
final BigDecimal index0 = Book.getSeriesInfo().Index;
|
||||||
Book.getSeriesInfo().Index - ((BookTree)tree).Book.getSeriesInfo().Index;
|
final BigDecimal index1 = ((BookTree)tree).Book.getSeriesInfo().Index;
|
||||||
if (difference != 0) {
|
if (index0 == null) {
|
||||||
return difference > 0 ? 1 : -1;
|
return index1 == null ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
return index1 == null ? -1 : index0.compareTo(index1);
|
||||||
}
|
}
|
||||||
return super.compareTo(tree);
|
return super.compareTo(tree);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ public abstract class BooksDatabase {
|
||||||
protected void addTag(Book book, Tag tag) {
|
protected void addTag(Book book, Tag tag) {
|
||||||
book.addTagWithNoCheck(tag);
|
book.addTagWithNoCheck(tag);
|
||||||
}
|
}
|
||||||
protected void setSeriesInfo(Book book, String series, float index) {
|
protected void setSeriesInfo(Book book, String series, String index) {
|
||||||
book.setSeriesInfoWithNoCheck(series, index);
|
book.setSeriesInfoWithNoCheck(series, SeriesInfo.createIndex(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void executeAsATransaction(Runnable actions);
|
protected abstract void executeAsATransaction(Runnable actions);
|
||||||
|
|
|
@ -19,11 +19,21 @@
|
||||||
|
|
||||||
package org.geometerplus.fbreader.library;
|
package org.geometerplus.fbreader.library;
|
||||||
|
|
||||||
public final class SeriesInfo {
|
import java.math.BigDecimal;
|
||||||
public final String Name;
|
|
||||||
public final float Index;
|
|
||||||
|
|
||||||
public SeriesInfo(String name, float index) {
|
public final class SeriesInfo {
|
||||||
|
public static BigDecimal createIndex(String index) {
|
||||||
|
try {
|
||||||
|
return index != null ? new BigDecimal(index).stripTrailingZeros() : null;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String Name;
|
||||||
|
public final BigDecimal Index;
|
||||||
|
|
||||||
|
public SeriesInfo(String name, BigDecimal index) {
|
||||||
Name = name;
|
Name = name;
|
||||||
Index = index;
|
Index = index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue