Defending Australian Open champion Novak Djokovic says a confrontation with a spectator was “needed” after holding off Alexei Popyrin to reach the third round.