Basically the tradition indicates that Adam (a) was not a Hujjah and vicegerent in that garden, but when he descended down to earth he became the vicegerent of Allah. Based on this, we can conclude: Allah creates Adam, then he commands the angels to prostrate to him, then later he teaches him all the names and then makes him his vicegerent.