Esempio n. 1
0
 public void ColumnDeleted(int index)
 {
     cells[index].DeleteView();
     columns[index].DeleteView();
     layout.RemoveViewAt(index * 2 + ADDITIONAL_ROWS);
     layout.RemoveViewAt(index * 2 + ADDITIONAL_ROWS);
 }
        private void DeletePlace(object sender, EventArgs e)
        {
            ViewGroup parent = (ViewGroup)((ImageButton)sender).Parent;

            for (int i = 0; i < parent.ChildCount; i++)
            {
                View child = parent.GetChildAt(i);
                if (child.GetType() == typeof(AppCompatTextView))
                {
                    chosenPlaces.RemoveAll(p => p.Name == ((TextView)child).Text);
                    break;
                }
            }

            ViewGroup topParent = (ViewGroup)parent.Parent.Parent;

            for (int i = 0; i < choicesRoot.ChildCount; i++)
            {
                View child = choicesRoot.GetChildAt(i);
                if (child.Id == topParent.Id)
                {
                    choicesRoot.RemoveViewAt(i);
                    break;
                }
            }

            if (choicesRoot.ChildCount <= 1)
            {
                choicesRoot.Visibility = ViewStates.Gone;
            }
        }
Esempio n. 3
0
        public void OnAddExerciseEvent(EditText exerciseEdittext, int currentPosition,
                                       LinearLayout currentExpandedLayout, LinearLayout.LayoutParams ll, int index, CardView rootCardView)
        {
            HideKeyboard(exerciseEdittext);

            // format exercises list
            if (currentPosition > -1 && currentPosition < data.Count)
            {
                data[currentPosition].exercises += (data[currentPosition].exercises != null ? "\n" : "") + exerciseEdittext.Text.ToString();
            }

            // replace edit view with normal exercise view
            currentExpandedLayout.RemoveViewAt(index);
            View exerciseView = LayoutInflater.From(context).Inflate(Resource.Layout.ListItemExercise, null);

            exerciseView.FindViewById <TextView>(Resource.Id.exercise_name).Text = exerciseEdittext.Text.ToString();
            ll.LeftMargin = 24; ll.RightMargin = 24;
            exerciseView.LayoutParameters = ll;
            currentExpandedLayout.AddView(exerciseView, index);

            LinearLayout rootExerciseItem = exerciseView.FindViewById <LinearLayout>(Resource.Id.root_exercise_item);
            Button       addSetBtn        = exerciseView.FindViewById <Button>(Resource.Id.add_set_btn);

            if (!rootExerciseItem.HasOnClickListeners)
            {
                rootExerciseItem.Click += delegate(object rootSender, EventArgs rootE) { ExerciseItemOnClick(rootSender, rootE); };
            }

            if (!addSetBtn.HasOnClickListeners)
            {
                addSetBtn.Click += delegate(object addSetSender, EventArgs addSetE) { ExerciseItemOnClick(addSetSender, addSetE); };
            }
        }
        private void DeleteItemClicked(object sender, EventArgs e)
        {
            ViewGroup parent = (ViewGroup)((ImageButton)sender).Parent;

            for (int i = 0; i < parent.ChildCount; i++)
            {
                View child = parent.GetChildAt(i);
                if (child.GetType() == typeof(AppCompatTextView))
                {
                    entries.Remove(((TextView)child).Text);
                    break;
                }
            }

            ViewGroup topParent = (ViewGroup)parent.Parent.Parent;

            for (int i = 0; i < choicesRoot.ChildCount; i++)
            {
                View child = choicesRoot.GetChildAt(i);
                if (child.Id == topParent.Id)
                {
                    choicesRoot.RemoveViewAt(i);
                    break;
                }
            }

            if (choicesRoot.ChildCount <= 1)
            {
                optionsHeader.Text = Resources.GetString(Resource.String.createNewMultChoiceNone);
            }
        }
        private void RemoveButtonClick(object sender, EventArgs e)
        {
            var index = _viewGroup.ChildCount - 1;

            if (index > -1)
            {
                _viewGroup.RemoveViewAt(index);
            }
        }
        private void OnClickRemoveDeveloper(object sender, EventArgs e)
        {
            var button      = (ImageView)sender;
            int posToRemove = (int)button.Tag;

            lstAssignments.RemoveAt(posToRemove);
            lstDevelopers.RemoveAt(posToRemove);
            ly_developers.RemoveViewAt(posToRemove);
        }
