code cleanup
[fanfix.git] / src / be / nikiroo / fanfix / reader / android / AndroidReader.java
1 package be.nikiroo.fanfix.reader.android;
2
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.net.Uri;
6
7 import java.io.File;
8 import java.io.IOException;
9
10 import be.nikiroo.fanfix.reader.BasicReader;
11
12 public class AndroidReader extends BasicReader {
13 private Activity app;
14
15 /**
16 * Do not use.
17 */
18 private AndroidReader() {
19 // Required for reflection
20 }
21
22 public AndroidReader(Activity app) {
23 this.app = app;
24 }
25
26 @Override
27 public void read(boolean sync) throws IOException {
28 }
29
30 @Override
31 public void browse(String source) {
32 }
33
34 @Override
35 protected void start(File target, String program, boolean sync) throws IOException {
36 if (program == null) {
37 try {
38 Intent[] intents = new Intent[] { //
39 new Intent(Intent.ACTION_VIEW), //
40 new Intent(Intent.ACTION_OPEN_DOCUMENT) //
41 };
42
43 for (Intent intent : intents) {
44 intent.setDataAndType(Uri.parse(target.toURI().toString()),
45 "application/x-cbz");
46 }
47
48 Intent chooserIntent = Intent.createChooser(intents[0],
49 "Open CBZ in...");
50
51 // chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
52 // intents);
53
54 app.startActivity(chooserIntent);
55 } catch (UnsupportedOperationException e) {
56 super.start(target, program, sync);
57 }
58 } else {
59 super.start(target, program, sync);
60 }
61 }
62 }