Skip to content

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

@AndreThlckr

Description

@AndreThlckr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions