use of net.wigle.wigleandroid.background.KmlWriter in project wigle-wifi-wardriving by wiglenet.
the class DataFragment method handleDialog.
@SuppressLint("SetTextI18n")
@Override
public void handleDialog(final int dialogId) {
final SharedPreferences prefs = getActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0);
final SharedPreferences.Editor editor = prefs.edit();
final View view = getView();
switch(dialogId) {
case CSV_RUN_DIALOG:
{
// actually need this Activity context, for dialogs
ObservationUploader observationUploader = new ObservationUploader(getActivity(), ListFragment.lameStatic.dbHelper, DataFragment.this, true, false, true);
observationUploader.start();
break;
}
case CSV_DB_DIALOG:
{
ObservationUploader observationUploader = new ObservationUploader(getActivity(), ListFragment.lameStatic.dbHelper, DataFragment.this, true, true, false);
observationUploader.start();
break;
}
case KML_RUN_DIALOG:
{
KmlWriter kmlWriter = new KmlWriter(getActivity(), ListFragment.lameStatic.dbHelper, ListFragment.lameStatic.runNetworks);
kmlWriter.start();
break;
}
case KML_DB_DIALOG:
{
KmlWriter kmlWriter = new KmlWriter(getActivity(), ListFragment.lameStatic.dbHelper);
kmlWriter.start();
break;
}
case BACKUP_DIALOG:
{
BackupTask task = new BackupTask(DataFragment.this, MainActivity.getMainActivity(DataFragment.this));
task.execute();
break;
}
case IMPORT_DIALOG:
{
this.createAndStartImport();
break;
}
case ZERO_OUT_DIALOG:
{
editor.putLong(ListFragment.PREF_DB_MARKER, 0L);
editor.apply();
if (view != null) {
final TextView tv = (TextView) view.findViewById(R.id.reset_maxid_text);
tv.setText(getString(R.string.setting_max_id) + " 0");
}
break;
}
case MAX_OUT_DIALOG:
{
final long maxDB = prefs.getLong(ListFragment.PREF_MAX_DB, 0L);
editor.putLong(ListFragment.PREF_DB_MARKER, maxDB);
editor.apply();
if (view != null) {
// set the text on the other button
final TextView tv = (TextView) view.findViewById(R.id.reset_maxid_text);
tv.setText(getString(R.string.setting_max_id) + " " + maxDB);
}
break;
}
case DELETE_DIALOG:
{
// blow away the DB
ListFragment.lameStatic.dbHelper.clearDatabase();
// update markers
editor.putLong(ListFragment.PREF_DB_MARKER, 0L);
editor.putLong(ListFragment.PREF_DB_MARKER, 0L);
editor.apply();
if (view != null) {
final TextView tv = (TextView) view.findViewById(R.id.reset_maxid_text);
tv.setText(getString(R.string.setting_max_id) + " " + 0L);
}
try {
ListFragment.lameStatic.dbHelper.getNetworkCountFromDB();
} catch (DBException dbe) {
MainActivity.warn("Failed to update network count on DB clear: ", dbe);
}
break;
}
default:
MainActivity.warn("Data unhandled dialogId: " + dialogId);
}
}
Aggregations