Skip to content

Commit

Permalink
Merge branch 'master' of github.com:liudongmiao/bible
Browse files Browse the repository at this point in the history
  • Loading branch information
liudongmiao committed Mar 29, 2014
2 parents 2b06dbd + e57e573 commit 3ef6587
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/me/piebridge/bible/OsisItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public static ArrayList<OsisItem> parseSearch(String s, Context context) {
s = s.replaceAll("-\\d?[A-Za-z]+\\s*", "-");

// John 3; John 3:16; John 3:16-17; John 3-4; John 3-4:5; John 3:16-4:6
Pattern p = Pattern.compile("\\s*(\\d*?\\s*?[^\\d\\s;]+)\\s*(\\d*):?(\\d*)\\s*?-?\\s*?(\\d*):?(\\d*);?");
Pattern p = Pattern.compile("\\s*(\\d*?\\s*?[^\\d\\s:-;]*)\\s*(\\d*):?(\\d*)\\s*?-?\\s*?(\\d*):?(\\d*);?");
Matcher m = p.matcher(s);
String prevbook = "";
String prevchap = "";
String prevosis = "";
while (m.find()) {
String book = m.group(1);
String start_chapter = m.group(2);
Expand All @@ -129,6 +130,8 @@ public static ArrayList<OsisItem> parseSearch(String s, Context context) {
start_verse = start_chapter;
start_chapter = prevchap;
}
} else if ("".equals(book)) {
book = prevbook;
}

prevbook = book;
Expand All @@ -140,10 +143,18 @@ public static ArrayList<OsisItem> parseSearch(String s, Context context) {

String osis;
if (book.equalsIgnoreCase("ch") || book.equalsIgnoreCase("ch.")) {
osis = PreferenceManager.getDefaultSharedPreferences(context).getString("osis", "Gen");
if ("".equals(prevosis)) {
osis = PreferenceManager.getDefaultSharedPreferences(context).getString("osis", "Gen");
} else {
osis = prevosis;
}
osis = osis.split("\\.")[0];
} else if (book.equalsIgnoreCase("vv") || book.equalsIgnoreCase("vv.") || book.equalsIgnoreCase("v") || book.equalsIgnoreCase("v.")) {
osis = PreferenceManager.getDefaultSharedPreferences(context).getString("osis", "Gen.1");
if ("".equals(prevosis) || "".equals(prevchap)) {
osis = PreferenceManager.getDefaultSharedPreferences(context).getString("osis", "Gen.1");
} else {
osis = prevosis + "." + prevchap;
}
if (osis.contains(".")) {
start_verse = start_chapter;
end_verse = end_chapter;
Expand All @@ -156,11 +167,12 @@ public static ArrayList<OsisItem> parseSearch(String s, Context context) {
} else {
osis = Bible.getBible(context).getOsis(book);
}
Log.d("OsisItem", String.format("book:%s, osis:%s, %s:%s-%s%s", book, osis, start_chapter, start_verse, end_chapter, end_verse));
Log.d("OsisItem", String.format("book:%s, osis:%s, %s:%s-%s:%s", book, osis, start_chapter, start_verse, end_chapter, end_verse));
if (osis == null) {
continue;
}

prevosis = osis;
if (end_chapter.equals(start_chapter)) {
end_chapter = end_verse;
end_verse = "";
Expand Down

0 comments on commit 3ef6587

Please sign in to comment.