This is “put of sight out of mind”. When you are together, he is happy so share sexxxytimes. As soon as you are out of sight, he’s unwilling to put in any effort. He’s not thinking about you, at least not enough to bother texting.
Admit he’s your personal kryptonite and stay away from him unless you’re single otherwise you’ll destroy your meaningful romantic relationships.