Как понял, передавать можно, но могут ли случиться непредвиденные ситуации?
CheckoutController:public void init(){
btn.setOnClickListener(v->getRouter().pushController(RouterTransaction.with(address == null ? new AddressController(this) : new AddressController(address, this)));
}
@Override
public void setAddress(Address address) {
this.address = address;
tvAddress.setText(address.street+" "+address.house);
}
AddressController:public <T extends Controller & CheckoutListener> AddressController(Address address, T listener) {
this(new BundleBuilder()
.putString("street", address.street)
.putString("house", address.house)
.build());
setTargetController(listener);
}
public AddressController(Bundle bundle){
address.street = bundle.getString("street");
address.house = bundle.getString("house");
}
public void init(){
btnSave.setOnClickListener(v->{
getRouter().popCurrentController();
Address address = new Address();
address.street = etStreet.getText().toString();
address.house = etHouse.getText().toString();
CheckoutListener listener = (CheckoutListener) getTargetController();
if (listener != null) {
listener.setAddress(address);
}
});
}
Или в SharedPreference лучше сохранять?