Search in sources :

Example 1 with FormNavigator

use of org.odk.collect.android.formmanagement.FormNavigator 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());
        }
    });
}
Also used : SelectionMapViewModel(org.odk.collect.geo.SelectionMapViewModel) Form(org.odk.collect.forms.Form) FormNavigator(org.odk.collect.android.formmanagement.FormNavigator) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

ViewModelProvider (androidx.lifecycle.ViewModelProvider)1 FormNavigator (org.odk.collect.android.formmanagement.FormNavigator)1 Form (org.odk.collect.forms.Form)1 SelectionMapViewModel (org.odk.collect.geo.SelectionMapViewModel)1