示例#1
0
 public PropertyTableSource(List <Property> properties)
 {
     propertyCollection = properties;
     // propertyManager = new PropertyMangager();
     //propertyManager = TinyIoC.TinyIoCContainer.Current.Resolve<IPropertyMangager>();
     propertyManager = Mvx.GetSingleton <IPropertyMangager>();
 }
        /// <summary>
        /// Download the image from the url and save it to local storage for reuse
        /// </summary>
        /// <param name="propertyManager"></param>
        /// <param name="listingID"></param>
        /// <param name="imageName"></param>
        /// <param name="downloadedImageView"></param>
        /// <param name="isOrignal"></param>
        public static void SetImage(IPropertyMangager propertyManager, int listingID, string imageName, UIImageView downloadedImageView, int isOrignal = 50)
        {
            byte[] imageBytes = null;
            //imageBytes = propertyManager.GetImageAsync(propertyitem.Image).Result
            if (!urlToImageMap.ContainsKey(listingID))
            {
                string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                string localFilename = listingID + ".jpg";
                string localPath     = System.IO.Path.Combine(documentsPath, localFilename);
                if (!File.Exists(localPath))
                {
                    Task.Run(async() =>
                    {
                        imageBytes = await propertyManager.GetImageAsync(imageName);
                    }
                             ).ConfigureAwait(false).GetAwaiter().GetResult();

                    File.WriteAllBytes(localPath, imageBytes); // writes to local storage
                }

                downloadedImageView.Image = UIImage.FromFile(localPath);
                urlToImageMap.Add(listingID, localPath);
            }
            else
            {
                downloadedImageView.Image = UIImage.FromFile(urlToImageMap[listingID]);
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            propertyManager = new PropertyMangager();
            if (currentPropertyId > 0)
            {
                propertyDetail = propertyManager.GetItemAsync(currentPropertyId.ToString()).Result;

                byte[] imageBytes = null;
                imageBytes = propertyManager.GetImageAsync(propertyDetail.Image).Result;

                //ImageHelper.SetImage(imageBytes, propertyDetail.ListingID, PropertyImage, 150);
                ImageHelper.SetImage(propertyManager, propertyDetail.ListingID, propertyDetail.Image, PropertyImage);

                AddressLabel.Text        = propertyDetail.Address;
                BedsLabel.Text           = string.Format("Beds: {0}", propertyDetail.Beds);
                BathsLabel.Text          = string.Format(", Baths: {0}", propertyDetail.Baths);
                EstimatedValueLabel.Text = string.Format(", {0:C}, ", propertyDetail.EstimatedValue);
                RateChangeLabel.Text     = string.Format("{0}%", Convert.ToString(propertyDetail.ChangeOverLastYear));
                FeatureText.Text         = propertyDetail.Features;
                if (Convert.ToDouble(propertyDetail.ChangeOverLastYear) < 0)
                {
                    RateChangeLabel.TextColor = UIColor.Red;
                }
            }
        }
示例#4
0
        /// <summary>
        /// Download the image from the url and save it to local storage for reuse
        /// </summary>
        /// <param name="propertyManager"></param>
        /// <param name="listingID"></param>
        /// <param name="imageName"></param>
        /// <param name="downloadedImageView"></param>
        /// <param name="isOrignal"></param>
        public static void SetImage(IPropertyMangager propertyManager, int listingID, string imageName, ImageView downloadedImageView, int isOrignal = 100)
        {
            byte[] imageBytes = null;

            if (!urlToImageMap.ContainsKey(listingID))
            {
                string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                string localFilename = listingID + ".jpg";
                string localPath     = System.IO.Path.Combine(documentsPath, localFilename);
                if (!File.Exists(localPath))
                {
                    Task.Run(async() =>
                    {
                        imageBytes = await propertyManager.GetImageAsync(imageName);
                    }
                             ).GetAwaiter().GetResult();

                    if (imageBytes != null && imageBytes.Length > 0)
                    {
                        File.WriteAllBytes(localPath, imageBytes); // writes to local storage
                    }
                }

                var localImage = new Java.IO.File(localPath);
                if (localImage.Exists())
                {
                    SetPic(localImage.AbsolutePath, downloadedImageView, isOrignal);
                    urlToImageMap.Add(listingID, localImage.AbsolutePath);
                }
            }
            else
            {
                SetPic(urlToImageMap[listingID], downloadedImageView, isOrignal);
            }
        }
        /// <summary>
        /// OnCreate
        /// </summary>
        /// <param name="savedInstanceState"></param>
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            progress = ProgressDialog.Show(this, "Loading", "Please Wait...", true);
            //propertyManager = TinyIoC.TinyIoCContainer.Current.Resolve<IPropertyMangager>();
            propertyManager = Mvx.GetSingleton <IPropertyMangager>();

            // propertyManager = new PropertyMangager();
            int listingID = Intent.GetIntExtra("ListingID", 0);

            if (listingID > 0)
            {
                propertydetail = await propertyManager.GetItemAsync(listingID.ToString());
            }
            SetContentView(Resource.Layout.PropertyDetailView);
            if (propertydetail != null)
            {
                BindFields();
            }

            if (CrossConnectivity.Current.IsConnected)
            {
                SQLLiteHelper.InsertPropertyDetails(propertydetail);
            }

            if (progress != null)
            {
                progress.Hide();
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="context"></param>
        /// <param name="layoutResourceId"></param>
        /// <param name="listingCollection"></param>
        public PropertyListingsManagerAdapter(Context context, int layoutResourceId, List <Property> listingCollection)
        {
            #region Commented
            //propertyManager = TinyIoC.TinyIoCContainer.Current.Resolve<IPropertyMangager>();
            //propertyManager = new PropertyMangager();
            #endregion

            this.context            = context;
            this.layoutResourceId   = layoutResourceId;
            this.propertyCollection = listingCollection;
            propertyManager         = Mvx.GetSingleton <IPropertyMangager>();
        }
        /// <summary>
        /// OnCreate
        /// </summary>
        /// <param name="bundle"></param>
        protected async override void OnCreate(Bundle bundle)
        {
            SetUpIOC.SetupContainer();
            if (!CrossConnectivity.Current.IsConnected)
            {
                Mvx.RegisterSingleton(new PropertyRepository(new SQLiteInfoMonodroid()));
            }

            base.OnCreate(bundle);

            propertyManager = Mvx.GetSingleton <IPropertyMangager>();
            //propertyManager = new PropertyMangager();
            SetContentView(Resource.Layout.PropertyViewMain);

            propertylisttingsView = FindViewById <ListView>(Resource.Id.PropertylisttingsView);
            propertylisttingsView.SetItemChecked(0, true);
            propertylisttingsView.ItemClick += ListtingsView_ItemClick;
        }
示例#8
0
 public void Setup()
 {
     mgr = new PropertyMangager();
 }
 public PropertyDetailViewController(IntPtr handle) : base(handle)
 {
     // propertyManager = TinyIoC.TinyIoCContainer.Current.Resolve<IPropertyMangager>();
     propertyManager = Mvx.GetSingleton <IPropertyMangager>();
 }