Refactoring

This commit is contained in:
M66B 2015-11-02 19:18:15 +01:00
parent ebad4d1d04
commit e2b4b7d495
1 changed files with 70 additions and 62 deletions

View File

@ -622,6 +622,19 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
} else if (requestCode == REQUEST_EXPORT) { } else if (requestCode == REQUEST_EXPORT) {
if (resultCode == RESULT_OK && data != null) if (resultCode == RESULT_OK && data != null)
handleExport(data);
} else if (requestCode == REQUEST_IMPORT) {
if (resultCode == RESULT_OK && data != null)
handleImport(data);
} else {
Log.w(TAG, "Unknown activity result request=" + requestCode);
super.onActivityResult(requestCode, resultCode, data);
}
}
private void handleExport(final Intent data) {
new AsyncTask<Object, Object, Throwable>() { new AsyncTask<Object, Object, Throwable>() {
@Override @Override
protected Throwable doInBackground(Object... objects) { protected Throwable doInBackground(Object... objects) {
@ -652,9 +665,9 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show();
} }
}.execute(); }.execute();
}
} else if (requestCode == REQUEST_IMPORT) { private void handleImport(final Intent data) {
if (resultCode == RESULT_OK && data != null)
new AsyncTask<Object, Object, Throwable>() { new AsyncTask<Object, Object, Throwable>() {
@Override @Override
protected Throwable doInBackground(Object... objects) { protected Throwable doInBackground(Object... objects) {
@ -687,11 +700,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityMain.this, ex.toString(), Toast.LENGTH_LONG).show();
} }
}.execute(); }.execute();
} else {
Log.w(TAG, "Unknown activity result request=" + requestCode);
super.onActivityResult(requestCode, resultCode, data);
}
} }
private static Intent getIntentSupport() { private static Intent getIntentSupport() {