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

Merge branch 'master' into epub-native

Conflicts:
	TODO.1.4.6
This commit is contained in:
Nikolay Pultsin 2012-04-15 02:33:44 +01:00
commit 7f72a53c48
21 changed files with 126 additions and 230 deletions

View file

@ -162,13 +162,17 @@ public class BookInfoActivity extends Activity {
}
private void setupInfoPair(int id, String key, CharSequence value) {
setupInfoPair(id, key, value, 0);
}
private void setupInfoPair(int id, String key, CharSequence value, int param) {
final LinearLayout layout = (LinearLayout)findViewById(id);
if (value == null || value.length() == 0) {
layout.setVisibility(View.GONE);
return;
}
layout.setVisibility(View.VISIBLE);
((TextView)layout.findViewById(R.id.book_info_key)).setText(myResource.getResource(key).getValue());
((TextView)layout.findViewById(R.id.book_info_key)).setText(myResource.getResource(key).getValue(param));
((TextView)layout.findViewById(R.id.book_info_value)).setText(value);
}
@ -219,13 +223,14 @@ public class BookInfoActivity extends Activity {
setupInfoPair(R.id.book_title, "title", book.getTitle());
final StringBuilder buffer = new StringBuilder();
for (Author author: book.authors()) {
final List<Author> authors = book.authors();
for (Author a : authors) {
if (buffer.length() > 0) {
buffer.append(", ");
}
buffer.append(author.DisplayName);
buffer.append(a.DisplayName);
}
setupInfoPair(R.id.book_authors, "authors", buffer);
setupInfoPair(R.id.book_authors, "authors", buffer, authors.size());
final SeriesInfo series = book.getSeriesInfo();
setupInfoPair(R.id.book_series, "series", series == null ? null : series.Name);
@ -250,7 +255,7 @@ public class BookInfoActivity extends Activity {
tagNames.add(tag.Name);
}
}
setupInfoPair(R.id.book_tags, "tags", buffer);
setupInfoPair(R.id.book_tags, "tags", buffer, tagNames.size());
String language = book.getLanguage();
if (!ZLLanguageUtil.languageCodes().contains(language)) {
language = ZLLanguageUtil.OTHER_LANGUAGE_CODE;

View file

@ -59,7 +59,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
private NetworkBookItem myBook;
private View myMainView;
private final ZLResource myResource = ZLResource.resource("networkBookView");
private final ZLResource myResource = ZLResource.resource("bookInfo");
private BookDownloaderServiceConnection myConnection;
@Override
@ -225,11 +225,15 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
}
private void setPairLabelTextFromResource(int id, String resourceKey) {
final LinearLayout layout = (LinearLayout)findViewById(id);
((TextView)layout.findViewById(R.id.book_info_key))
((TextView)findViewById(id).findViewById(R.id.book_info_key))
.setText(myResource.getResource(resourceKey).getValue());
}
private void setPairLabelTextFromResource(int id, String resourceKey, int param) {
((TextView)findViewById(id).findViewById(R.id.book_info_key))
.setText(myResource.getResource(resourceKey).getValue(param));
}
private void setPairValueText(int id, CharSequence text) {
final LinearLayout layout = (LinearLayout)findViewById(id);
((TextView)layout.findViewById(R.id.book_info_value)).setText(text);
@ -242,7 +246,6 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
setPairLabelTextFromResource(R.id.network_book_authors, "authors");
setPairLabelTextFromResource(R.id.network_book_series_title, "series");
setPairLabelTextFromResource(R.id.network_book_series_index, "indexInSeries");
setPairLabelTextFromResource(R.id.network_book_tags, "tags");
setPairLabelTextFromResource(R.id.network_book_catalog, "catalog");
setPairValueText(R.id.network_book_title, myBook.Title);
@ -256,6 +259,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
}
authorsText.append(author.DisplayName);
}
setPairLabelTextFromResource(R.id.network_book_authors, "authors", myBook.Authors.size());
setPairValueText(R.id.network_book_authors, authorsText);
} else {
findViewById(R.id.network_book_authors).setVisibility(View.GONE);
@ -291,6 +295,7 @@ public class NetworkBookInfoActivity extends Activity implements NetworkLibrary.
}
tagsText.append(tag);
}
setPairLabelTextFromResource(R.id.network_book_tags, "tags", myBook.Tags.size());
setPairValueText(R.id.network_book_tags, tagsText);
} else {
findViewById(R.id.network_book_tags).setVisibility(View.GONE);

View file

@ -58,6 +58,24 @@ final class ZLTreeResource extends ZLResource {
}
}
private static class ModRangeCondition implements Condition {
private final int myMin;
private final int myMax;
private final int myBase;
ModRangeCondition(int min, int max, int base) {
myMin = min;
myMax = max;
myBase = base;
}
@Override
public boolean accepts(int number) {
number = number % myBase;
return myMin <= number && number <= myMax;
}
}
private static class ModCondition implements Condition {
private final int myMod;
private final int myBase;
@ -80,6 +98,8 @@ final class ZLTreeResource extends ZLResource {
return new RangeCondition(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
} else if ("mod".equals(parts[0])) {
return new ModCondition(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
} else if ("modrange".equals(parts[0])) {
return new ModRangeCondition(Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3]));
} else if ("value".equals(parts[0])) {
return new ValueCondition(Integer.parseInt(parts[1]));
}