Refactored to remove one "if" statement in onResume().