mirror of https://github.com/tasks/tasks
Use non-blocking daos in json exporter
parent
5b8256d65e
commit
39077910b7
@ -1,37 +0,0 @@
|
|||||||
package org.tasks.dialogs;
|
|
||||||
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import org.tasks.backup.TasksJsonExporter;
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
public class ExportTasksDialog extends DialogFragment {
|
|
||||||
|
|
||||||
@Inject DialogBuilder dialogBuilder;
|
|
||||||
@Inject TasksJsonExporter tasksJsonExporter;
|
|
||||||
|
|
||||||
public static ExportTasksDialog newExportTasksDialog() {
|
|
||||||
return new ExportTasksDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
ProgressDialog progressDialog = dialogBuilder.newProgressDialog();
|
|
||||||
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
|
||||||
progressDialog.setProgress(0);
|
|
||||||
progressDialog.setCancelable(false);
|
|
||||||
progressDialog.setIndeterminate(false);
|
|
||||||
progressDialog.show();
|
|
||||||
|
|
||||||
setCancelable(false);
|
|
||||||
tasksJsonExporter.exportTasks(
|
|
||||||
getActivity(), TasksJsonExporter.ExportType.EXPORT_TYPE_MANUAL, progressDialog);
|
|
||||||
return progressDialog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package org.tasks.dialogs
|
||||||
|
|
||||||
|
import android.app.Dialog
|
||||||
|
import android.app.ProgressDialog
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import kotlinx.coroutines.NonCancellable
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import org.tasks.backup.TasksJsonExporter
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class ExportTasksDialog : DialogFragment() {
|
||||||
|
@Inject lateinit var dialogBuilder: DialogBuilder
|
||||||
|
@Inject lateinit var tasksJsonExporter: TasksJsonExporter
|
||||||
|
|
||||||
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
|
val progressDialog = dialogBuilder.newProgressDialog()
|
||||||
|
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL)
|
||||||
|
progressDialog.progress = 0
|
||||||
|
progressDialog.setCancelable(false)
|
||||||
|
progressDialog.isIndeterminate = false
|
||||||
|
progressDialog.show()
|
||||||
|
isCancelable = false
|
||||||
|
lifecycleScope.launch(NonCancellable) {
|
||||||
|
tasksJsonExporter.exportTasks(
|
||||||
|
activity, TasksJsonExporter.ExportType.EXPORT_TYPE_MANUAL, progressDialog)
|
||||||
|
}
|
||||||
|
return progressDialog
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun newExportTasksDialog(): ExportTasksDialog {
|
||||||
|
return ExportTasksDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue