Exemple #1
0
 public SelectCityView(Context context) :
     base(context)
 {
     this.context = context;
     rowHeight    = PixelConverter.DpToPixels(context.Resources.GetInteger(Resource.Integer.textLabelRowHeight));
     Initialize();
 }
        View AddCategoryRow(KeyValuePair <object, object> option)
        {
            var row = new LinearLayout(_context);

            row.Orientation      = Orientation.Horizontal;
            row.LayoutParameters = rowParams;

            var text = new TextView(_context);

            text.Text = (string)option.Key;
            text.SetPadding(PixelConverter.DpToPixels(20), 0, 0, 0);
            text.LayoutParameters = textParams;
            text.Gravity          = GravityFlags.CenterVertical;

            row.Click += (object sender, EventArgs e) =>
            {
                if (this.CatPicked != null)
                {
                    this.CatPicked(this, new SubCatSelectedEventArgs {
                        SubCatPicked = option
                    });
                }
            };

            row.AddView(text);
            return(row);
        }
Exemple #3
0
 public SavedSearchRow(Context context)
     : base(context)
 {
     _context  = context;
     rowHeight = PixelConverter.DpToPixels(context.Resources.GetInteger(Resource.Integer.textLabelRowHeight));
     Initialize();
 }
        public void OnLoaded(ImageView p0, Bitmap p1, string p2, bool p3)
        {
            _image = imageView.Drawable;
            _image.SetBounds(0, 0, _image.IntrinsicWidth, _image.IntrinsicHeight);
            _scaleDetector = new ScaleGestureDetector(_context, new MyScaleListener(this));

            var metrics = Resources.DisplayMetrics;

            _posX = GetCornerPosition(PixelConverter.PixelsToDp(metrics.WidthPixels), _image.Bounds.Width()) * (int)_scaleFactor;
            _posY = GetCornerPosition(PixelConverter.PixelsToDp(metrics.HeightPixels), _image.Bounds.Height());
        }
Exemple #5
0
        public SearchOptionsView(Context context, Location location, KeyValuePair <string, string> category)
            : base(context)
        {
            this.context  = context;
            this.location = location;
            this.category = category;

            SearchItems = new Dictionary <string, string>();
            Conditions  = new Dictionary <object, KeyValuePair <object, object> >();

            rowHeight = PixelConverter.DpToPixels(context.Resources.GetInteger(Resource.Integer.textLabelRowHeight));

            Initialize();
        }
        void Initialize()
        {
            var padding = PixelConverter.DpToPixels(8);

            SetPadding(padding, padding, padding, 0);

            CardView card = new CardView(_context);

            card.LayoutParameters = new CardView.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            card.SetForegroundGravity(GravityFlags.CenterHorizontal);
            card.Radius        = PixelConverter.DpToPixels(6);
            card.CardElevation = PixelConverter.DpToPixels(4);
            card.SetCardBackgroundColor(Resource.Color.accent);

            LinearLayout layoutHolder = new LinearLayout(_context);

            layoutHolder.Orientation      = Orientation.Vertical;
            layoutHolder.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            layoutHolder.SetPadding(padding, padding, padding, padding);
            layoutHolder.SetBackgroundResource(Resource.Color.accent);

            TextView titleDisplay = new TextView(_context)
            {
                Text = _ack.Title
            };

            titleDisplay.Gravity          = GravityFlags.CenterVertical;
            titleDisplay.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            titleDisplay.SetTextSize(ComplexUnitType.Dip, 20);
            titleDisplay.SetTypeface(Android.Graphics.Typeface.DefaultBold, Android.Graphics.TypefaceStyle.Bold);
            titleDisplay.SetTextColor(Android.Graphics.Color.AntiqueWhite);
            layoutHolder.AddView(titleDisplay);

            TextView descriptionDisplay = new TextView(_context)
            {
                Text = _ack.Description
            };

            descriptionDisplay.Gravity          = GravityFlags.CenterVertical;
            descriptionDisplay.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            descriptionDisplay.SetTextSize(ComplexUnitType.Dip, 14);
            descriptionDisplay.SetTypeface(Android.Graphics.Typeface.Default, Android.Graphics.TypefaceStyle.Normal);
            descriptionDisplay.SetTextColor(Android.Graphics.Color.AntiqueWhite);
            layoutHolder.AddView(descriptionDisplay);

            card.AddView(layoutHolder);
            AddView(card);
        }
