Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace callbacks in activities/fragments with Fragment Result API #36

Open
AndreThlckr opened this issue Dec 23, 2021 · 1 comment
Open

Comments

@AndreThlckr
Copy link

Currently, in order to retrieve the value from the CalcDialog, the owner (an activity or a fragment) needs to implement the CalcDialog.CalcDialogCallback interface.

In the newer versions of the fragment library, the Fragment Result API is available, which I believe is a better way to implement the communication between the dialog and the owner. (Fragment Result API)

It's usage would be something like this:

setFragmentResultListener("calcDialogKey") { requestKey, bundle ->
	val enteredValue = bundle.getSerializableExtra("enteredValueKey") as BigDecimal
	// Handle the result...
}

Some utility functions could also be created to simplify even more this process, resulting in something like:

setCalculatorResultListener { enteredValue: BigDecimal ->
	// Handle the result...
}

If this seems like a good idea, I can work on this feature and open a PR with the changes required.

@maltaisn
Copy link
Owner

Sure, it seems like that's the way to go going forward. You can work on a pull request and I'll merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants