public void UpdateProgressBar()
{
var chats = ChatViewManager.Chats;
var totalChatCount = chats.Count;
var syncedChatCount = chats.Count(x => x.IsSynced);
var fraction = (double) syncedChatCount / totalChatCount;
if (totalChatCount == 0) {
// x / 0d -> Infinity
fraction = 0;
}
ProgressBar.Fraction = fraction;
ProgressBar.Text = String.Format("{0} / {1}",
syncedChatCount,
totalChatCount);
if (syncedChatCount >= totalChatCount) {
ProgressBar.Hide();
} else {
ProgressBar.Show();
}
}