added isContextValid helper function to fragments and activities and utils.