<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def destroy(self):
 """ Custom destructor that deletes the fragment and removes itself from the adapter it was added to. """

        #: Destroy fragment
        fragment = self.fragment
        if fragment:
            #: Stop listening
            fragment.setFragmentListener(None)

            #: Cleanup from fragment
            if self.adapter is not None:
                self.adapter.removeFragment(self.fragment)

            del self.fragment
        super(AndroidFragment, self).destroy()