Exemple #7
0
        void Initialize()
        {
            this.Orientation = Orientation.Vertical;
            this.WeightSum   = 1;

            var padding = PixelConverter.DpToPixels(5);

            SetPadding(padding, padding, padding, padding);

            //Event handler is detached in proceed button handler. Very important!
            ((MainActivity)(this.context)).OptionItemSelected += OnOptionItemSelected;

            SearchCityText = new TextView(context);
            SearchCityText.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            SearchCityText.Text             = string.Format("Search {0} for: ", location.SiteName);
            SearchCityText.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.50f);
            SearchCityText.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));

            LinearLayout searchCityHolder = RowHolder();

            searchCityHolder.AddView(SearchCityText);
            AddView(searchCityHolder);

            proceedButton = new Button(context);
            proceedButton.LayoutParameters = new LayoutParams(0, LayoutParams.WrapContent, 0.5f);
            proceedButton.Text             = "Search";
            proceedButton.SetTextSize(ComplexUnitType.Px, rowHeight * 0.5f);
            proceedButton.SetBackgroundResource(Resource.Drawable.roundedButton);
            proceedButton.SetTextColor(context.Resources.GetColor(Resource.Color.lightTextColor));

            LinearLayout buttonLayout = RowHolder();

            buttonLayout.AddView(proceedButton);
            AddView(buttonLayout);

            var tableItems = GetTableSetup();

            foreach (var item in tableItems)
            {
                AddRowToLayout(item);
            }

            proceedButton.Click += ProceedButton_Click;
        }
        void Initialize(KeyValuePair <object, object> title, bool selectedAlready)
        {
            this.Orientation      = Orientation.Horizontal;
            this.WeightSum        = 1;
            this.LayoutParameters = new ListView.LayoutParams(LayoutParams.MatchParent, PixelConverter.DpToPixels(40));

            var text = new TextView(_context)
            {
                Text = (string)title.Key
            };

            text.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
            text.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);

            AddView(text);

            var checkBoxPlacer = new LinearLayout(_context);

            checkBoxPlacer.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            checkBoxPlacer.SetHorizontalGravity(GravityFlags.Right);

            var checkbox = new CheckBox(_context);

            if (selectedAlready)
            {
                checkbox.Checked = true;
            }

            checkbox.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);
            checkbox.SetPadding(0, 0, PixelConverter.DpToPixels(15), 0);
            checkBoxPlacer.AddView(checkbox);

            checkbox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
            {
                Console.WriteLine(e.IsChecked);
                if (ItemSelected != null)
                {
                    ItemSelected(this, e);
                }
            };

            AddView(checkBoxPlacer);
        }
        public void SetImageCollection(List <string> images)
        {
            int index = 0;

            foreach (var image in images)
            {
                ImageView imgView = new ImageView(_context);
                Koush.UrlImageViewHelper.SetUrlDrawable(imgView, image, Resource.Drawable.placeholder);
                imgView.LayoutParameters = new ViewGroup.LayoutParams(
                    Convert.ToInt16(_context.Resources.DisplayMetrics.HeightPixels * 0.1),
                    Convert.ToInt16(_context.Resources.DisplayMetrics.HeightPixels * 0.1)
                    );

                int current = index;
                imgView.Click += (sender, e) =>
                {
                    if (ImageClick != null)
                    {
                        ImageClick(this, new ImageCollectionClickEventArgs {
                            Index = current
                        });
                    }
                };

                imgView.SetScaleType(ImageView.ScaleType.CenterCrop);

                ImageCollectionHolder.AddView(imgView);

                LinearLayout imagePadding = new LinearLayout(_context);
                imagePadding.LayoutParameters = new ViewGroup.LayoutParams(PixelConverter.DpToPixels(5), LayoutParams.MatchParent);

                ImageCollectionHolder.AddView(imagePadding);

                index++;
            }
        }
