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

code cleanup (fit coding standards + small fixes)

This commit is contained in:
Nikolay Pultsin 2015-06-24 13:58:48 +01:00
parent 927037a3e8
commit b0ef1d911e
5 changed files with 13 additions and 18 deletions

View file

@ -22,7 +22,7 @@ public interface Api {
// book information for current book
String getBookLanguage() throws ApiException;
String getBookTitle() throws ApiException;
//List<String> getBookAuthors() throws ApiException;
List<String> getBookAuthors() throws ApiException;
List<String> getBookTags() throws ApiException;
String getBookFilePath() throws ApiException;
String getBookHash() throws ApiException;
@ -38,6 +38,7 @@ public interface Api {
String getBookHash(long id) throws ApiException;
String getBookUniqueId(long id) throws ApiException;
Date getBookLastTurningTime(long id) throws ApiException;
float getBookProgress() throws ApiException;
//long findBookIdByUniqueId(String uniqueId) throws ApiException;
//long findBookIdByFilePath(String uniqueId) throws ApiException;

View file

@ -147,12 +147,12 @@ public class ApiClientImplementation implements ServiceConnection, Api, ApiMetho
}
return ((ApiObject.Integer)object).Value;
}
private float requestFloat(int method, ApiObject[] params) throws ApiException {
final ApiObject object = request(method, params);
if (!(object instanceof ApiObject.Float)) {
throw new ApiException("Cannot cast return type of method " + method + " to float");
}
}
return ((ApiObject.Float)object).Value;
}

View file

@ -219,6 +219,7 @@ public abstract class ApiObject implements Parcelable {
static ApiObject envelope(float value) {
return new Float(value);
}
static ApiObject envelope(boolean value) {
return new Boolean(value);
}

View file

@ -352,24 +352,21 @@ public class ApiServerImplementation extends ApiInterface.Stub implements Api, A
if (book == null) {
return -1.0f;
}
RationalNumber progress=book.getProgress();
return progress.toFloat();
final RationalNumber progress = book.getProgress();
return progress != null ? progress.toFloat() : -1.0f;
}
public List<String> getBookAuthors() {
final Book book=getReader().getCurrentBook();
final Book book = getReader().getCurrentBook();
if (book == null) {
return null;
}
List<Author> authors=book.getAuthors();
if (authors == null) {
return Collections.emptyList();
final List<Author> authors = book.authors();
final List<String> authorNames = new ArrayList<String>(authors.size());
for (Author a : authors) {
authorNames.add(a.DisplayName);
}
List<String> result=new LinkedList<String>();
for (Author author:authors) {
result.add(author.DisplayName);
}
return result;
return authorNames;
}
public String getBookFilePath() {

View file

@ -60,10 +60,6 @@ public abstract class AbstractBook extends TitledEntity<AbstractBook> {
public abstract String getPath();
public List<Author> getAuthors() {
return myAuthors!=null ? myAuthors: null;
}
public void updateFrom(AbstractBook book) {
if (book == null || myId != book.myId) {
return;