Minor improvements in the short descr. generation
This commit is contained in:
parent
d95a64295a
commit
4d76e043c7
1 changed files with 10 additions and 12 deletions
|
@ -47,6 +47,8 @@ public class WikiArticleHelper {
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
|
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
private static final String P_OPENED = "<p>";
|
||||||
|
private static final String P_CLOSED = "</p>";
|
||||||
|
|
||||||
public WikiArticleHelper(MapActivity mapActivity, boolean nightMode) {
|
public WikiArticleHelper(MapActivity mapActivity, boolean nightMode) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
|
@ -241,23 +243,19 @@ public class WikiArticleHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pOpened = "<p>";
|
int firstParagraphStart = content.indexOf(P_OPENED);
|
||||||
String pClosed = "</p>";
|
int firstParagraphEnd = content.indexOf(P_CLOSED);
|
||||||
|
|
||||||
int firstParagraphStart = content.indexOf(pOpened);
|
|
||||||
int firstParagraphEnd = content.indexOf(pClosed);
|
|
||||||
if (firstParagraphStart == -1 || firstParagraphEnd == -1
|
if (firstParagraphStart == -1 || firstParagraphEnd == -1
|
||||||
|| firstParagraphEnd < firstParagraphStart) {
|
|| firstParagraphEnd < firstParagraphStart) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int pClosedLength = pClosed.length();
|
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length());
|
||||||
String firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + pClosedLength);
|
while (firstParagraphHtml.length() == (P_OPENED.length() + P_CLOSED.length())
|
||||||
while (firstParagraphHtml.length() == (pOpened.length() + pClosedLength)
|
&& (firstParagraphEnd + P_CLOSED.length()) < content.length()) {
|
||||||
&& (firstParagraphEnd + pClosedLength) < content.length()) {
|
firstParagraphStart = content.indexOf(P_OPENED, firstParagraphEnd);
|
||||||
firstParagraphStart = content.indexOf(pOpened, firstParagraphEnd);
|
firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(P_CLOSED, firstParagraphStart);
|
||||||
firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(pClosed, firstParagraphStart);
|
|
||||||
if (firstParagraphStart != -1 && firstParagraphEnd != -1) {
|
if (firstParagraphStart != -1 && firstParagraphEnd != -1) {
|
||||||
firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + pClosedLength);
|
firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length());
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue