Fixing a crash when the fragment is not attached to the Activity.