Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            uid = Convert.ToInt32(CurrentUser.getUserId());
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Tasting);
            try
            {
                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);

                ServiceWrapper     svc        = new ServiceWrapper();
                ItemReviewResponse uidreviews = new ItemReviewResponse();
                // ItemRatingResponse irr = svc.GetItemReviewUID(uid).Result;

                uidreviews = svc.GetItemReviewUID(uid).Result;

                //if (uidreviews.Reviews.Count == 0)
                //{
                //    SetContentView(Resource.Layout.Dummy);
                //}
                List <Review> myArr1;
                myArr1 = uidreviews.Reviews.ToList();


                var wineList = FindViewById <ListView>(Resource.Id.listView1);
                // myArr1 = SampleData1();
                Review          edit      = new Review();
                ReviewPopup     editPopup = new ReviewPopup(this, edit);
                MyReviewAdapter adapter   = new MyReviewAdapter(this, myArr1);
                //if (adapter.Count == 0)
                //{
                //    TextView infoText = FindViewById<TextView>(Resource.Id.txtInfo);
                //    infoText.Text = "You haven't reviewed anything";
                //}
                //adapter.Edit_Click += editPopup.EditPopup;

                wineList.Adapter = adapter;

                // wineList.ItemClick += listView_ItemClick;

                wineList.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
                {
                    int WineID = myArr1[args.Position].WineId;
                    var intent = new Intent(this, typeof(detailViewActivity));
                    intent.PutExtra("WineID", WineID);
                    StartActivity(intent);
                };
                ProgressIndicator.Hide();
            }
            catch (Exception exe)
            {
                AlertDialog.Builder aler = new AlertDialog.Builder(this);
                aler.SetTitle("Sorry");
                aler.SetMessage("We're under maintainence");
                aler.SetNegativeButton("Ok", delegate { });
                Dialog dialog = aler.Create();
                dialog.Show();
            }
        }
Пример #2
0
        public ItemReviewResponse GetReviewsWineID(int WineId)
        {
            ItemReviewResponse itemReviewResponse = new ItemReviewResponse();
            IList <Review>     raingList          = new List <Review>();
            IItemDBManager     itemDBManager      = new ItemDBManager();
            IList <RetrieveReviewsByWineIdResult> reviewsSKUresult = itemDBManager.GetReviewsWineID(WineId).ToList();

            foreach (RetrieveReviewsByWineIdResult result in reviewsSKUresult)
            {
                raingList.Add(new Review
                {
                    SKU          = Convert.ToInt32(result.SKU),
                    RatingStars  = result.RatingStars,
                    Date         = Convert.ToDateTime(result.Date),
                    Username     = result.UserName.ToString(),
                    Name         = result.Name,
                    Vintage      = result.Vintage.ToString(),
                    Region       = result.Region,
                    Country      = result.Country,
                    RatingText   = result.RatingText,
                    ReviewId     = result.ReviewId,
                    WineId       = result.WineId,
                    ReviewUserId = Convert.ToInt32(result.ReviewUserId)
                });
            }
            itemReviewResponse.Reviews = raingList;
            return(itemReviewResponse);
        }
Пример #3
0
        public ItemReviewResponse GetItemReviewsUID(int objectId)
        {
            ItemReviewResponse resp        = new ItemReviewResponse();
            IItemService       itemService = new ItemService();

            resp = itemService.GetReviewsUID(objectId);
            return(resp);
        }
Пример #4
0
        public void RefreshParent()
        {
            nfloat              width  = View.Frame.Width;
            ServiceWrapper      svc    = new ServiceWrapper();
            ItemReviewResponse  rv     = svc.GetItemReviewUID(CurrentUser.RetreiveUserId()).Result;
            ItemDetailsResponse myData = svc.GetItemDetailsBarcode(WineBarcode, _storeId).Result;

            TableView.Source = new SKUDetailTableSource(width, this, NavigationController, myData.ItemDetails, _storeId);
            TableView.ReloadData();
        }
Пример #5
0
 public override void ViewDidLoad()
 {
     try
     {
         LoggingClass.LogInfo("Entered into detail view of " + WineBarcode, screenid);
         BTProgressHUD.Show();
         nfloat              width  = View.Frame.Width;
         ServiceWrapper      svc    = new ServiceWrapper();
         ItemDetailsResponse myData = svc.GetItemDetailsBarcode(WineBarcode, _storeId).Result;
         ItemReviewResponse  rv     = svc.GetItemReviewUID(CurrentUser.RetreiveUserId()).Result;
         TableView.SeparatorStyle  = UITableViewCellSeparatorStyle.None;
         TableView.AllowsSelection = false;
         TableView.RowHeight       = UITableView.AutomaticDimension;
         TableView.Source          = new SKUDetailTableSource(width, this, NavigationController, myData.ItemDetails, _storeId);
         BTProgressHUD.Dismiss();
     }
     catch (Exception ex)
     {
         LoggingClass.LogError(ex.Message, screenid, ex.StackTrace.ToString());
     }
 }
Пример #6
0
        public async Task <ItemReviewResponse> GetItemReviewUID(int userId)
        {
            sw.Start();
            ItemReviewResponse output = null;

            try
            {
                var uri      = new Uri(ServiceURL + "GetReviewUID/" + userId);
                var response = await client.GetStringAsync(uri).ConfigureAwait(false);

                output = JsonConvert.DeserializeObject <ItemReviewResponse>(response);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace);
            }
            sw.Stop();
            LoggingClass.LogServiceInfo("Service " + sw.Elapsed.TotalSeconds, "GetItemReviewUID");
            //Console.WriteLine("GetItemReviewUID service Time Elapsed"+sw.Elapsed.TotalSeconds);
            return(output);
        }
