For your sake, i'd honestly just back away. You're always going to have some kind of emotions for him, being your first boyfriend.
My ex was exactly the same, when he was around friends from him culture, he'd speak down to me, treat me like i was his slave and a piece of dirt, not wanting to be near me. Yet when he was away from them, he would be a nice normal guy. It was just too confusing as it was like living with two different people, one minute he would be the perfect boyfriend, next point he would be distant and cold, acting like he barely knew me.
Eventually you get too fed up of it and damn confused, we tried the whole "let's be friends thing" but it didn't work, he'd still be like two different people, eventually it got to the point where i was ending every sentence with I hate that ***%$^." Just stay away from him, find your own circle and spend your time off with them.
Give yourself time and you won't even want to communicate anymore. It's better to back away now and just leave the friendship. There is a reason why the classic line of "never go back" is there, even if it's just being friends. Me and my ex were great friends before we went out and i do miss him as a friend, but it just doesn't work.