예제 #1
0
        /// <summary>
        /// Calls the Google Places API to retrieve autofill suggestions
        /// </summary>
        /// <returns>The places.</returns>
        /// <param name="newTextValue">New text value.</param>
        async Task <AutoCompleteResult> GetPlaces(string newTextValue)
        {
            try
            {
                await Task.Delay(500);

                var items = new List <AutoCompletePrediction>
                {
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "高档及以上", ProductName = "脸谱花脸"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "高档及以上", ProductName = "脸谱花旦"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "高档及以上", ProductName = "金标纯生"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "高档及以上", ProductName = "概念纯生"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档及中档高", ProductName = "概念勇闯天涯"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档及中档高", ProductName = "勇闯天涯superX"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档及中档高", ProductName = "勇闯天涯"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档及中档高", ProductName = "干啤"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档低", ProductName = "原汁麦"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档低", ProductName = "自然之美"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "中档低", ProductName = "冰菓野刺梨"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "其他", ProductName = "清爽"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "其他", ProductName = "金威果园菠萝味"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "其他", ProductName = "金威果园橙味"
                    },
                    new AutoCompletePrediction {
                        Brand = "雪花", Grade = "其他", ProductName = "金威果园酸梅汤"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "鸿运当头"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "奥古特"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "汉斯红狼"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "黑啤"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "纯生"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "高档及以上", ProductName = "纯生"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "全麦白啤"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "汉斯纯生"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "经典"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "1903"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "冰醇"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档及中档高", ProductName = "9度"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档低", ProductName = "汉斯醉美"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "中档低", ProductName = "9度"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "其他", ProductName = "汉斯干啤"
                    },
                    new AutoCompletePrediction {
                        Brand = "青岛", Grade = "其他", ProductName = "汉斯小木屋"
                    },
                    new AutoCompletePrediction {
                        Brand = "百威", Grade = "高档及以上", ProductName = "红百威"
                    },
                    new AutoCompletePrediction {
                        Brand = "百威", Grade = "高档及以上", ProductName = "百威大瓶"
                    },
                    new AutoCompletePrediction {
                        Brand = "百威", Grade = "中档及中档高", ProductName = "哈啤小麦王"
                    },
                    new AutoCompletePrediction {
                        Brand = "百威", Grade = "中档及中档高", ProductName = "哈啤冰纯"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "高档及以上", ProductName = "红乌苏"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "高档及以上", ProductName = "绿乌苏"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "其他", ProductName = "蓝马果乐"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "其他", ProductName = "蓝马野刺梨"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "其他", ProductName = "蓝马小橙橙"
                    },
                    new AutoCompletePrediction {
                        Brand = "其它", Grade = "其他", ProductName = "蓝马酸梅汤"
                    }
                };

                //Detalls

                items.ForEach(p =>
                {
                    p.Detalls = $"{p.Brand},{p.Grade}";
                });

                var tempItem = items;
                tempItem = tempItem.Where(p => p.ProductName.StartsWith(newTextValue) || p.Grade.StartsWith(newTextValue) || p.Brand.StartsWith(newTextValue)).ToList();
                if (tempItem.Count == 0)
                {
                    tempItem = items;
                }

                var result = new AutoCompleteResult()
                {
                    Status = "", AutoCompletePlaces = tempItem
                };

                //JsonConvert.DeserializeObject<AutoCompleteResult>(result);

                return(result);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("PlacesBar HTTP issue: {0} {1}", ex.Message, ex);
                return(null);
            }
        }
예제 #2
0
        protected virtual void OnPlacesRetrieved(AutoCompleteResult e)
        {
            PlacesRetrievedEventHandler handler = PlacesRetrieved;

            handler?.Invoke(this, e);
        }