예제 #1
0
        public static PropertyDetail NewInstance()
        {
            var frag1 = new PropertyDetail {
                Arguments = new Bundle()
            };

            return(frag1);
        }
예제 #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.searchPage, container, false);

            city       = v.FindViewById <EditText>(Resource.Id.getCity);
            search     = v.FindViewById <Button>(Resource.Id.bSearch);
            jsonViewer = v.FindViewById <TextView>(Resource.Id.textView1);
            mainLayout = v.FindViewById <LinearLayout>(Resource.Id.searchLayout);
            // Gets all the elements on the page

            search.Click += async delegate
            {
                string    url  = "http://housechecker.co.uk/api/export_property.php";
                JsonValue json = await FetchUserAsync(url);

                // Gets all the properties in the database

                string jsonString  = json.ToString();
                var    addressList = JsonConvert.DeserializeObject <List <Address> >(jsonString);
                // Creates a list of addresses from the JSON string through parsing

                foreach (var address in addressList)
                {
                    // Goes through each accomodation to see if the city matches the city searched for
                    if (address.city.ToUpper().Equals(city.Text.ToUpper()))
                    {
                        LinearLayout newLayout = new LinearLayout(this.Context);
                        newLayout.Orientation = Orientation.Vertical;
                        ImageView imageView = new ImageView(this.Context);
                        imageView.SetPadding(0, 100, 0, 0);
                        // Creates a new layout to store a single entry in the search results

                        try
                        {
                            string imageURL = address.image.Remove(0, 2);
                            imageURL = "http://housechecker.co.uk" + imageURL;
                            WebRequest request = WebRequest.Create(imageURL);
                            // Creates the image URL based from what is stored in the database
                            WebResponse resp       = request.GetResponse();
                            Stream      respStream = resp.GetResponseStream();
                            Bitmap      bmp        = BitmapFactory.DecodeStream(respStream);
                            Bitmap      image      = Bitmap.CreateScaledBitmap(bmp, 500, 500, false);
                            // Resizes the image to fit
                            respStream.Dispose();
                            imageView.SetImageBitmap(image);
                            imageView.RefreshDrawableState();
                            // Creates it and sets it to the view
                        }
                        catch (Exception e)
                        {
                            imageView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.propertyStock));
                        }

                        TextView displayAddress = new TextView(this.Context);
                        displayAddress.Text     = (address.address1 + " , " + address.address2);
                        displayAddress.Typeface = Typeface.DefaultBold;
                        displayAddress.TextSize = 16;
                        displayAddress.Gravity  = GravityFlags.Center;
                        // Creates and formats a text field to display the address for the property

                        displayAddress.Click += async delegate
                        {
                            await CrossTextToSpeech.Current.Speak(displayAddress.Text);
                        };
                        // Using a plugin this reads out the text that is clicked on, in this case the address

                        imageView.Click += (senderNew, eNew) =>
                        {
                            FragmentTransaction fragmentTx     = FragmentManager.BeginTransaction();
                            PropertyDetail      propertyDetail = new PropertyDetail();
                            Bundle bundle = new Bundle();
                            bundle.PutString("accomID", address.id.ToString());
                            propertyDetail.Arguments = bundle;
                            fragmentTx.Replace(Resource.Id.content_frame, propertyDetail);
                            fragmentTx.Commit();
                            // Creates a click event function for the image so it will go to the selected property
                        };

                        newLayout.AddView(imageView);
                        newLayout.AddView(displayAddress);
                        mainLayout.AddView(newLayout);
                        // Adding the views to the main Layout
                    }
                }
            };

            return(v);
        }
예제 #3
0
        //Creates the main attributes of the page when it is loaded
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.myProperties, container, false);

            mainLayout = v.FindViewById <LinearLayout>(Resource.Id.mainLayout);
            Button displayProperties = v.FindViewById <Button>(Resource.Id.showProperty);

            id = int.Parse(ap.getAccessKey());

            displayProperties.Click += async delegate
            {
                string    url  = "http://housechecker.co.uk/api/export_property.php";
                JsonValue json = await FetchUserAsync(url);

                string jsonString = json.ToString();
                //Getting the properties from the database and putting it into the list
                propertyList = JsonConvert.DeserializeObject <List <Address> >(jsonString);
                //Getting each property for the current landlord
                foreach (var accomodation in propertyList.Where(a => a.user_id.Equals(id)))
                {
                    //Creating the layout for the properties
                    LinearLayout newLayout = new LinearLayout(this.Context);
                    newLayout.Orientation = Orientation.Vertical;
                    TextView displayAddress = new TextView(this.Context);
                    displayAddress.Text = "Address: " + accomodation.address1 + ", " + accomodation.address2 + "\nCity: " +
                                          accomodation.city + "\nPostcode " + accomodation.postcode;
                    displayAddress.Typeface = Typeface.DefaultBold;
                    displayAddress.TextSize = 16;
                    displayAddress.Gravity  = GravityFlags.Center;

                    //Button to allow for more informaiton

                    ImageView imageView = new ImageView(this.Context);

                    try
                    {
                        string imageURL = accomodation.image.Remove(0, 2);
                        imageURL = "http://housechecker.co.uk" + imageURL;
                        WebRequest request = WebRequest.Create(imageURL);
                        // Creates the image URL based from what is stored in the database
                        WebResponse resp       = request.GetResponse();
                        Stream      respStream = resp.GetResponseStream();
                        Bitmap      bmp        = BitmapFactory.DecodeStream(respStream);
                        Bitmap      image      = Bitmap.CreateScaledBitmap(bmp, 500, 500, false);
                        // Resizes the image to fit
                        respStream.Dispose();
                        imageView.SetImageBitmap(image);
                        imageView.RefreshDrawableState();
                        // Creates it and sets it to the view
                    }
                    catch (Exception e)
                    {
                        imageView.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.propertyStock));
                    }

                    imageView.Click += (senderNew, eNew) =>
                    {
                        FragmentTransaction fragmentTx     = FragmentManager.BeginTransaction();
                        PropertyDetail      propertyDetail = new PropertyDetail();
                        Bundle bundle = new Bundle();
                        bundle.PutString("accomID", accomodation.id.ToString());
                        propertyDetail.Arguments = bundle;
                        fragmentTx.Replace(Resource.Id.content_frame, propertyDetail);
                        fragmentTx.Commit();
                        // Creates a click event function for the image so it will go to the selected property
                    };

                    newLayout.AddView(imageView);
                    newLayout.AddView(displayAddress);
                    mainLayout.AddView(newLayout);
                }
            };
            displayProperties.CallOnClick();
            return(v);
        }