Now displaying progress dialog on export

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

@ -4,7 +4,7 @@
<booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<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"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>
<intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/>

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

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

@ -58,7 +58,7 @@ public class TasksXmlImporter {
// --- implementation
private final Handler importHandler;
private final Handler handler;
private int taskCount;
private int importCount;
private int skipCount;
@ -72,7 +72,7 @@ public class TasksXmlImporter {
private final Runnable runAfterImport;
private void setProgressMessage(final String message) {
importHandler.post(new Runnable() {
handler.post(new Runnable() {
public void run() {
progressDialog.setMessage(message);
}
@ -87,21 +87,17 @@ public class TasksXmlImporter {
this.input = input;
this.context = context;
this.runAfterImport = runAfterImport;
handler = new Handler();
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() {
@Override
public void run() {
@ -150,8 +146,13 @@ public class TasksXmlImporter {
}
}
} finally {
progressDialog.dismiss();
showSummary();
handler.post(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
showSummary();
}
});
}
}
@ -170,17 +171,12 @@ public class TasksXmlImporter {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
if (runAfterImport != null) {
importHandler.post(runAfterImport);
handler.post(runAfterImport);
}
}
});
importHandler.post(new Runnable() {
@Override
public void run() {
builder.show();
}
});
builder.show();
}
// --- importers

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

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

Loading…
Cancel
Save