Add calculation function and gridview adapter