Пример #7
0
        public SKUDetailTableSource(nfloat wid, UIViewController parent, UINavigationController navCtrl, ItemDetails Data, int storeid)
        {
            try
            {
                _store = storeid;
                Width  = wid;
                Parent = parent;
                NavigationController = navCtrl;
                data = Data;

                data.Producer       = Data.Producer;
                data.AverageRating  = Data.AverageRating;               // 4.25m;
                data.WineProperties = new Dictionary <string, string>();
                ServiceWrapper     sw      = new ServiceWrapper();
                ItemReviewResponse ratings = sw.GetItemReviewsByWineID(data.Barcode).Result;
                data.Reviews = ratings.Reviews.ToList();
                //temp = new UITableViewCell[17];
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            AndHUD.Shared.Dismiss();
            CheckInternetConnection();
            Stopwatch st = new Stopwatch();

            st.Start();
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.detailedView);
            //         WineBarcode = Intent.GetStringExtra("WineBarcode");
            //storeid = Intent.GetIntExtra("storeid", 1);
            //ActionBar.SetHomeButtonEnabled(true);
            //ActionBar.SetDisplayHomeAsUpEnabled(true);
            //ServiceWrapper svc = new ServiceWrapper();
            //         myData = new ItemDetailsResponse();
            //ItemReviewResponse SkuRating = new ItemReviewResponse();
            //this.Title = "Wine Details";
            commentsview           = FindViewById <ListView>(Resource.Id.listView2);
            WineName               = FindViewById <TextView>(Resource.Id.txtWineName); //Assigning values to respected Textfields
            WineName.Focusable     = false;
            WineProducer           = FindViewById <TextView>(Resource.Id.txtProducer);
            WineProducer.Focusable = false;
            Vintage                     = FindViewById <TextView>(Resource.Id.txtVintage);
            Vintage.Focusable           = false;
            WineDescription             = FindViewById <TextView>(Resource.Id.txtWineDescription);
            WineDescription.Focusable   = false;
            AvgRating                   = FindViewById <RatingBar>(Resource.Id.avgrating);
            AvgRating.Focusable         = false;
            ErrorDescription            = FindViewById <TextView>(Resource.Id.Error);
            ErrorDescription.Focusable  = false;
            ErrorDescription.Visibility = ViewStates.Gone;
            TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5);

            WineBarcode = Intent.GetStringExtra("WineBarcode");
            storeid     = Intent.GetIntExtra("storeid", 1);
            Review edit = new Review()
            {
                Barcode    = WineBarcode,
                RatingText = "",
                PlantFinal = storeid.ToString()
            };

            ItemReviewResponse SkuRating = new ItemReviewResponse();
            ServiceWrapper     svc       = new ServiceWrapper();

            SkuRating = svc.GetItemReviewsByWineBarcode(WineBarcode).Result;
            var tempReview = SkuRating.Reviews.ToList().Find(x => x.ReviewUserId == Convert.ToInt32(CurrentUser.getUserId()));

            if (tempReview != null)
            {
                edit.RatingText = tempReview.RatingText;
            }
            editPopup = new ReviewPopup(this, edit);
            RatingBar RatingInput = FindViewById <RatingBar>(Resource.Id.ratingInput);//Taking rating stars input

            RatingInput.RatingBarChange += editPopup.CreatePopup;

            Internal_ViewDidLoad();
            st.Stop();
            AndHUD.Shared.Dismiss();
            LoggingClass.LogTime("Detail activity", st.Elapsed.TotalSeconds.ToString());
        }
        public void Internal_ViewDidLoad()
        {
            try
            {
                WineBarcode = Intent.GetStringExtra("WineBarcode");
                storeid     = Intent.GetIntExtra("storeid", 1);
                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                ServiceWrapper svc = new ServiceWrapper();
                myData = new ItemDetailsResponse();
                ItemReviewResponse SkuRating = new ItemReviewResponse();
                this.Title = "Wine Details";
                try
                {
                    DownloadAsync(this, System.EventArgs.Empty, WineBarcode);
                    myData      = svc.GetItemDetails(WineBarcode, storeid).Result;
                    SkuRating   = svc.GetItemReviewsByWineBarcode(WineBarcode).Result;
                    ReviewArray = SkuRating.Reviews.ToList();
                    var tempReview = SkuRating.Reviews.ToList().Find(x => x.ReviewUserId == Convert.ToInt32(CurrentUser.getUserId()));
                    if (tempReview != null)
                    {
                        editPopup._editObj.RatingText = tempReview.RatingText;
                    }
                    comments = new reviewAdapter(this, ReviewArray);
                    if (comments.Count == 0)
                    {
                        ErrorDescription.Visibility = ViewStates.Visible;
                        ErrorDescription.Text       = SkuRating.ErrorDescription;
                        ErrorDescription.SetTextColor(Android.Graphics.Color.Black);
                    }
                    else
                    {
                        commentsview.Adapter = comments;
                    }
                    setListViewHeightBasedOnChildren1(commentsview);
                    WineName.Text = myData.ItemDetails.Name;

                    WineName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
                    Vintage.Text       = myData.ItemDetails.Vintage.ToString();
                    if (Vintage.Text == null || Vintage.Text == "0")
                    {
                        Vintage.Text = "";
                    }
                    else
                    {
                        Vintage.Text = myData.ItemDetails.Vintage.ToString();
                    }
                    if (myData.ItemDetails.Producer == null || myData.ItemDetails.Producer == "")
                    {
                        WineProducer.Text = "Not Available";
                    }
                    else
                    {
                        WineProducer.Text = myData.ItemDetails.Producer;
                    }
                    if (myData.ItemDetails.Description == null || myData.ItemDetails.Description == "")
                    {
                        WineDescription.Text = "Not Available";
                    }
                    else
                    {
                        WineDescription.Text = myData.ItemDetails.Description;
                    }
                    AvgRating.Rating = (float)myData.ItemDetails.AverageRating;

                    //ReviewPopup editPopup = new ReviewPopup(this, edit);
                    //RatingBar RatingInput = FindViewById<RatingBar>(Resource.Id.ratingInput);//Taking rating stars input
                    //RatingInput.RatingBarChange += editPopup.CreatePopup;

                    var metrics    = Resources.DisplayMetrics;
                    var widthInDp  = ConvertPixelsToDp(metrics.WidthPixels);
                    var heightInDp = ConvertPixelsToDp(metrics.HeightPixels);


                    HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage);

                    BitmapFactory.Options options = new BitmapFactory.Options
                    {
                        InJustDecodeBounds = false,
                        OutHeight          = 75,
                        OutWidth           = 75
                    };
                    ProgressIndicator.Hide();
                    LoggingClass.LogInfo("Entered into detail view" + WineBarcode, screenid);
                    Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options);
                }
                catch (Exception exe)
                {
                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                    AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme);
                    alert.SetTitle("Sorry");
                    alert.SetMessage("We're under maintainence");
                    alert.SetNegativeButton("Ok", delegate { });
                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
            }
            catch { }
        }
