Exemplo n.º 1
0
        private void LvListings_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            // User clicked on an item so grab id an pass to the detail page
            ListListing ll = ListingsForList[Convert.ToInt32(e.Id)];

            ConfigureDetailsLayout(ll.Id);
        }
Exemplo n.º 2
0
        public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
        {
            if (convertView == null)
            {
                convertView = _activity.LayoutInflater.Inflate(Resource.Layout.list_item, parent, false);
            }

            ListListing listing = _listings[position];

            AQuery aq = new AQuery(convertView);

            TextView txtProductName = convertView.FindViewById <TextView>(Resource.Id.txtProductName);

            txtProductName.Text = listing.MainText;

            TextView txtSubText = convertView.FindViewById <TextView>(Resource.Id.txtSubText);

            txtSubText.Text = listing.SubText;


            Bitmap imgLoading = aq.GetCachedImage(Resource.Drawable.img_loading);

            if (aq.ShouldDelay(position, convertView, parent, listing.ImageUrl))
            {
                ((AQuery)aq.Id(Resource.Id.imgProduct)).Image(imgLoading, 0.75f);
            }
            else
            {
                ((AQuery)aq.Id(Resource.Id.imgProduct)).Image(listing.ImageUrl, true, true, 0, 0, imgLoading, 0, 0.75f);
            }

            return(convertView);
        }
Exemplo n.º 3
0
        private int ExecListingsSearch(string q = null, bool countOnly = false)
        {
            // Execute a search using the supplied text and apply the results to a new listings list page
            string url = _serviceUri + AzureSearchUrl + "*";

            if (q != "")
            {
                url = _serviceUri + AzureSearchUrl + q;
            }

            // Append the count request
            url += "&$count=true";
            url += "&$top=10";

            // Set the page
            url += "&$skip=" + currentPage * 10;

            // Append the filter
            url += "&$filter=beds ge " + filterMinBeds + " and beds le " + filterMaxBeds +
                   " and baths ge " + filterMinBaths + " and baths le " + filterMaxBaths;

            // Determing the status filter
            string statusFilter = string.Empty;

            if ((filterShowForSale) && (filterShowPending) && (filterShowSold))
            {
                statusFilter = " and (status eq 'active' or status eq 'pending' or status eq 'sold')";
            }
            else if (!(filterShowForSale) && (filterShowPending) && (filterShowSold))
            {
                statusFilter = " and (status eq 'pending' or status eq 'sold')";
            }
            else if ((filterShowForSale) && !(filterShowPending) && (filterShowSold))
            {
                statusFilter = " and (status eq 'active' or status eq 'sold')";
            }
            else if ((filterShowForSale) && (filterShowPending) && !(filterShowSold))
            {
                statusFilter = " and (status eq 'active' or status eq 'pending')";
            }
            else if ((filterShowForSale) && !(filterShowPending) && !(filterShowSold))
            {
                statusFilter = " and (status eq 'active')";
            }
            else if (!(filterShowForSale) && !(filterShowPending) && (filterShowSold))
            {
                statusFilter = " and (status eq 'sold')";
            }
            else if (!(filterShowForSale) && (filterShowPending) && !(filterShowSold))
            {
                statusFilter = " and (status eq 'pending')";
            }
            else
            {
                statusFilter = " and status eq 'noresults'";
            }
            url += statusFilter;

            Uri uri = new Uri(url);
            HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);

            AzureSearchHelper.EnsureSuccessfulSearchResponse(response);
            dynamic result = AzureSearchHelper.DeserializeJson <dynamic>(response.Content.ReadAsStringAsync().Result);

            JObject jsonObj = JObject.Parse(result.ToString());

            if (countOnly == false)
            {
                ListingsForList = new List <ListListing>();;

                foreach (var item in jsonObj["value"])
                {
                    ListListing ll = new ListListing();
                    ll.ImageUrl = item["thumbnail"].ToString();
                    string price = "$" + Convert.ToInt32(item["price"].ToString()).ToString("#,##0");
                    ll.MainText = price + " Beds: " + item["beds"].ToString() +
                                  " Baths: " + item["baths"].ToString() +
                                  " Sq Ft.: " + Convert.ToInt32(item["sqft"].ToString()).ToString("#,##0");

                    ll.Id = item["listingId"].ToString();
                    // build up the address
                    string address = string.Empty;
                    if (item["number"] != null)
                    {
                        address += item["number"].ToString() + " ";
                    }
                    if (item["street"] != null)
                    {
                        address += item["street"].ToString() + " ";
                    }
                    if (item["city"] != null)
                    {
                        address += item["city"].ToString() + " ";
                    }
                    if (item["region"] != null)
                    {
                        address += item["region"].ToString() + " ";
                    }

                    ll.SubText = address;
                    ListingsForList.Add(ll);
                }

                // Default to the listings list for search results
                ConfigureListingsLayout();
            }

            int docCount = Convert.ToInt32(jsonObj["@odata.count"].ToString());

            // Update the seek bar with the paging
            maxPage = Convert.ToInt32(docCount / 10) + 1;

            if (countOnly == false)
            {
                SeekBar seekBar = FindViewById <SeekBar>(Resource.Id.seekBarPaging);
                if (maxPage > 20)
                {
                    seekBar.Max = 19;   // Base 0
                }
                else
                {
                    seekBar.Max = maxPage;
                }
            }

            return(Convert.ToInt32(docCount.ToString()));
        }
Exemplo n.º 4
0
        private void ExecMoreLikeThisListingsSearch(string listingIid)
        {
            // Execute a search to find similar listings to the one currently being viewed
            string url = _serviceUri + AzureSearchUrl + "&morelikethis=" + listingIid;

            url += "&$top=1";

            // Only do comparison over a few fields
            url += "&searchFields=description,city,region";

            Uri uri = new Uri(url);
            HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);

            AzureSearchHelper.EnsureSuccessfulSearchResponse(response);
            dynamic result = AzureSearchHelper.DeserializeJson <dynamic>(response.Content.ReadAsStringAsync().Result);

            JObject jsonObj = JObject.Parse(result.ToString());

            ListingsSimilarForDetails = new List <ListListing>();;

            foreach (var item in jsonObj["value"])
            {
                ListListing ll = new ListListing();
                ll.ImageUrl = item["thumbnail"].ToString();
                string price = "$" + Convert.ToInt32(item["price"].ToString()).ToString("#,##0");
                ll.MainText = price + " Beds: " + item["beds"].ToString() +
                              " Baths: " + item["baths"].ToString() +
                              " Sq Ft.: " + Convert.ToInt32(item["sqft"].ToString()).ToString("#,##0");

                ll.Id = item["listingId"].ToString();
                // build up the address
                string address = string.Empty;
                if (item["number"] != null)
                {
                    address += item["number"].ToString() + " ";
                }
                if (item["street"] != null)
                {
                    address += item["street"].ToString() + " ";
                }
                if (item["city"] != null)
                {
                    address += item["city"].ToString() + " ";
                }
                if (item["region"] != null)
                {
                    address += item["region"].ToString() + " ";
                }

                ll.SubText = address;
                ListingsSimilarForDetails.Add(ll);
            }

            // Default to the listings list for search results
            ListView lvListingsSimilar = FindViewById <ListView>(Resource.Id.lvListingsSimilar);

            lvListingsSimilar.Adapter    = new LoadListings(this, ListingsSimilarForDetails);
            lvListingsSimilar.ItemClick += LvListingsSimilar_ItemClick;

            return;
        }