Here is my collision detection loop in sudo-code to assist with reading.
if(Avatar is not colliding with enviroment)
{
while(Enviroment left to move)
{
;
}
}else
{
while(iterator != null)
{
iterator.getValue().moveX(mAvatar.getXVel());
iterator = iterator.getNext();
}
mAvatar.setXVel(0);
lockRight = true;
lockDirection();
}