diff options
author | ligi <ligi@ligi.de> | 2013-01-23 14:44:28 +0100 |
---|---|---|
committer | ligi <ligi@ligi.de> | 2013-01-23 14:44:28 +0100 |
commit | 60546a7bd74357726d025123449254cb4fd216b5 (patch) | |
tree | 11914805600f8fc6645dfc33aed2710003efbbec | |
parent | c75640d274ab47dc9d8b96ae15b5a4a273228313 (diff) | |
download | AntennaPod-60546a7bd74357726d025123449254cb4fd216b5.zip |
make room for another way of Opml import
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/AddFeedActivity.java | 2 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java | 4 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java (renamed from src/de/danoeh/antennapod/activity/OpmlImportActivity.java) | 13 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/activity/OpmlImportHolder.java | 29 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java | 5 | ||||
-rw-r--r-- | src/de/danoeh/antennapod/asynctask/OpmlImportWorker.java | 37 |
7 files changed, 59 insertions, 33 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c392ae272..d223e174e 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -162,7 +162,7 @@ android:label="@string/about_pref" > </activity> <activity - android:name=".activity.OpmlImportActivity" + android:name=".activity.OpmlImportFromPathActivity" android:configChanges="keyboardHidden|orientation" android:label="@string/opml_import_label" > </activity> diff --git a/src/de/danoeh/antennapod/activity/AddFeedActivity.java b/src/de/danoeh/antennapod/activity/AddFeedActivity.java index e90387cd3..44486b5ef 100644 --- a/src/de/danoeh/antennapod/activity/AddFeedActivity.java +++ b/src/de/danoeh/antennapod/activity/AddFeedActivity.java @@ -73,7 +73,7 @@ public class AddFeedActivity extends SherlockActivity { @Override public void onClick(View v) { startActivity(new Intent(AddFeedActivity.this, - OpmlImportActivity.class)); + OpmlImportFromPathActivity.class)); } }); diff --git a/src/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java b/src/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java index 582673dbb..2301d2f0f 100644 --- a/src/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java +++ b/src/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java @@ -90,8 +90,8 @@ public class OpmlFeedChooserActivity extends SherlockActivity { private List<String> getTitleList() { List<String> result = new ArrayList<String>(); - if (OpmlImportActivity.getReadElements() != null) { - for (OpmlElement element : OpmlImportActivity.getReadElements()) { + if (OpmlImportHolder.getReadElements() != null) { + for (OpmlElement element : OpmlImportHolder.getReadElements()) { result.add(element.getText()); } diff --git a/src/de/danoeh/antennapod/activity/OpmlImportActivity.java b/src/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java index 5ec2e8538..a02f0e67f 100644 --- a/src/de/danoeh/antennapod/activity/OpmlImportActivity.java +++ b/src/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java @@ -27,7 +27,7 @@ import de.danoeh.antennapod.opml.OpmlElement; import de.danoeh.antennapod.util.StorageUtils; /** Lets the user start the OPML-import process. */ -public class OpmlImportActivity extends SherlockActivity { +public class OpmlImportFromPathActivity extends SherlockActivity { private static final String TAG = "OpmlImportActivity"; public static final String IMPORT_DIR = "import/"; @@ -38,8 +38,6 @@ public class OpmlImportActivity extends SherlockActivity { private OpmlImportWorker importWorker; - private static ArrayList<OpmlElement> readElements; - @Override protected void onCreate(Bundle savedInstanceState) { setTheme(PodcastApp.getThemeResourceId()); @@ -144,9 +142,9 @@ public class OpmlImportActivity extends SherlockActivity { if (result != null) { if (AppConfig.DEBUG) Log.d(TAG, "Parsing was successful"); - readElements = result; + OpmlImportHolder.setReadElements(result); startActivityForResult(new Intent( - OpmlImportActivity.this, + OpmlImportFromPathActivity.this, OpmlFeedChooserActivity.class), 0); } else { if (AppConfig.DEBUG) @@ -211,7 +209,7 @@ public class OpmlImportActivity extends SherlockActivity { @Override protected void onPostExecute(Void result) { super.onPostExecute(result); - Intent intent = new Intent(OpmlImportActivity.this, MainActivity.class); + Intent intent = new Intent(OpmlImportFromPathActivity.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); @@ -226,8 +224,5 @@ public class OpmlImportActivity extends SherlockActivity { } } - public static ArrayList<OpmlElement> getReadElements() { - return readElements; - } } diff --git a/src/de/danoeh/antennapod/activity/OpmlImportHolder.java b/src/de/danoeh/antennapod/activity/OpmlImportHolder.java new file mode 100644 index 000000000..ec53ed7b6 --- /dev/null +++ b/src/de/danoeh/antennapod/activity/OpmlImportHolder.java @@ -0,0 +1,29 @@ +package de.danoeh.antennapod.activity; + +import de.danoeh.antennapod.opml.OpmlElement; + +import java.util.ArrayList; + +/** + * Hold infos gathered by Ompl-Import + * <p/> + * Created with IntelliJ IDEA. + * User: ligi + * Date: 1/23/13 + * Time: 2:15 PM + */ +public class OpmlImportHolder { + + private static ArrayList<OpmlElement> readElements; + + public static ArrayList<OpmlElement> getReadElements() { + return readElements; + } + + public static void setReadElements(ArrayList<OpmlElement> _readElements) { + readElements = _readElements; + } + + +} + diff --git a/src/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java b/src/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java index 08c038206..a3652e05d 100644 --- a/src/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java +++ b/src/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java @@ -7,7 +7,8 @@ import android.app.ProgressDialog; import android.content.Context; import android.os.AsyncTask; import de.danoeh.antennapod.R; -import de.danoeh.antennapod.activity.OpmlImportActivity; +import de.danoeh.antennapod.activity.OpmlImportFromPathActivity; +import de.danoeh.antennapod.activity.OpmlImportHolder; import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.opml.OpmlElement; import de.danoeh.antennapod.storage.DownloadRequestException; @@ -43,7 +44,7 @@ public class OpmlFeedQueuer extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void... params) { DownloadRequester requester = DownloadRequester.getInstance(); for (int idx = 0; idx < selection.length; idx++) { - OpmlElement element = OpmlImportActivity.getReadElements().get( + OpmlElement element = OpmlImportHolder.getReadElements().get( selection[idx]); Feed feed = new Feed(element.getXmlUrl(), new Date(), element.getText()); diff --git a/src/de/danoeh/antennapod/asynctask/OpmlImportWorker.java b/src/de/danoeh/antennapod/asynctask/OpmlImportWorker.java index 7498b93de..f9b199b63 100644 --- a/src/de/danoeh/antennapod/asynctask/OpmlImportWorker.java +++ b/src/de/danoeh/antennapod/asynctask/OpmlImportWorker.java @@ -1,9 +1,6 @@ package de.danoeh.antennapod.asynctask; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; +import java.io.*; import java.util.ArrayList; import org.xmlpull.v1.XmlPullParserException; @@ -26,35 +23,39 @@ public class OpmlImportWorker extends private static final String TAG = "OpmlImportWorker"; private Context context; - private File file; // path to opml file private Exception exception; private ProgressDialog progDialog; + private Reader mReader; + public OpmlImportWorker(Context context, File file) { super(); this.context = context; - this.file = file; + + // Create reader + try { + mReader = new FileReader(file); + if (AppConfig.DEBUG) Log.d(TAG, "Parsing " + file.toString()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + exception = e; + } } @Override protected ArrayList<OpmlElement> doInBackground(Void... params) { if (AppConfig.DEBUG) Log.d(TAG, "Starting background work"); - FileReader reader = null; - // Create reader - try { - reader = new FileReader(file); - if (AppConfig.DEBUG) Log.d(TAG, "Parsing " + file.toString()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - exception = e; - return null; - } + + if (mReader==null) { + return null; + } + OpmlReader opmlReader = new OpmlReader(); try { - ArrayList<OpmlElement> result = opmlReader.readDocument(reader); - reader.close(); + ArrayList<OpmlElement> result = opmlReader.readDocument(mReader); + mReader.close(); return result; } catch (XmlPullParserException e) { e.printStackTrace(); |