Now displaying progress dialog on export

pull/14/head
Tim Su 16 years ago
parent 5d43da7b68
commit 351e1c0797

@ -4,7 +4,7 @@
<booleanAttribute key="ch.zork.quicklaunch" value="true"/> <booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/> <stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<intAttribute key="ch.zork.quicklaunch.index" value="0"/> <intAttribute key="ch.zork.quicklaunch.index" value="0"/>
<stringAttribute key="ch.zork.quicklaunch.mode" value="run"/> <stringAttribute key="ch.zork.quicklaunch.mode" value="debug"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="0"/> <intAttribute key="com.android.ide.eclipse.adt.action" value="0"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/> <stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>
<intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/> <intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/>

@ -51,8 +51,12 @@ public class BackupActivity extends Activity {
} }
private void exportTasks() { private void exportTasks() {
TasksXmlExporter.exportTasks(this, false); TasksXmlExporter.exportTasks(this, false, new Runnable() {
finish(); @Override
public void run() {
finish();
}
});
} }
} }

@ -38,10 +38,10 @@ public class TasksXmlExporter {
* Import tasks from the given file * Import tasks from the given file
* *
* @param input * @param input
* @param runAfterImport * @param runAfterExport
*/ */
public static void exportTasks(Context context, boolean isService) { public static void exportTasks(Context context, boolean isService, Runnable runAfterExport) {
new TasksXmlExporter(context, isService); new TasksXmlExporter(context, isService, runAfterExport);
} }
// --- implementation // --- implementation
@ -67,24 +67,22 @@ public class TasksXmlExporter {
}); });
} }
private TasksXmlExporter(final Context context, final boolean isService) { private TasksXmlExporter(final Context context, final boolean isService,
final Runnable runAfterExport) {
this.context = context; this.context = context;
this.exportCount = 0; this.exportCount = 0;
progressDialog = new ProgressDialog(context);
handler = new Handler(); handler = new Handler();
progressDialog = new ProgressDialog(context);
if(!isService) { if(!isService) {
handler.post(new Runnable() { progressDialog.setIcon(android.R.drawable.ic_dialog_info);
@Override progressDialog.setTitle(R.string.export_progress_title);
public void run() { progressDialog.setMessage(context.getString(R.string.backup_progress_initial));
progressDialog.setIcon(android.R.drawable.ic_dialog_info); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle(R.string.export_progress_title); progressDialog.setProgress(0);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(false);
progressDialog.setCancelable(false); progressDialog.setIndeterminate(false);
progressDialog.setIndeterminate(false); progressDialog.show();
progressDialog.show();
}
});
} }
new Thread(new Runnable() { new Thread(new Runnable() {
@ -107,6 +105,9 @@ public class TasksXmlExporter {
exceptionService.reportError("background-backup", e); //$NON-NLS-1$ exceptionService.reportError("background-backup", e); //$NON-NLS-1$
Preferences.setString(BackupService.PREF_BACKUP_LAST_ERROR, e.toString()); Preferences.setString(BackupService.PREF_BACKUP_LAST_ERROR, e.toString());
} }
} finally {
if(runAfterExport != null)
runAfterExport.run();
} }
} }
}).start(); }).start();

@ -58,7 +58,7 @@ public class TasksXmlImporter {
// --- implementation // --- implementation
private final Handler importHandler; private final Handler handler;
private int taskCount; private int taskCount;
private int importCount; private int importCount;
private int skipCount; private int skipCount;
@ -72,7 +72,7 @@ public class TasksXmlImporter {
private final Runnable runAfterImport; private final Runnable runAfterImport;
private void setProgressMessage(final String message) { private void setProgressMessage(final String message) {
importHandler.post(new Runnable() { handler.post(new Runnable() {
public void run() { public void run() {
progressDialog.setMessage(message); progressDialog.setMessage(message);
} }
@ -87,21 +87,17 @@ public class TasksXmlImporter {
this.input = input; this.input = input;
this.context = context; this.context = context;
this.runAfterImport = runAfterImport; this.runAfterImport = runAfterImport;
handler = new Handler();
progressDialog = new ProgressDialog(context); progressDialog = new ProgressDialog(context);
progressDialog.setIcon(android.R.drawable.ic_dialog_info);
progressDialog.setTitle(R.string.import_progress_title);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(context.getString(R.string.backup_progress_initial));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
importHandler = new Handler();
importHandler.post(new Runnable() {
@Override
public void run() {
progressDialog.setIcon(android.R.drawable.ic_dialog_info);
progressDialog.setTitle(R.string.import_progress_title);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(context.getString(R.string.import_progress_open));
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
}
});
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -150,8 +146,13 @@ public class TasksXmlImporter {
} }
} }
} finally { } finally {
progressDialog.dismiss(); handler.post(new Runnable() {
showSummary(); @Override
public void run() {
progressDialog.dismiss();
showSummary();
}
});
} }
} }
@ -170,17 +171,12 @@ public class TasksXmlImporter {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
dialog.dismiss(); dialog.dismiss();
if (runAfterImport != null) { if (runAfterImport != null) {
importHandler.post(runAfterImport); handler.post(runAfterImport);
} }
} }
}); });
importHandler.post(new Runnable() { builder.show();
@Override
public void run() {
builder.show();
}
});
} }
// --- importers // --- importers

@ -60,8 +60,8 @@ File %s contained %s.\n\n
<!-- Progress Dialog Title for importing --> <!-- Progress Dialog Title for importing -->
<string name="import_progress_title">Importing...</string> <string name="import_progress_title">Importing...</string>
<!-- Progress Dialog text for import opening file --> <!-- Progress Dialog text for starting import/export -->
<string name="import_progress_open">Opening file...</string> <string name="backup_progress_initial">Initializing...</string>
<!-- Progress Dialog text for import reading task (%d -> task number)--> <!-- Progress Dialog text for import reading task (%d -> task number)-->
<string name="import_progress_read">Reading task %d...</string> <string name="import_progress_read">Reading task %d...</string>

@ -61,8 +61,6 @@ public class FilterAdapter extends BaseExpandableListAdapter {
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
listView.setGroupIndicator( listView.setGroupIndicator(
activity.getResources().getDrawable(R.drawable.expander_group)); activity.getResources().getDrawable(R.drawable.expander_group));
getLists();
} }
public boolean hasStableIds() { public boolean hasStableIds() {

Loading…
Cancel
Save