Finished import export function
This commit is contained in:
parent
1112dde4d8
commit
6f1daa20ea
4 changed files with 71 additions and 40 deletions
|
|
@ -41,6 +41,7 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
|
||||
/** Fragments **/
|
||||
private StatusFragment statusFragment;
|
||||
private BehaviourListFragment behaviourListFragment;
|
||||
private MenuItem action_execute;
|
||||
private MenuItem action_mark;
|
||||
private boolean backButtonPressed = false;
|
||||
|
|
@ -70,8 +71,9 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
setContentView(R.layout.activity_main);
|
||||
statusFragment = (StatusFragment)
|
||||
getFragmentManager().findFragmentById(R.id.status_fragment);
|
||||
behaviourListFragment = new BehaviourListFragment();
|
||||
getFragmentManager().beginTransaction()
|
||||
.replace(R.id.container, new BehaviourListFragment()).commit();
|
||||
.replace(R.id.container, behaviourListFragment).commit();
|
||||
|
||||
// Setup Executor
|
||||
if(currentExecutor == null) {
|
||||
|
|
@ -100,8 +102,6 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
|
||||
currentExecutor.setThroughputListener(statusFragment.getThroughputListener());
|
||||
|
||||
|
||||
|
||||
updateExecutionState();
|
||||
}
|
||||
|
||||
|
|
@ -205,11 +205,14 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
return true;
|
||||
}
|
||||
else if (id == R.id.action_import) {
|
||||
FileBrowserDialog browser = FileBrowserDialog.newInstance("/sdcard");
|
||||
FileBrowserDialog browser = FileBrowserDialog.newInstance(
|
||||
"/sdcard", FileBrowserDialog.BrowserMode.SELECT_FILE);
|
||||
browser.show(this.getFragmentManager(), "import");
|
||||
}
|
||||
else if (id == R.id.action_export) {
|
||||
//TODO:
|
||||
FileBrowserDialog browser = FileBrowserDialog.newInstance(
|
||||
"/sdcard", FileBrowserDialog.BrowserMode.NEW_FILE);
|
||||
browser.show(this.getFragmentManager(), "export");
|
||||
}
|
||||
else if (id == R.id.action_settings) {
|
||||
startActivity(new Intent(this, SettingsActivity.class));
|
||||
|
|
@ -221,10 +224,17 @@ public class MainActivity extends FragmentActivity implements OnSharedPreference
|
|||
try {
|
||||
if(tag.equals("import")) {
|
||||
currentExecutor.read(file.getAbsolutePath());
|
||||
behaviourListFragment.onResume();
|
||||
}
|
||||
else if(tag.equals("export")) {
|
||||
currentExecutor.save(file.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to import from: "+file.getAbsolutePath(), e);
|
||||
Toast.makeText(this, "Unable to import from file", Toast.LENGTH_SHORT).show();
|
||||
String msg = "Unable to import from file";
|
||||
if(tag.equals("export"))
|
||||
msg = "Unable to export to file";
|
||||
log.error(msg+": "+file.getAbsolutePath(), e);
|
||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue