Esempio n. 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();
            }
        }
Esempio n. 2
0
        public void RefreshParent()
        {
            ServiceWrapper svc = new ServiceWrapper();

            var             uidreviews = svc.GetItemReviewUID(uid).Result;
            ListView        wineList   = FindViewById <ListView>(Resource.Id.listView1);
            Review          edit       = new Review();
            ReviewPopup     editPopup  = new ReviewPopup(this, edit);
            MyReviewAdapter adapter    = new MyReviewAdapter(this, uidreviews.Reviews.ToList());

            //adapter.Edit_Click += editPopup.EditPopup;

            wineList.Adapter = adapter;
            adapter.NotifyDataSetChanged();
        }
Esempio n. 3
0
        public void RefreshParent()
        {
            ServiceWrapper  svc        = new ServiceWrapper();
            var             uidreviews = svc.GetItemReviewUID(uid).Result;
            ListView        wineList   = FindViewById <ListView>(Resource.Id.listView1);
            Review          edit       = new Review();
            ReviewPopup     editPopup  = new ReviewPopup(this, edit);
            MyReviewAdapter adapter    = new MyReviewAdapter(this, uidreviews.Reviews.ToList());
            //adapter.Edit_Click += editPopup.EditPopup;
            int c = uidreviews.Reviews.Count;

            if (c == 0)
            {
                SetContentView(Resource.Layout.ReviewEmpty);
                txtName = FindViewById <TextView>(Resource.Id.textView1);
                Imag    = FindViewById <ImageView>(Resource.Id.imageView1);
            }
            wineList.Adapter = adapter;
            adapter.NotifyDataSetChanged();
        }
Esempio n. 4
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());
        }
Esempio n. 5
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;
            //}
        }