Esempio n. 7
0
 public void removeChilren(LinearLayout layout)
 {
     if (layout.ChildCount > 0)
     {
         for (int i = layout.ChildCount - 1; i > 0; i--)
         {
             layout.RemoveViewAt(i);
         }
     }
 }
        private void RemoveButtonClick(object sender, EventArgs e)
        {
            var index = _viewGroup.ChildCount - 1;

            if (index > -1)
            {
                TransitionManager.BeginDelayedTransition(_viewGroup, new Slide((int)GravityFlags.Top));
                _viewGroup.RemoveViewAt(index);
            }
        }
        public override void DataChanged(Dictionary <string, string> data)
        {
            if (data.ContainsKey("operation"))
            {
                switch (data["operation"])
                {
                case "del":
                    options.RemoveViewAt(int.Parse(data["index"]));
                    break;

                case "patch":
                    TextView updated = (TextView)options.FindViewWithTag(data["key"]);
                    updated.Text = data["value"];
                    break;

                case "put":
                    TextView option = new TextView(context)
                    {
                        Id   = 6667,
                        Tag  = data["key"],
                        Text = data["value"]
                    };
                    option.SetOnClickListener(this);
                    options.AddView(option, int.Parse(data["index"]));
                    break;

                case "new":
                    TextView newoption = new TextView(context)
                    {
                        Id   = 6667,
                        Tag  = data["key"],
                        Text = data["value"]
                    };
                    newoption.SetOnClickListener(this);
                    options.AddView(newoption, options.ChildCount - 1);
                    break;
                }
            }
            else
            {
                foreach (string key in data.Keys)
                {
                    TextView option = new TextView(context)
                    {
                        Id   = 6667,
                        Tag  = key,
                        Text = data[key]
                    };

                    option.SetOnClickListener(this);
                    options.AddView(option, options.ChildCount - 1);
                }
            }
        }
Esempio n. 10
0
 public void SetFooterView(View header, int index, Orientation orientation)
 {
     if (footerLayout == null || footerLayout.ChildCount <= index)
     {
         AddFooterView(header, index, orientation);
     }
     else
     {
         footerLayout.RemoveViewAt(index);
         footerLayout.AddView(header, index);
     }
 }
Esempio n. 11
0
        private void ConfigureExerciseTrashcanListener(View newExerciseView, int viewPosition, LinearLayout currentExpandedLayout, EditText exerciseEdittext)
        {
            ImageButton deleteExerciseBtn = newExerciseView.FindViewById <ImageButton>(Resource.Id.delete_exercise_btn);

            if (!deleteExerciseBtn.HasOnClickListeners)
            {
                deleteExerciseBtn.Click += delegate(object sender, EventArgs e)
                {
                    currentExpandedLayout.RemoveViewAt(viewPosition);
                    HideKeyboard(exerciseEdittext);
                };
            }
            ;
        }
Esempio n. 12
0
        /// <summary>
        /// Remove a action from the action bar.
        /// </summary>
        /// <param name="index">position of action to remove</param>
        public void RemoveActionAt(int index)
        {
            if (index < 1)
            {
                return;
            }

            var menuItemAction = m_ActionsView.GetChildAt(index).Tag as MenuItemActionBarAction;

            if (menuItemAction != null)
            {
                MenuItemsToHide.Remove(menuItemAction.MenuItemId);
            }

            m_ActionsView.RemoveViewAt(index);
        }
Esempio n. 13
0
        private void Txt_LongClick(object sender, View.LongClickEventArgs e)
        {
            try
            {
                TableTextView tv    = (TableTextView)sender;
                int           index = Convert.ToInt32(tv.Tag.ToString().Trim());

                mainLinerLayout = (LinearLayout)this.FindViewById(Resource.Id.RuleBreakTable);
                mainLinerLayout.RemoveViewAt(index);
                lstRules.RemoveAt(index);
            }
            catch (Exception ex)
            {
                LogManager.WriteSystemLog(ex.Message + ex.Source + ex.StackTrace);
            }
        }
