- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Store the strings in the local class variables.
- imageUrl = getArguments().getString("URL");
- imageFileName = getArguments().getString("Image_Name");
- }
-
- // The public interface is used to send information back to the parent activity.
- public interface DownloadImageListener {
- void onDownloadImage(AppCompatDialogFragment dialogFragment, String downloadUrl);
- }
-
- // `downloadImageListener` is used in `onAttach()` and `onCreateDialog()`.
- private DownloadImageListener downloadImageListener;
-
- // Check to make sure tha the parent activity implements the listener.
- @Override
- public void onAttach(Context context) {
- super.onAttach(context);
- try {
- downloadImageListener = (DownloadImageListener) context;
- } catch (ClassCastException exception) {
- throw new ClassCastException(context.toString() + " must implement DownloadImageListener.");
- }
- }
-