Refactor the code between MainActivity and FragmentProfile.