Esempio n. 14
0
        private void DeleteFile(AttachmentFile documentFile, int filePosition)
        {
            // Delete file from server if it's necessary
            // If the file has id that means that it was upload to the server, so it's needed to remove
            if (documentFile.Id != null)
            {
                filesToDeleteInServer.Add(documentFile);

                // Call WS to remove file in server
                //RemoveFileFromServer(documentFile, filePosition);
            }

            // Remove file in view
            attachedFiles.RemoveAt(filePosition);

            filesContainer.RemoveViewAt(filePosition);
        }
 private void ShowWebview(bool show)
 {
     if (show == true)
     {
         layoutList.Visibility = Android.Views.ViewStates.Gone;
         layoutWeb.Visibility  = Android.Views.ViewStates.Visible;
         int count = linearTabs.ChildCount - 1;
         for (int i = count; i >= 0; i--)
         {
             bool delete = false;
             View view   = linearTabs.GetChildAt(i);
             if (view is Button)
             {
                 Button vw = (Button)view;
                 delete = ((string)vw.GetTag(vw.Id) != "passageButton1");
             }
             if (delete)
             {
                 linearTabs.RemoveViewAt(i);
             }
         }
         passageButton.Visibility = ViewStates.Gone;
         int p = 0;
         foreach (string s in _Passages)
         {
             if (s != null || s != "")
             {
                 Button bt = new Button(this);
                 bt.LayoutParameters = passageButton.LayoutParameters;
                 bt.Id     = passageButton.Id + p;
                 bt.Text   = "Psg " + (p + 1).ToString();
                 bt.Tag    = p;
                 bt.Click += PassageButton_Click;
                 linearTabs.AddView(bt, p);
                 p++;
             }
         }
         LoadPassage(_activeVersion, _activePassages, 0);
     }
     else
     {
         layoutList.Visibility = ViewStates.Visible;
         layoutWeb.Visibility  = ViewStates.Gone;
         webview1.LoadUrl("");
     }
 }
Esempio n. 16
0
        public void DeleteAdvancedString(View view)
        {
            var          section   = view.Parent;
            LinearLayout container = (LinearLayout)FindViewById(Resource.Id.advanced_container);

            State.EntryModified = true;
            for (int i = 0; i < container.ChildCount; i++)
            {
                var ees = container.GetChildAt(i);
                if (ees == section)
                {
                    container.RemoveViewAt(i);
                    container.Invalidate();
                    break;
                }
            }
        }
Esempio n. 17
0
        private void SpSentenceItem_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            LinearLayout ll = (sender as Spinner).Parent as LinearLayout;

            if (e.Id == SentencePart.spModalVerb ||
                e.Id == SentencePart.spNotionalVerb)
            {
                if (ll.ChildCount == 1)
                {
                    var lp = new TableLayout.LayoutParams(0, ViewGroup.LayoutParams.WrapContent)
                    {
                        Weight = 1
                    };
                    Spinner spSentenceItemType = new Spinner(this)
                    {
                        LayoutParameters = lp
                    };
                    ll.AddView(spSentenceItemType);
                }

                BaseAdapter adapter;
                Spinner     sp = ll.GetChildAt(1) as Spinner;
                if (e.Id == SentencePart.spModalVerb)
                {
                    adapter = new LObjectListAdapter(this, ModalVerb.Instance.List.Values.ToArray());
                }
                else
                {
                    adapter = new LObjectListAdapter(this, NotionalVerb.Instance.List.Values.ToArray());
                }
                sp.Adapter = adapter;
            }
            else
            {
                if (ll.ChildCount == 2)
                {
                    ll.RemoveViewAt(1);
                }
            }
        }
Esempio n. 18
0
        public void RemoveSort(int index)
        {
            SortStruct removed = sorts[index];

            isSorted[sorts.IndexOf(removed)] = false;
            sortsList.RemoveViewAt(index);
            sorts.RemoveAt(index);

            for (int i = index; i < sortsList.ChildCount - 1; ++i)
            {
                View updated = sortsList.GetChildAt(i);

                TextView columnButton = updated.FindViewById <TextView>(Resource.Id.ViewSortColumn);
                columnButton.Tag = i;

                TextView sortTypeButton = updated.FindViewById <TextView>(Resource.Id.ViewSortType);
                sortTypeButton.Tag = i;

                View removeButton = updated.FindViewById(Resource.Id.ViewSortRemove);
                removeButton.Tag = i;
            }
        }