Пример #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CheckInternetConnection();
            Stopwatch st = new Stopwatch();

            st.Start();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.detailedView);
            WineBarcode = Intent.GetStringExtra("WineBarcode");
            storeid     = Intent.GetIntExtra("storeid", 1);
            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ServiceWrapper      svc       = new ServiceWrapper();
            ItemDetailsResponse myData    = new ItemDetailsResponse();
            ItemReviewResponse  SkuRating = new ItemReviewResponse();

            this.Title   = "Wine Details";
            commentsview = FindViewById <ListView>(Resource.Id.listView2);
            TextView WineName = FindViewById <TextView>(Resource.Id.txtWineName);            //Assigning values to respected Textfields

            WineName.Focusable = false;
            TextView WineProducer = FindViewById <TextView>(Resource.Id.txtProducer);

            WineProducer.Focusable = false;
            TextView Vintage = FindViewById <TextView>(Resource.Id.txtVintage);

            Vintage.Focusable = false;
            TextView WineDescription = FindViewById <TextView>(Resource.Id.txtWineDescription);

            WineDescription.Focusable = false;
            RatingBar AvgRating = FindViewById <RatingBar>(Resource.Id.avgrating);

            AvgRating.Focusable = false;
            TextView ErrorDescription = FindViewById <TextView>(Resource.Id.Error);

            ErrorDescription.Focusable  = false;
            ErrorDescription.Visibility = ViewStates.Invisible;
            TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5);

            try
            {
                DownloadAsync(this, System.EventArgs.Empty, WineBarcode);
                myData      = svc.GetItemDetails(WineBarcode, storeid).Result;
                SkuRating   = svc.GetItemReviewsByWineBarcode(WineBarcode).Result;
                ReviewArray = SkuRating.Reviews.ToList();
                comments    = new reviewAdapter(this, ReviewArray);
                if (comments.Count == 0)
                {
                    ErrorDescription.Text       = SkuRating.ErrorDescription;
                    ErrorDescription.Visibility = ViewStates.Visible;
                    //AlertDialog.Builder aler = new AlertDialog.Builder(this, Resource.Style.MyDialogTheme);
                    //aler.SetTitle("No Reviews");
                    //aler.SetMessage("Be the first one to Review");
                    //aler.SetNegativeButton("Ok", delegate { });

                    //Dialog dialog = aler.Create();
                    //dialog.Show();
                }
                else
                {
                    commentsview.Adapter = comments;
                }
                setListViewHeightBasedOnChildren1(commentsview);
                WineName.Text      = myData.ItemDetails.Name;
                WineName.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
                Vintage.Text       = myData.ItemDetails.Vintage.ToString();
                if (myData.ItemDetails.Producer == null || myData.ItemDetails.Producer == "")
                {
                    WineProducer.Text = "Not Available";
                }
                else
                {
                    WineProducer.Text = myData.ItemDetails.Producer;
                }
                if (myData.ItemDetails.Description == null || myData.ItemDetails.Description == "")
                {
                    WineDescription.Text = "Not Available";
                }
                else
                {
                    WineDescription.Text = myData.ItemDetails.Description;
                }
                AvgRating.Rating = (float)myData.ItemDetails.AverageRating;
                Review edit = new Review()
                {
                    Barcode    = WineBarcode,
                    RatingText = "",
                    PlantFinal = storeid.ToString()
                };
                var tempReview = ReviewArray.Find(x => x.ReviewUserId == Convert.ToInt32(CurrentUser.getUserId()));
                if (tempReview != null)
                {
                    edit.RatingText = tempReview.RatingText;
                }
                ReviewPopup editPopup   = new ReviewPopup(this, edit);
                RatingBar   RatingInput = FindViewById <RatingBar>(Resource.Id.ratingInput);             //Taking rating stars input
                RatingInput.RatingBarChange += editPopup.CreatePopup;
                var metrics    = Resources.DisplayMetrics;
                var widthInDp  = ConvertPixelsToDp(metrics.WidthPixels);
                var heightInDp = ConvertPixelsToDp(metrics.HeightPixels);


                HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage);

                BitmapFactory.Options options = new BitmapFactory.Options
                {
                    InJustDecodeBounds = false,
                    OutHeight          = 75,
                    OutWidth           = 75
                };
                ProgressIndicator.Hide();
                LoggingClass.LogInfo("Entered into detail view" + WineBarcode, screenid);
                Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options);
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Sorry");
                alert.SetMessage("We're under maintainence");
                alert.SetNegativeButton("Ok", delegate { });
                Dialog dialog = alert.Create();
                dialog.Show();
            }
            //downloadButton = FindViewById<Button>(Resource.Id.Download);
            //try
            //{
            //    //downloadButton.Enabled = true;
            //    downloadButton.Click += downloadAsync;
            //    //downloadButton.Enabled = false;

            //}

            //catch (Exception e) { }
            st.Stop();
            LoggingClass.LogTime("Detail activity", st.Elapsed.TotalSeconds.ToString());
            TokenModel devInfo         = new TokenModel();
            var        activityManager = (ActivityManager)this.GetSystemService(Context.ActivityService);

            ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
            activityManager.GetMemoryInfo(memInfo);

            System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Avail {0} - {1} MB", memInfo.AvailMem, memInfo.AvailMem / 1024 / 1024);
            System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Low {0}", memInfo.LowMemory);
            System.Diagnostics.Debug.WriteLine("GetDeviceInfo - Total {0} - {1} MB", memInfo.TotalMem, memInfo.TotalMem / 1024 / 1024);

            devInfo.AvailableMainMemory = memInfo.AvailMem;
            devInfo.IsLowMainMemory     = memInfo.LowMemory;
            devInfo.TotalMainMemory     = memInfo.TotalMem;
        }
