Answer the question
In order to leave comments, you need to log in
Is it practical to pass objects as a parameter to another controller in Conductor?
As I understand it, you can transfer, but can unforeseen situations happen?
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);
}
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);
}
});
}
Answer the question
In order to leave comments, you need to log in
There is no point in what you did. Nothing will be saved when recreating. Moreover, it will fall because you didn't make an empty constructor.
Arguments must be passed through the getArgs() bundle.
It is stupid to save in shared preferences, because this is a persistent storage.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question