Esempio n. 19
0
        public void AddFixedText(string text)
        {
            EditText fixedText = new EditText(Context);

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            layoutParams.Gravity = GravityFlags.CenterVertical;
            fixedText.SetTextAppearance(Context, Resource.Style.judo_payments_CardText);
            fixedText.LayoutParameters = layoutParams;
            fixedText.Enabled          = false;
            fixedText.Focusable        = false;
            fixedText.Text             = text;
            fixedText.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            fixedText.SetPadding(0, 0, 0, 0);
            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);

            fixedText.Typeface = type;

            if (linearLayout.ChildCount > 1)
            {
                linearLayout.RemoveViewAt(0);
            }
            linearLayout.AddView(fixedText, 0);
        }
        public void RemoveSort(int index)
        {
            FilterStruct removed = filters[index];

            filtersList.RemoveViewAt(index);
            filters.RemoveAt(index);

            for (int i = index; i < filtersList.ChildCount - 1; ++i)
            {
                View updated = filtersList.GetChildAt(i);

                TextView columnButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterColumn);
                columnButton.Tag = i;

                TextView sortTypeButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterType);
                sortTypeButton.Tag = i;

                TextView sortStringButton = updated.FindViewById <TextView>(Resource.Id.ViewFilterPredicate);
                sortStringButton.Tag = i;

                View removeButton = updated.FindViewById(Resource.Id.ViewFilterRemove);
                removeButton.Tag = i;
            }
        }
 public void ColumnDeleted(int index)
 {
     cells.RemoveAt(index);
     mainLayout.RemoveViewAt(index * 2);
     mainLayout.RemoveViewAt(index * 2);
 }
Esempio n. 22
0
        public override View GetSampleContent(Context con)
        {
            float        height = con.Resources.DisplayMetrics.HeightPixels;;
            LinearLayout layout = new LinearLayout(con);
            Typeface     tf     = Typeface.CreateFromAsset(con.Assets, "Segoe_MDL2_Assets.ttf");

            layout.Orientation  = Android.Widget.Orientation.Vertical;
            sfpicker            = new SfPicker(con);
            sfpicker.ShowHeader = true;
            List <String> source = new List <string>();

            source.Add("Yellow");
            source.Add("Green");
            source.Add("Orange");
            source.Add("Lime");
            source.Add("LightBlue");
            source.Add("Pink");
            source.Add("SkyBlue");
            source.Add("White");
            source.Add("Red");
            source.Add("Aqua");
            sfpicker.ItemsSource      = source;
            sfpicker.LayoutParameters = new ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, (int)(height * 0.60));
            sfpicker.PickerMode       = PickerMode.Default;
            sfpicker.ShowFooter       = false;

            sfpicker.SelectedItemTextSize    = 20 * con.Resources.DisplayMetrics.Density;
            sfpicker.UnSelectedItemTextSize  = 20 * con.Resources.DisplayMetrics.Density;
            sfpicker.HeaderHeight            = 40 * con.Resources.DisplayMetrics.Density;
            sfpicker.ShowColumnHeader        = false;
            sfpicker.UnSelectedItemTextColor = Color.Black;
            sfpicker.SelectedIndex           = 7;
            float density = con.Resources.DisplayMetrics.Density;

            eventLog = new TextView(con);
            eventLog.LayoutParameters = new ViewGroup.LayoutParams(800, 400);
            layout.SetGravity(GravityFlags.CenterHorizontal);
            layout.AddView(sfpicker);
            string headerText1 = "PICK A COLOR";

            sfpicker.ShowHeader  = true;
            sfpicker.HeaderText  = headerText1;
            sfpicker.BorderColor = Color.Red;
            TextView textview = new TextView(con);

            textview.Text     = "Event Log";
            textview.Typeface = tf;
            textview.SetTextColor(Color.Black);

            textview.TextSize = 20;
            if (density > 2)
            {
                textview.SetPadding(20, 0, 0, 20);
            }
            else
            {
                textview.SetPadding(10, 0, 0, 10);
            }
            layout.AddView(textview);
            var scrollviewer = new ScrollView(con);
            var textFrame    = new LinearLayout(con);

            textFrame.Orientation = Android.Widget.Orientation.Vertical;
            scrollviewer.AddView(textFrame);
            scrollviewer.VerticalScrollBarEnabled = true;
            FrameLayout bottomFrame = new FrameLayout(con);

            bottomFrame.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(height));
            bottomFrame.SetBackgroundColor(Color.Silver);
            bottomFrame.AddView(scrollviewer);
            bottomFrame.SetPadding(10, 30, 10, 0);
            layout.AddView(bottomFrame);
            sfpicker.ColumnHeaderText = "COLOR";


            sfpicker.OnSelectionChanged += (sender, e) =>
            {
                eventLog = new TextView(con);
                eventLog.SetTextColor(Color.Black);
                if (textFrame.ChildCount == 6)
                {
                    textFrame.RemoveViewAt(0);
                }

                textFrame.AddView(eventLog);
                eventLog.Text = (e.NewValue).ToString() + " " + "has been Selected";
                Color color = PickerHelper.GetColor(e.NewValue.ToString());
                sfpicker.SetBackgroundColor(color);
                sfpicker.Background.Alpha = 128;
                // scrollviewer.ScrollTo(0, textFrame.Bottom);
            };

            return(layout);
        }
