Added error toast message if directory is empty

This commit is contained in:
daniel oeh 2012-07-23 18:23:20 +02:00
parent 3afa2c136e
commit 507a6df046
2 changed files with 20 additions and 12 deletions

View File

@ -133,7 +133,7 @@
<string name="opml_directory_error">ERROR!</string> <string name="opml_directory_error">ERROR!</string>
<string name="reading_opml_label">Reading OPML file</string> <string name="reading_opml_label">Reading OPML file</string>
<string name="opml_reader_error">An error has occured while reading the opml document:</string> <string name="opml_reader_error">An error has occured while reading the opml document:</string>
<string name="opml_import_error_dir_empty">It seems like the import directory is empty. Please copy a OPML file into the directory to import it.</string> <string name="opml_import_error_dir_empty">The import directory is empty.</string>
<string name="select_all_label">Select all</string> <string name="select_all_label">Select all</string>
<string name="deselect_all_label">Deselect all</string> <string name="deselect_all_label">Deselect all</string>

View File

@ -10,6 +10,7 @@ import android.view.View;
import android.view.View.OnClickListener; 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 com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.Menu;
@ -110,34 +111,41 @@ public class OpmlImportActivity extends SherlockActivity {
protected void onPostExecute(ArrayList<OpmlElement> result) { protected void onPostExecute(ArrayList<OpmlElement> result) {
super.onPostExecute(result); super.onPostExecute(result);
if (result != null) { if (result != null) {
if (AppConfig.DEBUG) Log.d(TAG, "Parsing was successful"); if (AppConfig.DEBUG)
Log.d(TAG, "Parsing was successful");
readElements = result; readElements = result;
startActivityForResult(new Intent( startActivityForResult(new Intent(
OpmlImportActivity.this, OpmlImportActivity.this,
OpmlFeedChooserActivity.class), 0); OpmlFeedChooserActivity.class), 0);
} else { } else {
if (AppConfig.DEBUG) Log.d(TAG, "Parser error occured"); if (AppConfig.DEBUG)
Log.d(TAG, "Parser error occured");
} }
} }
}; };
importWorker.executeAsync(); importWorker.executeAsync();
} else { } else {
Log.e(TAG, "Import directory is empty"); Log.e(TAG, "Import directory is empty");
Toast toast = Toast
.makeText(this, R.string.opml_import_error_dir_empty,
Toast.LENGTH_LONG);
toast.show();
} }
} }
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (AppConfig.DEBUG) Log.d(TAG, "Received result"); if (AppConfig.DEBUG)
Log.d(TAG, "Received result");
if (resultCode == RESULT_CANCELED) { if (resultCode == RESULT_CANCELED) {
if (AppConfig.DEBUG) Log.d(TAG, "Activity was cancelled"); if (AppConfig.DEBUG)
Log.d(TAG, "Activity was cancelled");
} else { } else {
int[] selected = data.getIntArrayExtra(OpmlFeedChooserActivity.EXTRA_SELECTED_ITEMS); int[] selected = data
.getIntArrayExtra(OpmlFeedChooserActivity.EXTRA_SELECTED_ITEMS);
if (selected != null && selected.length > 0) { if (selected != null && selected.length > 0) {
OpmlFeedQueuer queuer = new OpmlFeedQueuer(this, selected){ OpmlFeedQueuer queuer = new OpmlFeedQueuer(this, selected) {
@Override @Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
@ -148,12 +156,12 @@ public class OpmlImportActivity extends SherlockActivity {
}; };
queuer.executeAsync(); queuer.executeAsync();
} else { } else {
if (AppConfig.DEBUG) Log.d(TAG, "No items were selected"); if (AppConfig.DEBUG)
Log.d(TAG, "No items were selected");
} }
} }
} }
public static ArrayList<OpmlElement> getReadElements() { public static ArrayList<OpmlElement> getReadElements() {
return readElements; return readElements;
} }