Пример #11
0
        protected override void OnCreate(Bundle bundle)
        {
            Stopwatch st = new Stopwatch();

            st.Start();
            base.OnCreate(bundle);
            uid = Convert.ToInt32(CurrentUser.getUserId());
            try
            {
                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                ServiceWrapper     svc        = new ServiceWrapper();
                ItemReviewResponse uidreviews = new ItemReviewResponse();
                uidreviews = svc.GetItemReviewUID(uid).Result;
                List <Review> myArr1;
                myArr1 = uidreviews.Reviews.ToList();
                int c = uidreviews.Reviews.Count;
                if (c == 0)
                {
                    var data = svc.GetMyTastingsList(uid).Result;


                    SetContentView(Resource.Layout.ReviewEmpty);
                    txtName = FindViewById <TextView>(Resource.Id.textView1);
                    if (data.TastingList.Count != 0)
                    {
                        txtName.Text = "You have tasted " + data.TastingList.Count + " wines.\n We would love to hear your feedback.";
                    }
                    else
                    {
                        txtName.Text = "Please taste and then review.";
                    }
                    Imag = FindViewById <ImageView>(Resource.Id.imageView1);
                    var TaskA = new System.Threading.Tasks.Task(() =>
                    {
                        Imag.SetImageResource(Resource.Drawable.ReviewIns);
                    });
                    TaskA.Start();
                }
                else
                {
                    SetContentView(Resource.Layout.MyReviews);
                    var             wineList  = FindViewById <ListView>(Resource.Id.listView1);
                    Review          edit      = new Review();
                    ReviewPopup     editPopup = new ReviewPopup(this, edit);
                    MyReviewAdapter adapter   = new MyReviewAdapter(this, myArr1);
                    wineList.Adapter = adapter;

                    wineList.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
                    {
                        string WineBarcode = myArr1[args.Position].Barcode;
                        int    storeID     = Convert.ToInt32(myArr1[args.Position].PlantFinal);
                        LoggingClass.LogInfoEx("Clicked on " + myArr1[args.Position].Barcode + " to enter into wine details From ReviewAct", screenid);
                        ProgressIndicator.Show(this);
                        //AndHUD.Shared.Show(this, "Loading...", Convert.ToInt32(MaskType.Clear));
                        var intent = new Intent(this, typeof(DetailViewActivity));
                        intent.PutExtra("WineBarcode", WineBarcode);
                        intent.PutExtra("storeid", storeID);
                        StartActivity(intent);
                    };

                    LoggingClass.LogInfo("Entered into My Review", screenid);
                }
                ProgressIndicator.Hide();
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                AndHUD.Shared.Dismiss();
                ProgressIndicator.Hide();
                AlertDialog.Builder aler = new AlertDialog.Builder(this);
                aler.SetTitle("Sorry");
                aler.SetMessage("We're under maintainence");
                aler.SetNegativeButton("Ok", delegate { });
                Dialog dialog = aler.Create();
                dialog.Show();
            }
            st.Stop();
            LoggingClass.LogTime("Reviewactivity", st.Elapsed.TotalSeconds.ToString());
        }
