1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package com.camilstaps.taize;
import android.content.Context;
import com.android.volley.Response;
import com.android.volley.VolleyError;
/**
* Class for holding some text in the Bible
*
* @author Camil Staps
*/
public class BibleText {
private String book;
private int start_chap, end_chap, start_verse, end_verse;
/**
* Constructor for a bible text consisting of a single verse
* @param book
* @param chapter
* @param verse
*/
public BibleText(String book, int chapter, int verse) {
this.book = book;
start_chap = end_chap = chapter;
start_verse = end_verse = verse;
}
/**
* Constructor for a bible text consisting of a "verse range"
* @param book
* @param start_chap
* @param start_verse
* @param end_chap
* @param end_verse
*/
public BibleText(String book, int start_chap, int start_verse, int end_chap, int end_verse) {
this.book = book;
this.start_chap = start_chap;
this.end_chap = end_chap;
this.start_verse = start_verse;
this.end_verse = end_verse;
}
/**
* Get the text (without verse numbers, line breaks, etc.) of this passage
* @param context
* @param listener
* @param errorListener
*/
public void getText(Context context, Response.Listener<String> listener, Response.ErrorListener errorListener) {
String passage = "";
if (start_chap == end_chap) {
if (start_verse == end_verse) {
passage = book + " " + start_chap + ":" + start_verse;
} else {
passage = book + " " + start_chap + ":" + start_verse + "-" + end_verse;
}
} else {
StringBuilder passageBuilder = new StringBuilder();
passageBuilder.append(book + " " + start_chap + ":" + start_verse);
for (int i = start_chap + 1; i <= end_chap; i++)
passageBuilder.append(";" + i);
passageBuilder.append("-" + end_verse);
passage = passageBuilder.toString();
}
Bible.getPassage(context, passage, listener, errorListener);
}
}
|