Esempio n. 23
0
        private void SyncLines()
        {
            if (syncing)
            {
                return;
            }
            syncing = true;

            string extra = "";

            try {
                var inflater = table.Context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
                int i        = 0;

                FrameLayout nextRow = null;

                foreach (var period in vm.Periods)
                {
                    // first, remove all next rows that are not Period Rows
                    extra = "remove";
                    while (i < table.ChildCount)
                    {
                        nextRow = table.GetChildAt(i) as FrameLayout;
                        if (nextRow.Tag == Row)
                        {
                            break;
                        }
                        var value = nextRow.FindViewById <TextView> (Resource.Id.value);
                        if (value != null)
                        {
                            animvalues.Remove(value);
                        }
                        var bar = nextRow.FindViewById <View> (Resource.Id.bar);
                        if (bar != null)
                        {
                            animvalues.Remove(bar);
                        }
                        table.RemoveViewAt(i);
                        nextRow = null;
                    }

                    var periodRow = nextRow;
                    // if no next row, inflate a new one
                    extra = "inflate";
                    if (periodRow == null)
                    {
                        periodRow        = inflater.Inflate(Resource.Layout.PeriodRow, null) as FrameLayout;
                        periodRow.Tag    = Row;
                        periodRow.Click += (object sender, EventArgs e) => {
                            PeriodTap(period);
                        };
                        (periodRow as ViewGroup).SetClipChildren(false);
                        animvalues.Add(periodRow.FindViewById <TextView> (Resource.Id.value));
                        animvalues.Add(periodRow.FindViewById <View> (Resource.Id.bar));
                        table.AddView(periodRow, i);
                    }

                    // sync the row texts
                    extra = "synctext";
                    int screenwidth = table.Context.Resources.DisplayMetrics.WidthPixels;
                    periodRow.FindViewById <View> (Resource.Id.bar).LayoutParameters.Width = (period.BarWidth * screenwidth / JournalDayVM.GoalWidth);
                    periodRow.FindViewById <TextView> (Resource.Id.text).Text  = period.Text;
                    periodRow.FindViewById <TextView> (Resource.Id.value).Text = period.Value;
                    i++;

                    foreach (var line in period.Lines)
                    {
                        nextRow = (i < table.ChildCount) ? table.GetChildAt(i)  as FrameLayout : null;

                        var lineRow = nextRow;
                        if (nextRow != null && nextRow.Tag != Line)
                        {
                            nextRow = null;
                        }

                        if (lineRow != null)
                        {
                            // 05/30/2015: we were getting lots of "settext" exceptions on object null (not sure why). This is the workaround:
                            if (lineRow.FindViewById <TextView> (Resource.Id.text) == null)
                            {
                                lineRow = null;
                            }
                            if (lineRow.FindViewById <TextView> (Resource.Id.value) == null)
                            {
                                lineRow = null;
                            }
                        }

                        // if none to re-use, inflate a new one
                        extra = "inflaterow";
                        if (lineRow == null)
                        {
                            lineRow        = inflater.Inflate(Resource.Layout.LineRow, null) as FrameLayout;
                            lineRow.Tag    = Line;
                            lineRow.Click += (object sender, EventArgs e) => {
                                PeriodTap(period);
                            };
                            (lineRow as ViewGroup).SetClipChildren(false);
                            animvalues.Add(lineRow.FindViewById <TextView> (Resource.Id.value));
                            table.AddView(lineRow, i);
                        }

                        // set the texts
                        extra = "settext";
                        lineRow.FindViewById <TextView> (Resource.Id.text).Text  = line.Text;
                        lineRow.FindViewById <TextView> (Resource.Id.value).Text = line.Value;
                        i++;
                    }

                    // add margin if next row isnt margin
                    extra   = "addmargin";
                    nextRow = (i < table.ChildCount) ? table.GetChildAt(i)  as FrameLayout : null;
                    if (nextRow == null || nextRow.Tag != Space)
                    {
                        var marginview = inflater.Inflate(Resource.Layout.PeriodRowMargin, null) as FrameLayout;
                        marginview.Tag = Space;
                        table.AddView(marginview, i);
                    }
                    i++;
                }

                // remove all subsequent rows
                extra = "removetherest";
                while (i < table.ChildCount)
                {
                    nextRow = table.GetChildAt(i) as FrameLayout;
                    var value = nextRow.FindViewById <TextView> (Resource.Id.value);
                    if (value != null)
                    {
                        animvalues.Remove(value);
                    }
                    var bar = nextRow.FindViewById <TextView> (Resource.Id.bar);
                    if (bar != null)
                    {
                        animvalues.Remove(bar);
                    }
                    table.RemoveViewAt(i);
                }
            } catch (Exception ex) {
                LittleWatson.ReportException(ex, extra);
            }

            syncing = false;
        }