Пример #12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Dummy);

            Button             btnGallery = FindViewById <Button>(Resource.Id.btnTest);
            ServiceWrapper     svc = new ServiceWrapper();
            ItemReviewResponse md, md1 = new ItemReviewResponse();

            CurrentUser.SaveUserName("lok", "3");
            List <Review> Arr;

            md  = svc.GetItemReviewUID(Convert.ToInt32(CurrentUser.getUserId())).Result;
            Arr = md.Reviews.ToList();
            int oldcont = Arr.Count;

            md1 = svc.GetItemReviewUID(Convert.ToInt32(CurrentUser.getUserId())).Result;
            //CurrentUser.putCount(oldcont);
            Arr = md1.Reviews.ToList();
            int newcoun = Arr.Count;

            if (oldcont != newcoun)
            {
                Notification.Builder builder = new Notification.Builder(this)
                                               .SetContentTitle("You've reviewed new wine")
                                               .SetContentText("https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-gcm/")
                                               .SetSmallIcon(Resource.Drawable.user1);
                Notification        notification        = builder.Build();
                NotificationManager notificationManager =
                    GetSystemService(Context.NotificationService) as NotificationManager;
                const int notificationId = 0;
                notificationManager.Notify(notificationId, notification);
            }

            //btnGallery.Click += delegate
            //{
            //    Notification.Builder builder = new Notification.Builder(this)
            //    .SetContentTitle("hi Notification")
            //    .SetContentText("https://developer.xamarin.com/guides/android/application_fundamentals/notifications/remote-notifications-with-gcm/")
            //    .SetSmallIcon(Resource.Drawable.user1);
            //    Notification notification = builder.Build();
            //    NotificationManager notificationManager =
            //    GetSystemService(Context.NotificationService) as NotificationManager;
            //    const int notificationId = 0;
            //    notificationManager.Notify(notificationId, notification);
            //    //Intent intent = new Intent(this, typeof(ProfilePictureGallery));
            //StartActivity(intent);
            //};



            ////AsyncDownload asn = new AsyncDownload();
            //ImageView imageView = FindViewById<ImageView>(Resource.Id.imageView1);
            //LinearLayout progressLayout = FindViewById<LinearLayout>(Resource.Id.progressLayout);
            //progressLayout.Visibility = ViewStates.Gone;
            //Button downloadButton = FindViewById<Button>(Resource.Id.downloadButton);
            //downloadButton.Click += downloadAsync;

            //async void downloadAsync(object sender, System.EventArgs ea)
            //{
            //    webClient = new WebClient();
            //    var url = new Uri("https://icsintegration.blob.core.windows.net/bottleimagesdetails/198.jpg");
            //    byte[] imageBytes = null;
            //    progressLayout.Visibility = ViewStates.Visible;
            //    try
            //    {
            //        imageBytes = await webClient.DownloadDataTaskAsync(url);
            //    }
            //    catch (TaskCanceledException)
            //    {
            //        this.progressLayout.Visibility = ViewStates.Gone;
            //        return;
            //    }
            //    catch (Exception exe)
            //    {
            //        progressLayout.Visibility = ViewStates.Gone;
            //        downloadButton.Click += downloadAsync;
            //        downloadButton.Text = "Download Image";
            //        return;
            //    }

            //    try
            //    {
            //        string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            //        string localFilename = "Wine.png";
            //        string localPath = System.IO.Path.Combine(documentsPath, localFilename);

            //        FileStream fs = new FileStream(localPath, FileMode.OpenOrCreate);
            //        await fs.WriteAsync(imageBytes, 0, imageBytes.Length);
            //        Console.WriteLine("Saving image in local path: " + localPath);
            //        fs.Close();

            //        BitmapFactory.Options options = new BitmapFactory.Options();
            //        options.InJustDecodeBounds = true;
            //        await BitmapFactory.DecodeFileAsync(localPath, options);


            //    //options.InSampleSize = options.OutWidth > options.OutHeight ? options.OutHeight / imageView.Height : options.OutWidth / imageView.Width;
            //    //options.InJustDecodeBounds = false;

            //    Bitmap bitmap = await BitmapFactory.DecodeFileAsync(localPath);
            //    imageView.SetImageBitmap(bitmap);
            //    }
            //    catch (Exception e)
            //    {


            //    }

            //    progressLayout.Visibility = ViewStates.Gone;
            //    downloadButton.Click += downloadAsync;
            //    downloadButton.Text = "Download Image";
            //}

            //    public static async Task<bool> SaveCache(Stream data, string id)
            //{
            //    try
            //    {
            //        //cache folder in local storage
            //        IFolder rootFolder = FileSystem.Current.LocalStorage;
            //        var folder = await rootFolder.CreateFolderAsync("Cache",
            //            CreationCollisionOption.OpenIfExists);
            //        //save cached data
            //        IFile file = await folder.CreateFileAsync(id, CreationCollisionOption.ReplaceExisting);
            //        byte[] buffer = new byte[data.Length];
            //        data.Read(buffer, 0, buffer.Length);
            //        using (Stream stream = await file.OpenAsync(FileAccess.ReadAndWrite))
            //        {
            //            stream.Write(buffer, 0, buffer.Length);
            //        }
            //        return true;
            //    }
            //    catch
            //    {
            //        //some logging
            //        return false;
            //    }
            //}

            //public static async Task<Stream> LoadCache(string id)
            //{
            //    //cache folder in local storage
            //    IFolder rootFolder = FileSystem.Current.LocalStorage;
            //    var folder = await rootFolder.CreateFolderAsync("Cache",
            //        CreationCollisionOption.OpenIfExists);

            //    var isExists = await folder.CheckExistsAsync(id);

            //    if (isExists == ExistenceCheckResult.FileExists)
            //    {
            //        //file exists - load it from cache
            //        IFile file = await folder.GetFileAsync(id);
            //        return await file.OpenAsync(FileAccess.Read);
            //    }
            //}
            //    return null;
            //}
        }
        public void Internal_ViewDidLoad(Boolean refresh)
        {
            try
            {
                LoggingClass.LogInfo("Entered into detail view of " + _wineId, screen);
                //BTProgressHUD.Show();
                nfloat width = View.Frame.Width;
                ItemDetailsResponse mydata = svc.GetItemDetailsBarcode(_wineId, _storeId).Result;
                //ItemReviewResponse rv = svc.GetItemReviewUID(CurrentUser.RetreiveUserId()).Result;
                var data = mydata.ItemDetails;
                if (data.Barcode != null)
                {
                    var lblName = new UILabel();
                    lblName.Frame         = new CGRect(0, 0, width, 40);
                    lblName.Text          = data.Name;
                    lblName.Font          = UIFont.FromName("Verdana-Bold", 16f);
                    lblName.TextAlignment = UITextAlignment.Center;
                    lblName.TextColor     = UIColor.Purple;

                    //var Separator = new UIImageView();
                    //Separator.Frame = new CGRect(0, 50, View.Frame.Width, 2);
                    //Separator.Image = UIImage.FromFile("separator.png");

                    var lblVintage = new UILabel();
                    lblVintage.Frame = new CGRect(View.Frame.Width / 2 - 10, 40, 40, 20);
                    double l = Math.Floor(Math.Log10(data.Vintage) + 1);
                    if (l < 4)
                    {
                        lblVintage.Text = " ";
                    }
                    else
                    {
                        lblVintage.Text = data.Vintage.ToString();
                    }
                    lblVintage.Font            = UIFont.FromName("Verdana", 12f);
                    lblVintage.TextAlignment   = UITextAlignment.Center;
                    lblVintage.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("line123.png"));


                    var btlImage = new UIImageView();                     //92 * 233
                    btlImage.Frame = new CGRect(0, 10, width, width);
                    UIImage image = new UIImage("Images/loadin.png");

                    var btnBuy = new UIButton();
                    btnBuy.Frame             = new CGRect(UIScreen.MainScreen.Bounds.Width - 140, 70 + View.Frame.Width, 130, 70);
                    btnBuy.ClipsToBounds     = true;
                    btnBuy.Layer.BorderColor = UIColor.White.CGColor;
                    //btnBuy.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                    btnBuy.SetImage(UIImage.FromFile("buy.png"), UIControlState.Normal);
                    btnBuy.TouchUpInside += delegate {
                        UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.wineoutlet.com/sku" + data.SKU + ".html"));
                    };

                    CGRect rect      = btlImage.Bounds;
                    nfloat boxHeight = rect.Height;                     // which is = width;
                    //nfloat imgHeight = image.Size.Height;
                    //nfloat ratio = boxHeight / imgHeight;
                    //CGSize newSize = new CGSize(image.Size.Width * ratio, image.Size.Height * ratio);
                    //image = image.Scale(newSize);
                    nfloat X = (rect.Width / 2) - 50;
                    btlImage.Frame = new CGRect(X, btlImage.Bounds.Height / 2, 100, 100);
                    btlImage.Image = image;
                    DownloadAsync(data.Barcode, _storeId, btlImage, boxHeight, 70);
                    nfloat Y1 = 90 + View.Frame.Width;

                    UITextView txtWineleft = new UITextView(new CGRect(0, Y1 + 10, width, 40));
                    txtWineleft.Text          = "Wine left in bottle: " + data.AvailableVolume.ToString() + ".ml";
                    txtWineleft.TextAlignment = UITextAlignment.Center;
                    txtWineleft.Editable      = false;
                    //uip.SetProgress(Convert.ToSingle(data.AvailableVolume), false);
                    //uip.ProgressTintColor = UIColor.Green;
                    //uip.TintColor = UIColor.Gray;
                    //CGAffineTransform transform=CGAffineTransform.MakeScale(1.0f,Convert.ToSingle(data.AvailableVolume));
                    //uip.Transform = transform;

                    var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/empty.png"),
                                                        filledImage: UIImage.FromBundle("Stars/star.png"),
                                                        chosenImage: UIImage.FromBundle("Stars/star.png"));

                    nfloat Y = 70 + View.Frame.Width;
                    ratingView = new PDRatingView(new CGRect(width * 3 / 8 + 2, Y, width / 4, 20f), ratingConfig, data.AverageRating);
                    ratingView.UserInteractionEnabled = false;


                    var lblRateTitle = new UILabel();
                    lblRateTitle.Frame         = new CGRect(4, Y + 40, width, 50);
                    lblRateTitle.Text          = "Rate this Wine";
                    lblRateTitle.TextAlignment = UITextAlignment.Center;
                    lblRateTitle.Font          = UIFont.FromName("Verdana-Bold", 16f);
                    lblRateTitle.TextColor     = UIColor.Purple;

                    var lblRateRequest = new UILabel();
                    lblRateRequest.Frame         = new CGRect(4, Y + 75, width, 10);
                    lblRateRequest.Text          = "Select number of Stars";
                    lblRateRequest.Font          = UIFont.FromName("AmericanTypewriter", 10f);
                    lblRateRequest.TextAlignment = UITextAlignment.Center;

                    var starUpLine = new UIImageView(new CGRect(4, Y + 90, width - 8, 1));
                    starUpLine.AutoresizingMask  = UIViewAutoresizing.FlexibleWidth;
                    starUpLine.Image             = UIImage.FromFile("separator.png");
                    starUpLine.ContentMode       = UIViewContentMode.ScaleAspectFill;
                    starUpLine.ClipsToBounds     = true;
                    starUpLine.Layer.BorderColor = UIColor.White.CGColor;
                    starUpLine.BackgroundColor   = UIColor.LightGray;
                    Y = Y + 10;
                    PDRatingView     ratingViewSelect = new PDRatingView(new CGRect(width * 2 / 8, Y + 82, width / 2, 36f), ratingConfig, 0m);
                    UIViewController that             = this;

                    var starDownLine = new UIImageView(new CGRect(4, Y + 120, View.Frame.Width - 8, 1));
                    starDownLine.AutoresizingMask  = UIViewAutoresizing.FlexibleWidth;
                    starDownLine.Image             = UIImage.FromFile("separator.png");
                    starDownLine.ContentMode       = UIViewContentMode.ScaleAspectFill;
                    starDownLine.ClipsToBounds     = true;
                    starDownLine.Layer.BorderColor = UIColor.White.CGColor;
                    starDownLine.BackgroundColor   = UIColor.LightGray;

                    Y = Y + 140;
                    var lblDesc = new UILabel();
                    lblDesc.Frame         = new CGRect(4, Y, View.Frame.Width, 20);
                    lblDesc.Text          = "Description: ";
                    lblDesc.TextAlignment = UITextAlignment.Left;

                    Y = Y + 20;
                    var lblDescText = new UITextView();
                    lblDescText.Editable = false;
                    if (data.Description == null || data.Description == "")
                    {
                        lblDescText.Text = "Not available";
                        lblDescText.Font = UIFont.FromName("EuphemiaUCAS-Italic", 10f);
                    }
                    else
                    {
                        lblDescText.Text = data.Description.Trim();
                    }
                    lblDescText.TextAlignment = UITextAlignment.Justified;
                    CGSize sTemp = new CGSize(width, 100);
                    sTemp             = lblDescText.SizeThatFits(sTemp);
                    lblDescText.Frame = new CGRect(0, Y, width, sTemp.Height);

                    Y = Y + lblDescText.Frame.Size.Height;
                    var table = new UITableView();
                    table.Frame           = new CGRect(0, Y, width, data.WineProperties.Count * 22);
                    table.Source          = new WineInfoTableSource(data.WineProperties);
                    table.AllowsSelection = false;
                    table.ScrollEnabled   = false;

                    Y = Y + table.Frame.Size.Height + 10;
                    var lblProducer = new UILabel();
                    lblProducer.Frame         = new CGRect(4, Y, width, 20);
                    lblProducer.Text          = "Producer: ";
                    lblProducer.TextAlignment = UITextAlignment.Left;

                    Y = Y + 20;
                    var lblProducerText = new UITextView();
                    lblProducerText.Editable = false;
                    if (data.Producer == null || data.Producer == "")
                    {
                        lblProducerText.Text = "Not available";
                        lblProducerText.Font = UIFont.FromName("EuphemiaUCAS-Italic", 10f);
                    }
                    else
                    {
                        lblProducerText.Text = data.Producer.Trim();
                    }
                    lblProducerText.TextAlignment = UITextAlignment.Justified;
                    sTemp = new CGSize(width, 100);
                    sTemp = lblProducerText.SizeThatFits(sTemp);
                    lblProducerText.Frame = new CGRect(0, Y, width, sTemp.Height);


                    ItemReviewResponse ratings = svc.GetItemReviewsByWineID(data.Barcode).Result;
                    data.Reviews = ratings.Reviews.ToList();
                    Y            = Y + lblProducerText.Frame.Size.Height;
                    var review = LoadReviews(data, Y, width);
                    Y = Y + review.Frame.Size.Height;

                    //Y = Y + 20;
                    var NoReviews = new UITextView();
                    NoReviews.Hidden = true;
                    if (data.Reviews.Count == 0)
                    {
                        _noreviews = true;
                        reviewTable.SeparatorColor = UIColor.Clear;
                        NoReviews.Text             = ratings.ErrorDescription;
                        sTemp                   = NoReviews.SizeThatFits(sTemp);
                        NoReviews.Frame         = new CGRect(0, Y - 50, width, 40);
                        NoReviews.Editable      = false;
                        NoReviews.TextAlignment = UITextAlignment.Center;
                        NoReviews.Hidden        = false;
                    }

                    var    currentReview = data.Reviews.Where(x => x.ReviewUserId == CurrentUser.RetreiveUserId()).FirstOrDefault();
                    string currComments  = "";
                    if (currentReview != null)
                    {
                        currComments = currentReview.RatingText;
                    }
                    if (_notif == true)
                    {
                        //ratingViewSelect.RatingChosen += (sender, e) =>
                        //{
                        //if (CurrentUser.RetreiveUserId() == 0)
                        //{
                        //	UIAlertView alert = new UIAlertView()
                        //	{
                        //		Title = "This feature is allowed only for VIP Card holders",
                        //		//Message = "Coming Soon..."
                        //	};
                        //		alert.AddButton("OK");
                        //	alert.AddButton("Know more");
                        //	alert.Clicked += (senderalert, buttonArgs) =>
                        //	{
                        //		if (buttonArgs.ButtonIndex == 1)
                        //		{
                        //			UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        //		}
                        //	};
                        //	alert.Show();
                        //	ratingViewSelect.ChosenRating = 0;
                        //}
                        //else
                        //{
                        try
                        {
                            LoggingClass.LogInfo("Came from notifications and giving rating for " + data.Barcode, screen);
                            PopupView yourController = new PopupView(data.Barcode, _storeId);
                            yourController.NavController          = NavigationController;
                            yourController.parent                 = that;
                            yourController.StartsSelected         = 5;
                            yourController.Comments               = currComments;
                            yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                            that.PresentModalViewController(yourController, false);
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screen, exe.StackTrace);
                        }
                        //}
                        //};
                    }
                    ratingViewSelect.RatingChosen += (sender, e) =>
                    {
                        if (CurrentUser.RetreiveUserId() == 0)
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "This feature is allowed only for VIP Card holders",
                                //Message = "Coming Soon..."
                            };
                            alert.AddButton("OK");
                            alert.AddButton("Know more");
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 1)
                                {
                                    UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                                }
                            };
                            alert.Show();
                            ratingViewSelect.ChosenRating = 0;
                        }
                        else
                        {
                            LoggingClass.LogInfo("Clicked on stars to give rating on " + data.Barcode, screen);
                            PopupView yourController = new PopupView(data.Barcode, _storeId);
                            yourController.NavController          = NavigationController;
                            yourController.parent                 = that;
                            yourController.StartsSelected         = e.Rating;
                            yourController.Comments               = currComments;
                            yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                            that.PresentModalViewController(yourController, false);
                        }
                    };
                    scrollView       = new UIScrollView();
                    scrollView.Frame = new CGRect(0, 70, View.Frame.Width, View.Frame.Height);
                    if (_noreviews == true)
                    {
                        scrollView.ContentSize = new CGSize(View.Frame.Width, Y + 70);
                    }
                    else
                    {
                        scrollView.ContentSize = new CGSize(View.Frame.Width, Y + 20);
                    }
                    if (refresh == true)
                    {
                        //scrollView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, 70);
                        scrollView.ContentOffset = new CGPoint(0, 300);
                        var tap = new UITapGestureRecognizer {
                            CancelsTouchesInView = false
                        };
                        tap.AddTarget(() =>
                        {
                            scrollView.ContentSize   = new CGSize(View.Frame.Width, Y + 70);
                            scrollView.ContentOffset = new CGPoint(0, 0);
                        });
                    }


                    scrollView.BackgroundColor  = UIColor.White;
                    scrollView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
                    //};
                    if (_fav != true)
                    {
                        scrollView.AddSubview(txtWineleft);
                    }
                    //When making it async the Frame.Y is messing up by image Y. So changing it to 70. Ideally it should be 0.
                    //Same will apply to ContentSize.Y
                    View.AddSubview(scrollView);
                    //View.AddSubview(NoReviews);
                    //scrollView.AddSubview(btnBuy);
                    scrollView.AddSubview(lblName);
                    //scrollView.AddSubview(txtWineleft);
                    scrollView.AddSubview(lblVintage);
                    scrollView.AddSubview(btlImage);
                    scrollView.AddSubview(ratingView);
                    scrollView.AddSubview(lblRateTitle);
                    scrollView.AddSubview(lblRateRequest);
                    scrollView.AddSubview(ratingViewSelect);
                    scrollView.AddSubview(starUpLine);
                    scrollView.AddSubview(starDownLine);
                    scrollView.AddSubview(lblDesc);
                    scrollView.AddSubview(lblDescText);
                    scrollView.AddSubview(table);
                    scrollView.AddSubview(lblProducer);
                    scrollView.AddSubview(lblProducerText);
                    scrollView.AddSubview(review);
                    scrollView.AddSubview(NoReviews);
                    //scrollView.
                    BTProgressHUD.Dismiss();
                }
                else
                {
                    BTProgressHUD.Dismiss();
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Sorry",
                        Message = "Something went wrong. We are on it"
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace.ToString());
            }
        }