Exemple #10
0
        void AddRowToLayout(SearchRow item)
        {
            var row = new LinearLayout(context)
            {
                Orientation = Orientation.Horizontal
            };

            row.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            row.WeightSum        = 1;

            row.SetMinimumHeight(PixelConverter.DpToPixels(30));

            LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, 0.5f);
            LinearLayout.LayoutParams f = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            var entryHolder             = new LinearLayout(context);

            entryHolder.Orientation = Orientation.Horizontal;
            entryHolder.SetHorizontalGravity(GravityFlags.Right);
            entryHolder.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            entryHolder.ShowDividers     = ShowDividers.Middle;
            entryHolder.DividerPadding   = 20;
            entryHolder.SetPadding(PixelConverter.DpToPixels(10), 0, 0, 0);

            switch (item.RowType)
            {
            case SearchRowTypes.Heading:
                row.AddView(Heading(item));

                break;

            case SearchRowTypes.SearchTerms:
                EditText searchfield = new EditText(context);
                searchfield.LayoutParameters = f;
                searchfield.Hint             = string.Format("Search {0}:", this.category.Value);
                searchfield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                searchfield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                searchfield.SetSingleLine(true);
                searchfield.InputType = InputTypes.ClassText;
                row.AddView(searchfield);

                searchfield.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    AddSearchItem(item.QueryPrefix, e.Text.ToString());
                };

                break;

            case SearchRowTypes.PriceDoubleEntry:
                row.AddView(Title(item));

                EditText minPricefield = new EditText(context);
                minPricefield.LayoutParameters = p;
                minPricefield.Hint             = "min";
                minPricefield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                minPricefield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                minPricefield.SetSingleLine(true);
                minPricefield.InputType = InputTypes.ClassNumber;
                entryHolder.AddView(minPricefield);

                EditText maxPricefield = new EditText(context);
                maxPricefield.LayoutParameters = p;
                maxPricefield.Hint             = "max";
                maxPricefield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                maxPricefield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                maxPricefield.SetSingleLine(true);
                maxPricefield.InputType = InputTypes.ClassNumber;
                entryHolder.AddView(maxPricefield);

                minPricefield.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    //TODO: Get this text masking to work correctly
                    //string text = minPricefield.Text;
                    //if (text.Length > 0 && text.Substring(0, 1) == "$")
                    //    minPricefield.Text = text;
                    //else
                    //    minPricefield.Text = "$" + text;

                    AddSearchItem(item.QueryPrefix, e.Text.ToString());
                };

                maxPricefield.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    //string text = maxPricefield.Text;
                    //if (text.Length > 0 && text.Substring(0, 1) == "$")
                    //    maxPricefield.SetText(text, null);
                    //else
                    //    maxPricefield.Text = "$" + text;

                    AddSearchItem(item.SecondQueryPrefix, e.Text.ToString());
                };

                row.AddView(entryHolder);
                break;

            case SearchRowTypes.DoubleEntry:
                row.AddView(Title(item));

                EditText minfield = new EditText(context);
                minfield.LayoutParameters = p;

                minfield.Hint = "min";
                minfield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                minfield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                minfield.SetSingleLine(true);
                minfield.InputType = InputTypes.ClassNumber;
                entryHolder.AddView(minfield);

                EditText maxfield = new EditText(context);
                maxfield.LayoutParameters = p;
                maxfield.Hint             = "max";
                maxfield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                maxfield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                maxfield.SetSingleLine(true);
                maxfield.InputType = InputTypes.ClassNumber;
                entryHolder.AddView(maxfield);

                minfield.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    AddSearchItem(item.QueryPrefix, e.Text.ToString());
                };

                maxfield.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    AddSearchItem(item.SecondQueryPrefix, e.Text.ToString());
                };

                row.AddView(entryHolder);

                break;

            case SearchRowTypes.SingleEntryLabel:
                row.AddView(Title(item));

                EditText inputField = new EditText(context);
                inputField.LayoutParameters = f;

                inputField.Hint = "make / model";
                inputField.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                inputField.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                inputField.SetSingleLine(true);
                entryHolder.AddView(inputField);

                inputField.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    AddSearchItem(item.QueryPrefix, e.Text.ToString());
                };

                row.AddView(entryHolder);
                break;

            case SearchRowTypes.SinglePicker:
                row.AddView(Title(item));

                TextView display = new TextView(context);
                display.LayoutParameters = f;
                display.Gravity          = GravityFlags.Right;
                display.Text             = "Any";
                display.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                display.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), PixelConverter.DpToPixels(50), (int)(rowHeight * 0.15));

                var dialog = new NumberPickerDialogFragment(context, item.Title, item.NumberPickerOptions, item.QueryPrefix);
                display.Click += (object sender, EventArgs e) =>
                {
                    dialog.Show(((Activity)context).FragmentManager, "number");
                };

                dialog.NumberChanged += (object sender, NumberPickerDialogFragment.NumberPickerValueChanged e) =>
                {
                    display.Text = e.Value.ToString() + item.NumberPickerOptions.DisplaySuffix;
                    AddSearchItem(e.CallerKey, e.Value.ToString());
                };

                row.AddView(display);

                break;

            case SearchRowTypes.ComboPicker:
                row.AddView(Title(item));

                TextView comboLabel = new TextView(context);
                comboLabel.LayoutParameters = f;
                comboLabel.Gravity          = GravityFlags.Right;
                comboLabel.Text             = "Any";
                comboLabel.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                comboLabel.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), PixelConverter.DpToPixels(50), (int)(rowHeight * 0.15));

                var comboDialog = new ComboPickerDialogFragment(context, item.Title, item.ComboPickerOptions);

                comboLabel.Click += (object sender, EventArgs e) =>
                {
                    var selectedKeys = (from kvp in Conditions where (string)kvp.Value.Key == item.QueryPrefix select(string) kvp.Key).ToList();
                    comboDialog._selectedKeys = selectedKeys;
                    comboDialog.Show(((Activity)context).FragmentManager, "combo");
                };

                comboDialog.ItemChanged += (object sender, ComboPickerItemChangedEventArgs e) =>
                {
                    if (e.InitialArgs.IsChecked)
                    {
                        Conditions.Add(e.Item.Key, new KeyValuePair <object, object>(item.QueryPrefix, e.Item.Value));
                        Console.WriteLine("Added Key: " + e.Item.Key + ", Value: " + e.Item.Value + " with prefix: " + item.QueryPrefix);
                    }
                    else
                    {
                        Conditions.Remove(e.Item.Key);
                        Console.WriteLine("Removed Key: " + e.Item.Key + ", Value: " + e.Item.Value);
                    }

                    var keys = (from kvp in Conditions where (string)kvp.Value.Key == item.QueryPrefix select(string) kvp.Key).ToList();
                    var text = keys.Count > 0 ? string.Join(", ", keys.ToArray()) : "Any";
                    comboLabel.Text = text;
                };

                row.AddView(comboLabel);

                break;

            case SearchRowTypes.SubCatPicker:
                row.AddView(Title(item));

                TextView catLabel = new TextView(context);
                catLabel.LayoutParameters = f;
                catLabel.Gravity          = GravityFlags.Right;
                catLabel.Text             = (string)item.ComboPickerOptions.First().Key;

                catLabel.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                catLabel.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), PixelConverter.DpToPixels(50), (int)(rowHeight * 0.15));

                if (item.Title == "Sub Category")
                {
                    SubCategory = item.ComboPickerOptions.First();
                }

                var categoryDialog = new SingleStringDialogFragment(context, item.Title, item.ComboPickerOptions);

                catLabel.Click += (object sender, EventArgs e) =>
                {
                    categoryDialog.Show(((Activity)context).FragmentManager, "stringPick");
                };

                categoryDialog.CatPicked += (object sender, SubCatSelectedEventArgs e) =>
                {
                    categoryDialog.Dismiss();

                    if (item.Title != "Posted Date" && item.Title != "Max Listings")
                    {
                        SubCategory = e.SubCatPicked;
                    }
                    else if (item.Title == "Posted Date")
                    {
                        WeeksOld = (int?)e.SubCatPicked.Value;
                    }
                    else if (item.Title == "Max Listings")
                    {
                        MaxListings = (int)e.SubCatPicked.Value;
                    }

                    catLabel.Text = (string)e.SubCatPicked.Key;
                };

                row.AddView(catLabel);
                break;

            case SearchRowTypes.Space:
                View strut = new View(context);
                strut.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                                    PixelConverter.DpToPixels(25));
                row.ShowDividers = ShowDividers.None;
                row.AddView(strut);
                break;

            default:
                row.AddView(Title(item));

                break;
            }

            AddView(row);
        }
        void Initialize()
        {
            Orientation = Orientation.Vertical;
            WeightSum   = 1;

            PostingTitle = new TextView(_context)
            {
                LayoutParameters = rowParams
            };
            PostingTitle.SetTextSize(Android.Util.ComplexUnitType.Dip, 18);
            PostingTitle.SetPadding(10, 10, 10, 10);
            PostingTitle.SetTypeface(Typeface.DefaultBold, TypefaceStyle.Bold);
            AddRowItem(PostingTitle, rowParams);

            PostingImage = new ImageView(_context);// { LayoutParameters = rowParams };
            PostingImage.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent,
                                                                       Convert.ToInt16(_context.Resources.DisplayMetrics.HeightPixels * 0.4));
            AddRowItem(PostingImage, rowParams);

            LinearLayout spacing = new LinearLayout(_context);

            spacing.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, PixelConverter.DpToPixels(5));

            AddView(spacing);

            ImageCollectionHolder = new LinearLayout(_context)
            {
                Orientation = Orientation.Horizontal
            };
            ImageCollectionHolder.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            ImageCollectionHolder.Clickable        = false;
            HorizontalScrollView scrollView = new HorizontalScrollView(_context);

            scrollView.AddView(ImageCollectionHolder);
            scrollView.Clickable = false;
            AddView(scrollView);

            PostingDescription = new TextView(_context)
            {
                LayoutParameters = rowParams
            };
            PostingDescription.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);
            PostingDescription.SetPadding(10, 10, 10, 10);
            PostingDescription.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
            AddRowItem(PostingDescription, rowParams);

            mapFrame    = new FrameLayout(_context);
            mapFrame.Id = 12345;
            AddView(mapFrame);

            PostingDate = new TextView(_context)
            {
                LayoutParameters = rowParams
            };
            PostingDate.SetPadding(10, 10, 10, 10);
            PostingDate.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);
            AddRowItem(PostingDate, rowParams);

            WebLink = new TextView(_context)
            {
                LayoutParameters = rowParams
            };
            WebLink.SetPadding(10, 10, 10, 10);
            WebLink.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);
            AddRowItem(WebLink, rowParams);
        }
Exemple #12
0
 public RecentCityAdapter(Context context, List <RecentCity> recentCities)
 {
     _context      = context;
     _recentCities = recentCities;
     rowHeight     = PixelConverter.DpToPixels(_context.Resources.GetInteger(Resource.Integer.textLabelRowHeight));
 }
 public SingleStringDialogFragment(Context context, string title, List <KeyValuePair <object, object> > options)
 {
     _context   = context;
     _title     = title;
     _options   = options;
     rowParams  = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, PixelConverter.DpToPixels(40));
     textParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
 }