Esempio n. 24
0
        protected void ShowVehicles()
        {
            ShowSpinner(true);

            var vehicleIds = _prefHelper.GetPrefStrings(Constants.PrefKeys.VEHICLES);

            //vehicleIds.Add(vehicleIds[0]);

            RunOnUiThread(() => {
                // Remove previously-rendered vehicle views.
                for (int i = _rootContainer.ChildCount - 1; i >= 0; i--)
                {
                    var childView = _rootContainer.GetChildAt(i);

                    if (childView.Tag != null && childView.Tag.ToString() == "vehicleView")
                    {
                        _rootContainer.RemoveViewAt(i);
                    }
                }

                // Set activity header.
                _yourTeslas.Text       = (vehicleIds.Count == 0) ? "No vehicles found." : "Your Tesla" + (vehicleIds.Count > 1 ? "s" : String.Empty);
                _yourTeslas.Visibility = ViewStates.Visible;
            });

            vehicleIds.ForEach((id) => {
                var name        = _prefHelper.GetPrefString(String.Format(Constants.PrefKeys.VEHICLE_NAME, id));
                var vin         = _prefHelper.GetPrefString(String.Format(Constants.PrefKeys.VEHICLE_VIN, id));
                var model       = vin.Substring(3, 1).ToLowerInvariant();
                var optionCodes = _prefHelper.GetPrefString(String.Format(Constants.PrefKeys.VEHICLE_OPTION_CODES, id));

                // Create new container.
                var vehicleContainer = new LinearLayout(this);
                vehicleContainer.Tag = "vehicleView";
                vehicleContainer.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                vehicleContainer.Orientation      = Orientation.Vertical;
                vehicleContainer.SetForegroundGravity(GravityFlags.CenterHorizontal);
                vehicleContainer.SetPadding(0, 0, 0, 150);

                // Load image.
                var image = new ImageView(this);

                using (var imageBitmap = GetImageBitmapFromUrl($"https://www.tesla.com/configurator/compositor/?model=m{model}&view=STUD_SIDE&size=1000&options={optionCodes}&bkba_opt=1"))
                    using (var croppedBitmap = Bitmap.CreateBitmap(imageBitmap, 0, (int)(imageBitmap.Height * 0.18), imageBitmap.Width, (int)(imageBitmap.Height * 0.55)))
                    {
                        image.SetImageBitmap(croppedBitmap);
                    }

                //image.SetBackgroundColor(Color.LightPink);
                image.SetForegroundGravity(GravityFlags.CenterHorizontal);
                image.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = GravityFlags.CenterHorizontal
                };

                // Show name.
                var nameLabel      = new TextView(this);
                nameLabel.Text     = name;
                nameLabel.Gravity  = GravityFlags.CenterHorizontal;
                nameLabel.TextSize = 23;
                nameLabel.SetTextColor(Color.Black);
                nameLabel.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = GravityFlags.CenterHorizontal
                };

                // Show status spinner until charge state is retrieved.
                var statusSpinner = new ProgressBar(this, null, 0, Resource.Style.Widget_AppCompat_ProgressBar);
                statusSpinner.SetForegroundGravity(GravityFlags.Center);
                statusSpinner.Indeterminate    = true;
                statusSpinner.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
                {
                    Gravity = GravityFlags.CenterHorizontal,
                    Height  = 50,
                    Width   = 50
                };

                vehicleContainer.AddView(nameLabel);
                vehicleContainer.AddView(image);
                vehicleContainer.AddView(statusSpinner);

                RunOnUiThread(() => {
                    _rootContainer.AddView(vehicleContainer);
                });

                Task.Run(async() => {
                    // Get current charge state.
                    var chargeState = await _teslaAPI.GetChargeState(Convert.ToInt64(id));

                    var chargeStatus = "Status: ";

                    if (String.IsNullOrEmpty(chargeState.charging_state))
                    {
                        chargeStatus += "Unknown";
                    }
                    else
                    {
                        chargeStatus += $"{chargeState.charging_state}{System.Environment.NewLine}{chargeState.battery_level}% charged with a range of {chargeState.battery_range} miles.";
                    }

                    var chargeStateLabel = new TextView(this)
                    {
                        Text     = chargeStatus,
                        Gravity  = GravityFlags.CenterHorizontal,
                        TextSize = 16
                    };

                    chargeStateLabel.SetTextColor(Color.DarkGray);
                    chargeStateLabel.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

                    RunOnUiThread(() => {
                        statusSpinner.Visibility = ViewStates.Gone;
                        vehicleContainer.AddView(chargeStateLabel);
                    });
                });
            });

            ShowSpinner(false);
        }