Пример #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.detailedView);
            wineid = Intent.GetIntExtra("WineID", 123);
            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ServiceWrapper      svc       = new ServiceWrapper();
            ItemDetailsResponse myData    = new ItemDetailsResponse();
            ItemReviewResponse  SkuRating = new ItemReviewResponse();

            this.Title = "Wine Details";
            var      commentsView = FindViewById <ListView>(Resource.Id.listView2);
            TextView WineName     = FindViewById <TextView>(Resource.Id.txtWineName); //Assigning values to respected Textfields

            WineName.Focusable = false;
            TextView WineProducer = FindViewById <TextView>(Resource.Id.txtProducer);

            WineProducer.Focusable = false;
            TextView Vintage = FindViewById <TextView>(Resource.Id.txtVintage);

            Vintage.Focusable = false;
            TextView WineDescription = FindViewById <TextView>(Resource.Id.txtWineDescription);

            WineDescription.Focusable = false;
            RatingBar AvgRating = FindViewById <RatingBar>(Resource.Id.avgrating);

            AvgRating.Focusable = false;
            TableRow tr5 = FindViewById <TableRow>(Resource.Id.tableRow5);

            try
            {
                downloadAsync(this, System.EventArgs.Empty, wineid);
                myData    = svc.GetItemDetails(wineid).Result;
                SkuRating = svc.GetItemReviewsByWineID(wineid).Result;
                reviewAdapter comments = new reviewAdapter(this, SkuRating.Reviews.ToList());
                commentsView.Adapter = comments;
                setListViewHeightBasedOnChildren1(commentsView);
                WineName.Text        = myData.ItemDetails.Name;
                WineName.InputType   = Android.Text.InputTypes.TextFlagNoSuggestions;
                Vintage.Text         = myData.ItemDetails.Vintage.ToString();
                WineProducer.Text    = myData.ItemDetails.Producer;
                WineDescription.Text = myData.ItemDetails.Description;
                AvgRating.Rating     = (float)myData.ItemDetails.AverageRating;
                Review edit = new Review();
                edit.WineId = wineid;
                ReviewPopup editPopup   = new ReviewPopup(this, edit);
                RatingBar   RatingInput = FindViewById <RatingBar>(Resource.Id.ratingInput);//Taking rating stars input
                RatingInput.RatingBarChange += editPopup.CreatePopup;

                var metrics    = Resources.DisplayMetrics;
                var widthInDp  = ConvertPixelsToDp(metrics.WidthPixels);
                var heightInDp = ConvertPixelsToDp(metrics.HeightPixels);

                //imgWine = FindViewById<ImageView>(Resource.Id.imgWine12);
                HighImageWine = FindViewById <ImageView>(Resource.Id.WineImage);

                //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
                //string path = pppd.CreateDirectoryForPictures();
                //var filePath = System.IO.Path.Combine(path + "/" + wineid + ".jpg");
                //if (System.IO.File.Exists(filePath))
                //{
                //    Bitmap imageBitmap = BitmapFactory.DecodeFile(filePath);
                //    imgWine.SetImageBitmap(imageBitmap);
                //}
                //else
                //{
                //    Bitmap imageBitmap = BlobWrapper.Bottleimages(wineid);
                //    imgWine.SetImageBitmap(imageBitmap);
                //}
                //imgWine.LayoutParameters = new RelativeLayout.LayoutParams(1100, 1100);
                BitmapFactory.Options options = new BitmapFactory.Options
                {
                    InJustDecodeBounds = false,
                    OutHeight          = 75,
                    OutWidth           = 75
                };
                ProgressIndicator.Hide();
                Bitmap result = BitmapFactory.DecodeResource(Resources, Resource.Drawable.placeholder_re, options);
            }
            catch (Exception ex)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Sorry");
                alert.SetMessage("We're under maintainence");
                alert.SetNegativeButton("Ok", delegate { });
                Dialog dialog = alert.Create();
                dialog.Show();
            }
            //downloadButton = FindViewById<Button>(Resource.Id.Download);
            //try
            //{
            //    //downloadButton.Enabled = true;
            //    downloadButton.Click += downloadAsync;
            //    //downloadButton.Enabled = false;

            //}

            //catch (Exception e) { }
        }