Use values from dialog

We would like to think this is a far simpler model to work with dialogs. You don't have to remember IDs, you don't have to pollute the mainline code with dialog creation, and you can use derived dialog objects directly to access values.

The principle of this abstraction is as follows. As a first step, we abstract out the creation of a dialog and the preparation of that dialog into a class that identifies a base dialog. We call this interface IDialogProtocol. This dialog also has a show() method on it directly. These dialogs are collected and kept in a registry in the base class for an activity, and they use their IDs as keys. The base activity will de-multiplex the onCreate, onPrepare, and onClick calls based on their IDs and reroute them to the dialog class. This architecture is further illustrated in Figure 5-6.

0 0

Post a comment