use of org.odk.collect.geo.SelectionMapViewModel in project collect by opendatakit.
the class FormMapActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DaggerUtils.getComponent(this).inject(this);
setContentView(R.layout.form_map_activity);
Form form = loadForm();
selectionMapViewModel = new ViewModelProvider(this).get(SelectionMapViewModel.class);
selectionMapViewModel.setMapTitle(form.getDisplayName());
FormNavigator formNavigator = new FormNavigator(currentProjectProvider, settingsProvider, instancesRepositoryProvider::get);
getSupportFragmentManager().setFragmentResultListener(SelectionMapFragment.REQUEST_SELECT_ITEM, this, (requestKey, result) -> {
if (result.containsKey(SelectionMapFragment.RESULT_SELECTED_ITEM)) {
long instanceId = result.getLong(SelectionMapFragment.RESULT_SELECTED_ITEM);
formNavigator.editInstance(this, instanceId);
} else if (result.containsKey(SelectionMapFragment.RESULT_CREATE_NEW_ITEM)) {
formNavigator.newInstance(this, form.getDbId());
}
});
}
Aggregations