Fix lifecycle of fragments with method to handle the afterinject callback.