private void InitAddBtn()
        {
            int numToAdd = 10;

            addBtn.Text = "Add " + numToAdd + " Random messages";
            addBtn.HorizontalOptions = LayoutOptions.Fill;

            addBtn.Clicked += (sender, e) =>
            {
                Random       r     = new Random();
                const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

                string   randText;
                int      strLength = 10;
                char[]   cs;
                ChatItem chat;
                for (int i = 0; i < numToAdd; i++)
                {
                    cs       = Enumerable.Repeat(chars, strLength).Select(s => s[r.Next(s.Length)]).ToArray();
                    randText = new string(cs);
                    chat     = new ChatItem(randText, "15/03/2017");
                    string newKey = FirebaseDatabaseSharedService.Instance.BatchSetObj(nodePath, chat);
                    chat.Key = newKey;
                }
            };
        }
        public void OnChatItemAdded(string key, ChatItem item)
        {
            item.Key = key;

            messages.Add(item);

            list.ScrollTo(messages[messages.Count - 1], ScrollToPosition.End, true);

            entry.Text = null;
        }
        private void InitEntry()
        {
            entry.Placeholder       = "Type Message...";
            entry.BackgroundColor   = Color.White;
            entry.VerticalOptions   = LayoutOptions.End;
            entry.HorizontalOptions = LayoutOptions.Fill;

            entry.Completed += (sender, e) =>
            {
                ChatItem chat = new ChatItem(entry.Text, "15/03/2017");
                //chat.Key = DependencyService.Get<FirebaseDatabaseService>().SetChildValueByAutoId(nodePath, chat);
                chat.Key = FirebaseDatabaseSharedService.Instance.BatchSetObj(nodePath, chat);
            };
        }
        void DeleteChat(object sender, SelectedItemChangedEventArgs e)
        {
            ChatItem chatItem = e.SelectedItem as ChatItem;

            if (chatItem.Key != null)
            {
                string nodePath = string.Format("{0}{1}{2}", MESSAGES_URL_PREFIX, "Bri2", MESSAGES_URL_SUFFIX);
                FirebaseDatabaseSharedService.Instance.BatchRemoveObj(nodePath, chatItem.Key, chatItem);
            }
            else
            {
                Debug.WriteLine("Error: Cant delete chat, No Firebase key for: " + chatItem.Message.ToString());
            }

            messages.Remove(chatItem);
        }
 public void OnChatItemChanged(string key, ChatItem item)
 {
     // TODO: Implement
 }