Slide 26
Slide 26 text
onActivityResultͷ݁ՌΛ
ViewModelͰड͚औΔ
private MySampleMainViewModel viewModel = new MySampleMainViewModel();
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ActivityResult.onResult(requestCode, resultCode, data).into(viewModel);
}
public class MySampleMainViewModel {
public ObservableField location = new ObservableField<>("0,0");
@OnActivityResult(requestCode = MySampleMainActivity.REQUEST_SELECT_LOCATION,
resultCodes = Activity.RESULT_OK)
void onSelectedLocation(@Extra(name = LocationSelectActivity.RESULT_SELECT_LOCATION) Location location) {
this.location.set(location.toString());
}
}