deduplication and cleanup -> preparing a pull request
This commit is contained in:
parent
e54dbbcdce
commit
ab9b244af4
@ -11,10 +11,9 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.preference.PreferenceActivity;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import de.danoeh.antennapod.activity.OpmlImportActivity;
|
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||||
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||||
import de.danoeh.antennapod.feed.FeedManager;
|
import de.danoeh.antennapod.feed.FeedManager;
|
||||||
import de.danoeh.antennapod.feed.FeedMedia;
|
import de.danoeh.antennapod.feed.FeedMedia;
|
||||||
@ -94,7 +93,7 @@ public class PodcastApp extends Application implements
|
|||||||
* available
|
* available
|
||||||
*/
|
*/
|
||||||
private void createImportDirectory() {
|
private void createImportDirectory() {
|
||||||
File importDir = getDataFolder(this, OpmlImportActivity.IMPORT_DIR);
|
File importDir = getDataFolder(this, OpmlImportFromPathActivity.IMPORT_DIR);
|
||||||
if (importDir != null) {
|
if (importDir != null) {
|
||||||
if (importDir.exists()) {
|
if (importDir.exists()) {
|
||||||
if (AppConfig.DEBUG)
|
if (AppConfig.DEBUG)
|
||||||
|
@ -1,27 +1,13 @@
|
|||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
import com.actionbarsherlock.app.SherlockActivity;
|
||||||
import com.actionbarsherlock.view.Menu;
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
|
||||||
import de.danoeh.antennapod.AppConfig;
|
import de.danoeh.antennapod.AppConfig;
|
||||||
import de.danoeh.antennapod.PodcastApp;
|
|
||||||
import de.danoeh.antennapod.R;
|
|
||||||
import de.danoeh.antennapod.asynctask.OpmlFeedQueuer;
|
import de.danoeh.antennapod.asynctask.OpmlFeedQueuer;
|
||||||
import de.danoeh.antennapod.asynctask.OpmlImportWorker;
|
import de.danoeh.antennapod.asynctask.OpmlImportWorker;
|
||||||
import de.danoeh.antennapod.opml.OpmlElement;
|
import de.danoeh.antennapod.opml.OpmlElement;
|
||||||
import de.danoeh.antennapod.util.StorageUtils;
|
import java.io.Reader;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +16,7 @@ import java.util.ArrayList;
|
|||||||
public class OpmlImportBaseActivity extends SherlockActivity {
|
public class OpmlImportBaseActivity extends SherlockActivity {
|
||||||
|
|
||||||
private static final String TAG = "OpmlImportBaseActivity";
|
private static final String TAG = "OpmlImportBaseActivity";
|
||||||
|
private OpmlImportWorker importWorker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the choices made by the user in the OpmlFeedChooserActivity and
|
* Handles the choices made by the user in the OpmlFeedChooserActivity and
|
||||||
@ -68,6 +55,32 @@ public class OpmlImportBaseActivity extends SherlockActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Starts the import process. */
|
||||||
|
protected void startImport(Reader reader) {
|
||||||
|
|
||||||
|
if (reader != null) {
|
||||||
|
importWorker = new OpmlImportWorker(this, reader) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(ArrayList<OpmlElement> result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
if (result != null) {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Parsing was successful");
|
||||||
|
OpmlImportHolder.setReadElements(result);
|
||||||
|
startActivityForResult(new Intent(
|
||||||
|
OpmlImportBaseActivity.this,
|
||||||
|
OpmlFeedChooserActivity.class), 0);
|
||||||
|
} else {
|
||||||
|
if (AppConfig.DEBUG)
|
||||||
|
Log.d(TAG, "Parser error occured");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
importWorker.executeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean finishWhenCanceled() {
|
protected boolean finishWhenCanceled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,13 @@
|
|||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
|
||||||
import de.danoeh.antennapod.AppConfig;
|
|
||||||
import de.danoeh.antennapod.PodcastApp;
|
import de.danoeh.antennapod.PodcastApp;
|
||||||
import de.danoeh.antennapod.R;
|
|
||||||
import de.danoeh.antennapod.asynctask.OpmlImportWorker;
|
|
||||||
import de.danoeh.antennapod.opml.OpmlElement;
|
|
||||||
import de.danoeh.antennapod.util.StorageUtils;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/** Lets the user start the OPML-import process. */
|
/** Lets the user start the OPML-import process. */
|
||||||
public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
||||||
private static final String TAG = "OpmlImportFromPathActivity";
|
|
||||||
|
|
||||||
public static final String IMPORT_DIR = "import/";
|
|
||||||
|
|
||||||
private OpmlImportWorker importWorker;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -49,33 +26,6 @@ public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Starts the import process. */
|
|
||||||
private void startImport(Reader reader) {
|
|
||||||
|
|
||||||
if (reader != null) {
|
|
||||||
importWorker = new OpmlImportWorker(this, reader) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(ArrayList<OpmlElement> result) {
|
|
||||||
super.onPostExecute(result);
|
|
||||||
if (result != null) {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Parsing was successful");
|
|
||||||
OpmlImportHolder.setReadElements(result);
|
|
||||||
startActivityForResult(new Intent(
|
|
||||||
OpmlImportFromIntentActivity.this,
|
|
||||||
OpmlFeedChooserActivity.class), 0);
|
|
||||||
} else {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Parser error occured");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
importWorker.executeAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean finishWhenCanceled() {
|
protected boolean finishWhenCanceled() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -13,31 +9,28 @@ import android.view.View.OnClickListener;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
import de.danoeh.antennapod.AppConfig;
|
import de.danoeh.antennapod.AppConfig;
|
||||||
import de.danoeh.antennapod.PodcastApp;
|
import de.danoeh.antennapod.PodcastApp;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.asynctask.OpmlFeedQueuer;
|
|
||||||
import de.danoeh.antennapod.asynctask.OpmlImportWorker;
|
|
||||||
import de.danoeh.antennapod.opml.OpmlElement;
|
|
||||||
import de.danoeh.antennapod.util.StorageUtils;
|
import de.danoeh.antennapod.util.StorageUtils;
|
||||||
|
|
||||||
/** Lets the user start the OPML-import process. */
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lets the user start the OPML-import process from a path
|
||||||
|
*/
|
||||||
public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
||||||
private static final String TAG = "OpmlImportFromPathActivity";
|
|
||||||
|
|
||||||
public static final String IMPORT_DIR = "import/";
|
public static final String IMPORT_DIR = "import/";
|
||||||
|
private static final String TAG = "OpmlImportFromPathActivity";
|
||||||
private TextView txtvPath;
|
private TextView txtvPath;
|
||||||
private Button butStart;
|
private Button butStart;
|
||||||
private String importPath;
|
private String importPath;
|
||||||
|
|
||||||
private OpmlImportWorker importWorker;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
setTheme(PodcastApp.getThemeResourceId());
|
setTheme(PodcastApp.getThemeResourceId());
|
||||||
@ -108,7 +101,7 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
|||||||
* Looks at the contents of the import directory and decides what to do. If
|
* Looks at the contents of the import directory and decides what to do. If
|
||||||
* more than one file is in the directory, a dialog will be created to let
|
* more than one file is in the directory, a dialog will be created to let
|
||||||
* the user choose which item to import
|
* the user choose which item to import
|
||||||
* */
|
*/
|
||||||
private void checkFolderForFiles() {
|
private void checkFolderForFiles() {
|
||||||
File dir = new File(importPath);
|
File dir = new File(importPath);
|
||||||
if (dir.isDirectory()) {
|
if (dir.isDirectory()) {
|
||||||
@ -130,29 +123,14 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Starts the import process. */
|
|
||||||
private void startImport(File file) {
|
private void startImport(File file) {
|
||||||
|
try {
|
||||||
if (file != null) {
|
Reader mReader = new FileReader(file);
|
||||||
importWorker = new OpmlImportWorker(this, file) {
|
if (AppConfig.DEBUG) Log.d(TAG, "Parsing " + file.toString());
|
||||||
|
startImport(mReader);
|
||||||
@Override
|
} catch (FileNotFoundException e) {
|
||||||
protected void onPostExecute(ArrayList<OpmlElement> result) {
|
Log.d(TAG, "File not found which really should be there");
|
||||||
super.onPostExecute(result);
|
// this should never happen as it is a file we have just chosen
|
||||||
if (result != null) {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Parsing was successful");
|
|
||||||
OpmlImportHolder.setReadElements(result);
|
|
||||||
startActivityForResult(new Intent(
|
|
||||||
OpmlImportFromPathActivity.this,
|
|
||||||
OpmlFeedChooserActivity.class), 0);
|
|
||||||
} else {
|
|
||||||
if (AppConfig.DEBUG)
|
|
||||||
Log.d(TAG, "Parser error occured");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
importWorker.executeAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,20 +29,6 @@ public class OpmlImportWorker extends
|
|||||||
|
|
||||||
private Reader mReader;
|
private Reader mReader;
|
||||||
|
|
||||||
public OpmlImportWorker(Context context, File file) {
|
|
||||||
super();
|
|
||||||
this.context = context;
|
|
||||||
|
|
||||||
// Create reader
|
|
||||||
try {
|
|
||||||
mReader = new FileReader(file);
|
|
||||||
if (AppConfig.DEBUG) Log.d(TAG, "Parsing " + file.toString());
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
exception = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpmlImportWorker(Context context, Reader reader) {
|
public OpmlImportWorker(Context context, Reader reader) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user