Esempio n. 25
0
            public async void getTripData(View view)
            {
                //TODO use global preference instead
                var numTripsToDisplay = 20;

                var prefs      = Application.Context.GetSharedPreferences("settings", FileCreationMode.Private);
                var prefEditor = prefs.Edit();

                if (!MojioConnectionHelper.isClientLoggedIn())
                {
                    await MojioConnectionHelper.setupMojioConnection(prefs);
                }


                if (firstStart)
                {
                    firstStart = false;
                    Globals.client.PageSize = 500; //Gets 15 results
                    MojioResponse <Results <Trip> > response = await Globals.client.GetAsync <Trip> ();

                    Results <Trip> result = response.Data;

                    //var results = view.FindViewById<TextView> (Resource.Id.tripResults);

                    tripIndex = 0;
                    fuelEcon  = 0.0;


                    tripIndex--;

                    list = new List <TripData> ();
                    //iterate over each trip to create TripData for each existing trip.

                    foreach (Trip trip in result.Data)
                    {
                        try {
                            fuelEcon += (double)trip.FuelEfficiency;
                            tripIndex++;
                            TripData td = new TripData(trip.StartTime, trip.EndTime, trip.MaxSpeed.Value.ToString(), trip.EndLocation.Lat.ToString(), trip.EndLocation.Lng.ToString(),
                                                       trip.FuelEfficiency.ToString(), trip.FuelLevel.ToString(), trip.StartLocation.Lat.ToString(), trip.StartLocation.Lng.ToString());
                            //add new trip to beginning of list, so they are in most recent first order
                            list.Insert(0, td);
                        } catch (Exception e) {
                            Console.WriteLine("Exception:" + e);
                        }
                    }
                }
                prefEditor.PutString("speed", "disabled");

                int i              = 1;
                var firstTrip      = true;
                var tripsDisplayed = 0;
                // programmatically create a view widget for each trip
                LinearLayout linlay = view.FindViewById <LinearLayout> (Resource.Id.linearLayout28);

                // remove all old children
                Console.Write("NUMCHILDREN: " + linlay.ChildCount);

                for (int j = linlay.ChildCount - 1; j >= 0; j--)
                {
                    linlay.RemoveViewAt(j);
                }

                //places all the UI elements
                foreach (TripData td in list)
                {
                    if (tripsDisplayed > numTripsToDisplay)
                    {
                        break;
                    }
                    else
                    {
                        tripsDisplayed++;
                    }

                    // get most recent time
                    if (firstTrip)
                    {
                        lastTime  = td.startDate + " @ " + td.startTime;
                        firstTrip = false;
                    }
                    else
                    {
                        // drive divider first for every one except for first card
                        var space = new Space(Application.Context)
                        {
                            LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 10)
                        };
                        var divider = new LinearLayout(Application.Context)
                        {
                            LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 1)
                        };

                        divider.SetBackgroundColor(Resources.GetColor(17170432));  //darker grey

                        //add divider then space for padding
                        linlay.AddView(divider);
                        linlay.AddView(space);
                    }


                    ImageView mapButton = new ImageView(Application.Context);
                    mapButton.SetImageResource(Resource.Drawable.mapButton);
                    mapButton.SetAdjustViewBounds(true);
                    mapButton.Click += delegate {
                        var tripviewActivity = new Intent(Activity, typeof(tripviewActivity));
                        // Create bundle to send to tripViewActivity
                        Bundle extras = new Bundle();
                        extras.PutString("endlat", (td.endlocationlat));
                        extras.PutString("endlng", (td.endlocationlng));
                        extras.PutString("startlat", (td.startlocationlat));
                        extras.PutString("startlng", (td.startlocationlng));
                        extras.PutString("fuelEfficiency", (td.fuelEfficiency));
                        extras.PutString("fuelLevel", (td.fuelLevel));
                        extras.PutString("startTime", (td.startTime));
                        extras.PutString("startDate", (td.startDate));
                        extras.PutString("maxSpeed", (td.maxSpeed));
                        extras.PutString("endTime", (td.endDateTime));
                        tripviewActivity.PutExtra("extras", extras);
                        StartActivity(tripviewActivity);
                    };
                    linlay.AddView(mapButton);

                    TextView tv = new TextView(Application.Context);
                    tv.Text     = td.startDate + " @ " + td.startTime;
                    tv.TextSize = 30;
                    //tv.Elevation = 4;
                    tv.SetPadding(5, 5, 5, 5);
                    //tv.SetBackgroundColor (Android.Graphics.Color.ParseColor("#BBDEFB"));
                    tv.SetTextColor(Resources.GetColor(Resource.Color.black_text));
                    linlay.AddView(tv);
                    i++;

                    LinearLayout innerll1 = new LinearLayout(Application.Context);
                    innerll1.Orientation = Android.Widget.Orientation.Horizontal;
                    innerll1.Id          = i + 5000;
                    //innerll1.Elevation = 4;
                    innerll1.SetPadding(5, 5, 5, 5);
                    //innerll1.SetBackgroundColor (Android.Graphics.Color.ParseColor("#BBDEFB"));

                    ImageView iv1 = new ImageView(Application.Context);
                    iv1.SetImageResource(Resource.Drawable.stopwatch);
                    iv1.SetMaxHeight(50);
                    iv1.SetColorFilter(Resources.GetColor(Resource.Color.accent));
                    iv1.SetAdjustViewBounds(true);
                    innerll1.AddView(iv1);

                    TextView tv1 = new TextView(Application.Context);
                    tv1.Text     = "   " + td.tripLength;
                    tv1.TextSize = 20;
                    tv1.SetTextColor(Resources.GetColor(Resource.Color.secondary_text));
                    innerll1.AddView(tv1);
                    linlay.AddView(innerll1);

                    LinearLayout innerll2 = new LinearLayout(Application.Context);
                    innerll2.Orientation = Android.Widget.Orientation.Horizontal;
                    //innerll2.Elevation = 4;
                    innerll2.SetPadding(5, 5, 5, 5);
                    //innerll2.SetBackgroundColor (Android.Graphics.Color.ParseColor("#BBDEFB"));

                    ImageView iv2 = new ImageView(Application.Context);
                    iv2.SetImageResource(Resource.Drawable.speedometer);
                    iv2.SetMaxHeight(50);
                    iv2.SetColorFilter(Resources.GetColor(Resource.Color.accent));
                    iv2.SetAdjustViewBounds(true);
                    innerll2.AddView(iv2);

                    TextView tv2 = new TextView(Application.Context);
                    tv2.Text     = "   " + td.maxSpeed;
                    tv2.TextSize = 20;
                    //tv2.Elevation = 4;
                    tv2.SetTextColor(Resources.GetColor(Resource.Color.secondary_text));
                    innerll2.AddView(tv2);
                    linlay.AddView(innerll2);

                    Space spc = new Space(Application.Context);
                    spc.SetMinimumHeight(14);
                    linlay.AddView(spc);
                }

                var fuelEfficiecny = view.FindViewById <TextView> (Resource.Id.fuelUsage);
                var lastTripTime   = view.FindViewById <TextView> (Resource.Id.lastTripTime);
                var fe             = Math.Round((fuelEcon / tripIndex), 1);

                fuelEfficiecny.Text = "   " + fe + " L/100km";
                lastTripTime.Text   = "   " + lastTime;
            }
 internal void TableNameDeleted(int index)
 {
     tableNameList.RemoveViewAt(index);
 }
Esempio n. 27
0
 public void RowDeleted(int index)
 {
     items[index].DeleteView();
     items.RemoveAt(index);
     itemsView.RemoveViewAt(index);
 }
Esempio n. 28
0
 internal void DatabaseRemoved(int index_del)
 {
     contentLayout.RemoveViewAt(index_del);
 }