1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package net.sourceforge.subsonic.androidapp.service.parser; |
20 |
|
|
21 |
|
import android.content.Context; |
22 |
|
import net.sourceforge.subsonic.androidapp.R; |
23 |
|
import net.sourceforge.subsonic.androidapp.domain.MusicDirectory; |
24 |
|
import net.sourceforge.subsonic.androidapp.domain.SearchResult; |
25 |
|
import net.sourceforge.subsonic.androidapp.domain.Artist; |
26 |
|
import net.sourceforge.subsonic.androidapp.util.ProgressListener; |
27 |
|
import org.xmlpull.v1.XmlPullParser; |
28 |
|
|
29 |
|
import java.io.Reader; |
30 |
|
import java.util.Collections; |
31 |
|
import java.util.List; |
32 |
|
import java.util.ArrayList; |
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 6 |
Complexity Density: 0,38 |
|
37 |
|
public class SearchResultParser extends MusicDirectoryEntryParser { |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
0
|
public SearchResultParser(Context context) {... |
40 |
0
|
super(context); |
41 |
|
} |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0,33 |
|
43 |
0
|
public SearchResult parse(Reader reader, ProgressListener progressListener) throws Exception {... |
44 |
0
|
updateProgress(progressListener, R.string.parser_reading); |
45 |
0
|
init(reader); |
46 |
|
|
47 |
0
|
List<MusicDirectory.Entry> songs = new ArrayList<MusicDirectory.Entry>(); |
48 |
0
|
int eventType; |
49 |
0
|
do { |
50 |
0
|
eventType = nextParseEvent(); |
51 |
0
|
if (eventType == XmlPullParser.START_TAG) { |
52 |
0
|
String name = getElementName(); |
53 |
0
|
if ("match".equals(name)) { |
54 |
0
|
songs.add(parseEntry()); |
55 |
0
|
} else if ("error".equals(name)) { |
56 |
0
|
handleError(); |
57 |
|
} |
58 |
|
} |
59 |
0
|
} while (eventType != XmlPullParser.END_DOCUMENT); |
60 |
|
|
61 |
0
|
validate(); |
62 |
0
|
updateProgress(progressListener, R.string.parser_reading_done); |
63 |
|
|
64 |
0
|
return new SearchResult(Collections.<Artist>emptyList(), Collections.<MusicDirectory.Entry>emptyList(), songs); |
65 |
|
} |
66 |
|
|
67 |
|
} |