It can be difficult to know why a person does things. When he gets friendly he might be lonely, he might be feeling a spike of affection for you, he might just enjoy speaking to you. No doubt there are other possibilities. It seems, though, that it is not because he is willing to get back with you.
Given that he is not coming back, a question for you is how to respond to his casual cruelty in flip flopping and thereby tantalizing and and tormenting you. You could ease your pain and start to get past him by by cutting all contact with him.