Beispiel #1
0
        private Tab CreateTab(string name, string tag, string gaugeType, string size, Tab tab = null)
        {
            ActionBar.Tab aTab = ActionBar.NewTab();
            aTab.SetText(name);

            if (tab == null)
            {
                tab = new Tab(
                    name,
                    aTab,
                    name == "Total" ? new Trip(true) : trip);

                tabs.Add(tab);
            }
            else
            {
                tab.ActionBarTab = aTab;
            }
            tab.include = parser.GetValues(tag);
            if (name == "Eff")
            {
                tab.include =
                    tab.include.OrderBy(x => x.unit.Trim()).ToList();
            }
            tab.size  = int.Parse(size);
            tab.style = int.Parse(gaugeType);
            if (name == "BMS")
            {
                tab.style = 3;
            }

            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);
            return(tab);
        }
Beispiel #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()); }
        }