示例#1
0
        public void UpdateItem(string name, string unit, string tag, int index, double value, int id)
        {
            ListElement l;

            items.TryGetValue(name, out l);
            if (l == null)
            {
                items.TryAdd(name, l = new ListElement(name, unit, tag, index, value, adapter, id));
                mainActivity.currentTab.AddElements(l);
                adapter.GetContext().RunOnUiThread(() => {
                    adapter.items = mainActivity.currentTab.GetItems(this);
                    adapter.NotifyChange();
                });
            }
            else
            {
                l.SetValue(value);
            }
            if (l.changed)
            {
                adapter.Touch(l);
            }
        }
示例#2
0
        private void LoadTabs()
        {
            try {
                string json = prefs.GetString("tabs", "");

                tabs = Tab.DeSerialize(json);

                foreach (var tab in tabs)
                {
                    if (tab.name == "All")
                    {
                        CreateTab("All", "", "0", "1", tab);
                        tab.items = new List <ListElement>();
                    }
                    else
                    {
                        ActionBar.Tab aTab = ActionBar.NewTab();
                        aTab.SetText(tab.name);
                        tab.ActionBarTab = aTab;

                        Value[] temp = new Value[tab.include.Count];
                        tab.include.CopyTo(temp);
                        tab.include.Clear();
                        foreach (var t in temp)
                        {
                            try {
                                tab.items = new List <ListElement>();
                                tab.include.Add(
                                    parser
                                    .GetAllValues()
                                    .Where(x => x.name == t.name)
                                    .First());
                            }
                            catch (Exception) { }
                        }
                        ;

                        if (tab.name.Contains("Trip"))
                        {
                            trip = tab.trip == null ? tab.trip = new Trip(false) : tab.trip;
                        }

                        aTab.TabSelected += (sender, args) => {
                            currentTab = tab;
                            if (bluetoothHandler.active)
                            {
                                bluetoothHandler.ChangeFilter(currentTab.include);
                            }
                            ladapter.items = currentTab.GetItems(parser);
                            ladapter.items.Any(x => x.selected = false);
                            gridView1.NumColumns = currentTab.style == 0 ? 1 : currentTab.size;
                            gridView1.Invalidate();
                            ladapter.NotifyChange();
                            if (!starting)
                            {
                                editor = prefs.Edit();
                                editor.PutString("currentTab", currentTab.name);
                                editor.Commit();
                            }
                        };
                        ActionBar.AddTab(aTab);
                    }
                }
            }
            catch (Exception e) { Console.WriteLine(e.ToString()); }
        }