예제 #1
0
 public void RefreshParent()
 {
     ServiceWrapper svc         = new ServiceWrapper();
     int            userId      = Convert.ToInt32(CurrentUser.getUserId());
     var            output      = svc.GetCustomerDetails(userId).Result;
     Bitmap         imageBitmap = BlobWrapper.ProfileImages(userId);
 }
예제 #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;

            if (row == null)
            {
                row = LayoutInflater.From(myContext).Inflate(Resource.Layout.CommentsCell, null, false);
            }
            TextView  Name     = row.FindViewById <TextView>(Resource.Id.textView64);
            TextView  Comments = row.FindViewById <TextView>(Resource.Id.textView66);
            TextView  date     = row.FindViewById <TextView>(Resource.Id.textView67);
            RatingBar rb       = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating);
            ImageView Image    = row.FindViewById <ImageView>(Resource.Id.imageButton2);

            Bitmap imageBitmap = BlobWrapper.ProfileImages(myItems[position].ReviewUserId);

            if (imageBitmap == null)
            {
                Image.SetImageResource(Resource.Drawable.user1);
            }
            else
            {
                Image.SetImageBitmap(imageBitmap);
            }
            //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
            //string path = pppd.CreateDirectoryForPictures();
            ////string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            ////It's taking lot of time to load user images so giving wine id, after completing compressing image we will give reviewuserid
            //var filePath = System.IO.Path.Combine(path + "/" + myItems[position].ReviewUserId + ".jpg");
            //if (System.IO.File.Exists(filePath))
            //{
            //    imageBitmap = BitmapFactory.DecodeFile(filePath);
            //    Image.SetImageBitmap(imageBitmap);
            //}
            //else
            //{
            //    //It's taking lot of time to load user images so giving wine id, after completing compressing image we will give reviewuserid
            //    imageBitmap = BlobWrapper.ProfileImages(myItems[position].ReviewUserId);
            //    if(imageBitmap==null)
            //    {
            //        Image.SetImageResource(Resource.Drawable.user1);
            //    }
            //    else
            //    {
            //    Image.SetImageBitmap(imageBitmap);
            //    }
            //}
            Name.Text      = myItems[position].Username;
            Name.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
            Comments.Text  = myItems[position].RatingText;
            date.Text      = myItems[position].Date.ToString("dd/MM/yyyy");
            rb.Rating      = myItems[position].RatingStars;
            //Image.SetImageBitmap(imageBitmap);
            Image.SetScaleType(ImageView.ScaleType.CenterCrop);
            return(row);
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Profile);
            try
            {
                ActionBar.SetHomeButtonEnabled(true);
                ActionBar.SetDisplayHomeAsUpEnabled(true);
                int                      userId      = Convert.ToInt32(CurrentUser.getUserId());
                ServiceWrapper           sw          = new ServiceWrapper();
                var                      output      = sw.GetCustomerDetails(userId).Result;
                ImageView                propicimage = FindViewById <ImageView>(Resource.Id.propicview);
                ProfilePicturePickDialog pppd        = new ProfilePicturePickDialog();
                string                   path        = pppd.CreateDirectoryForPictures();
                //string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

                var filePath = System.IO.Path.Combine(path + "/" + userId + ".jpg");
                if (System.IO.File.Exists(filePath))
                {
                    Bitmap imageBitmap = BitmapFactory.DecodeFile(filePath);
                    if (imageBitmap == null)
                    {
                        propicimage.SetImageResource(Resource.Drawable.user1);
                        //propicimage.SetImageBitmap(imageBitmap);
                    }
                    else
                    {
                        propicimage.SetImageBitmap(imageBitmap);
                    }
                }
                else
                {
                    Bitmap imageBitmap = BlobWrapper.ProfileImages(userId);
                    if (imageBitmap == null)
                    {
                        propicimage.SetImageResource(Resource.Drawable.user1);
                    }
                    else
                    {
                        propicimage.SetImageBitmap(imageBitmap);
                    }
                }

                ImageButton changepropic = FindViewById <ImageButton>(Resource.Id.btnChangePropic);

                //changepropic.SetImageResource(Resource.Drawable.dpreplacer);
                //changepropic.SetScaleType(ImageView.ScaleType.CenterCrop);
                changepropic.Click += delegate
                {
                    Intent intent = new Intent(this, typeof(ProfilePicturePickDialog));
                    StartActivity(intent);
                };

                //Button Btnlogout = FindViewById<Button>(Resource.Id.button1);
                //Btnlogout.Click += delegate
                //{

                //    Intent intent = new Intent(this, typeof(LoginActivity));
                //    StartActivity(intent);
                //};

                EditText Firstname = FindViewById <EditText>(Resource.Id.txtFirstName);
                Firstname.Text = output.customer.FirstName;
                EditText Lastname = FindViewById <EditText>(Resource.Id.txtLastName);
                Lastname.Text = output.customer.LastName;
                EditText Mobilenumber = FindViewById <EditText>(Resource.Id.txtMobileNumber);
                string   phno1        = output.customer.PhoneNumber;
                string   phno2        = output.customer.Phone2;
                if (phno1 != null)
                {
                    Mobilenumber.Text = phno1;
                }
                else
                {
                    Mobilenumber.Text = phno2;
                }
                EditText Email = FindViewById <EditText>(Resource.Id.txtEmail);
                Email.Text = output.customer.Email;
                EditText Address = FindViewById <EditText>(Resource.Id.txtAddress);
                string   Addres2 = output.customer.Address2;
                string   Addres1 = output.customer.Address1;
                Address.Text = string.Concat(Addres1, Addres2);
                EditText City = FindViewById <EditText>(Resource.Id.txtCity);
                City.Text = output.customer.City;
                EditText State = FindViewById <EditText>(Resource.Id.txtState);
                State.Text = output.customer.State;

                Button updatebtn = FindViewById <Button>(Resource.Id.UpdateButton);

                //updatebtn.SetScaleType(ImageView.ScaleType.CenterCrop);
                updatebtn.Click += async delegate
                {
                    Customer customer = new Customer();
                    customer.FirstName   = Firstname.Text;
                    customer.LastName    = Lastname.Text;
                    customer.PhoneNumber = Mobilenumber.Text;
                    customer.Address1    = Address.Text;
                    customer.Email       = Email.Text;
                    customer.CustomerID  = userId;
                    customer.State       = State.Text;
                    customer.City        = City.Text;
                    var x = await sw.UpdateCustomer(customer);

                    if (x == 1)
                    {
                        Toast.MakeText(this, "Thank you your profile is Updated", ToastLength.Short).Show();
                    }
                };
            }
            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();
            }
            ProgressIndicator.Hide();
        }
예제 #4
0
        public async void DownloadAsync(object sender, System.EventArgs ea)
        {
            try
            {
                //st.Start();
                Bitmap img = BlobWrapper.ProfileImages(Convert.ToInt32(CurrentUser.getUserId()));
                if (img != null)
                {
                    propicimage.SetImageBitmap(img);
                }
                else
                {
                    webClient = new WebClient();
                    var    url        = new Uri("https://icsintegration.blob.core.windows.net/profileimages/" + Convert.ToInt32(CurrentUser.getUserId()) + ".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)
                    {
                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                        //progressLayout.Visibility = ViewStates.Gone;
                        //downloadButton.Click += downloadAsync;
                        //downloadButton.Text = "Download Image";
                        Bitmap imgWine = BlobWrapper.ProfileImages(Convert.ToInt32(CurrentUser.getUserId()));
                        propicimage.SetImageBitmap(imgWine);
                        return;
                    }

                    try
                    {
                        string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                        string localFilename = "user.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()
                        {
                            InJustDecodeBounds = true
                        };
                        await BitmapFactory.DecodeFileAsync(localPath, options);

                        Bitmap bitmap = await BitmapFactory.DecodeFileAsync(localPath);

                        if (bitmap == null)
                        {
                            propicimage.SetImageResource(Resource.Drawable.user1);
                        }
                        propicimage.SetImageBitmap(bitmap);
                    }
                    catch (Exception exe)
                    {
                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                    }
                    st.Stop();
                    LoggingClass.LogTime("Download aSync image profile", st.Elapsed.TotalSeconds.ToString());
                    propicimage.Dispose();
                }
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
            }
        }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;

            if (row == null)
            {
                if (myItems.Count == 0)
                {
                    row = LayoutInflater.From(myContext).Inflate(Resource.Layout.EmptyTaste, null, false);

                    TextView te = row.FindViewById <TextView>(Resource.Id.textView123a);
                }
                else
                {
                    row = LayoutInflater.From(myContext).Inflate(Resource.Layout.ReviewInDetail, null, false);
                    TextView  Name     = row.FindViewById <TextView>(Resource.Id.textView64);
                    TextView  Comments = row.FindViewById <TextView>(Resource.Id.textView66);
                    TextView  date     = row.FindViewById <TextView>(Resource.Id.textView67);
                    RatingBar rb       = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating);
                    Image = row.FindViewById <ImageView>(Resource.Id.imageButton2);
                    Image.SetScaleType(ImageView.ScaleType.CenterCrop);
                    Button readmore = row.FindViewById <Button>(Resource.Id.btShowmore);
                    readmore.Visibility = ViewStates.Gone;
                    Bitmap imageBitmap = BlobWrapper.ProfileImages(myItems[position].ReviewUserId);
                    if (imageBitmap == null)
                    {
                        Image.SetImageResource(Resource.Drawable.ProfileEmpty);
                    }
                    else
                    {
                        Image.SetImageBitmap(imageBitmap);
                    }
                    if (convertView == null)
                    {
                        Name.Text      = myItems[position].Username;
                        Name.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
                        Comments.Text  = myItems[position].RatingText;
                        int counnt;
                        counnt = myItems[position].RatingText.Length;// Length();
                        myItems[position].RatingText.Contains('\n');
                        int strcount = countofrepeatedchar(myItems[position].RatingText, '\n');
                        date.Text = myItems[position].Date.ToString("yyyy/MM/dd");
                        rb.Rating = (float)myItems[position].RatingStars;
                        if (strcount >= 2)
                        {
                            readmore.Visibility = ViewStates.Visible;
                            Comments.SetMaxLines(2);
                            readmore.Click += (sender, e) =>
                            {
                                AlertDialog.Builder alert = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme);

                                alert.SetMessage(myItems[position].RatingText);
                                alert.SetNegativeButton("Ok", delegate
                                {
                                    readmore.Visibility = ViewStates.Visible;
                                });
                                Dialog dialog = alert.Create();
                                dialog.Show();
                            };

                            readmore.Visibility = ViewStates.Visible;
                            //Image.SetImageBitmap(imageBitmap);
                        }
                        else
                        {
                            if (counnt >= 80)
                            {
                                readmore.Visibility = ViewStates.Visible;
                                Comments.SetMaxLines(2);
                                readmore.Click += (sender, e) =>
                                {
                                    AlertDialog.Builder alert = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme);

                                    alert.SetMessage(myItems[position].RatingText);
                                    alert.SetNegativeButton("Ok", delegate
                                    {
                                        //  readmore.Visibility = ViewStates.Visible;
                                    });
                                    Dialog dialog = alert.Create();
                                    dialog.Show();
                                };

                                readmore.Visibility = ViewStates.Visible;
                            }
                            else
                            {
                                readmore.Visibility = ViewStates.Gone;
                                Comments.Text       = myItems[position].RatingText;
                            }
                        }
                    }
                }
            }
            Image.Dispose();
            return(row);
        }
예제 #6
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;


            if (row == null)
            {
                if (myItems.Count == 0)
                {
                    row = LayoutInflater.From(myContext).Inflate(Resource.Layout.EmptyTaste, null, false);

                    TextView te = row.FindViewById <TextView>(Resource.Id.textView123a);
                }
                else
                {
                    row = LayoutInflater.From(myContext).Inflate(Resource.Layout.Dummy, null, false);
                    TextView  Name     = row.FindViewById <TextView>(Resource.Id.textView64);
                    TextView  Comments = row.FindViewById <TextView>(Resource.Id.textView66);
                    TextView  date     = row.FindViewById <TextView>(Resource.Id.textView67);
                    RatingBar rb       = row.FindViewById <RatingBar>(Resource.Id.rtbProductRating);

                    ImageView Image = row.FindViewById <ImageView>(Resource.Id.imageButton2);
                    Image.SetScaleType(ImageView.ScaleType.CenterCrop);
                    Button readmore = row.FindViewById <Button>(Resource.Id.btShowmore);
                    readmore.Visibility = ViewStates.Gone;
                    Bitmap imageBitmap = BlobWrapper.ProfileImages(myItems[position].ReviewUserId);
                    if (imageBitmap == null)
                    {
                        Image.SetImageResource(Resource.Drawable.ProfileEmpty);
                    }

                    else
                    {
                        Image.SetImageBitmap(imageBitmap);
                    }
                    ///imageBitmap.Dispose();
                    //ProfilePicturePickDialog pppd = new ProfilePicturePickDialog();
                    //string path = pppd.CreateDirectoryForPictures();
                    ////string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
                    ////It's taking lot of time to load user images so giving wine id, after completing compressing image we will give reviewuserid
                    //var filePath = System.IO.Path.Combine(path + "/" + myItems[position].ReviewUserId + ".jpg");
                    //if (System.IO.File.Exists(filePath))
                    //{
                    //    imageBitmap = BitmapFactory.DecodeFile(filePath);
                    //    Image.SetImageBitmap(imageBitmap);
                    //}
                    //else
                    //{
                    //    //It's taking lot of time to load user images so giving wine id, after completing compressing image we will give reviewuserid
                    //    imageBitmap = BlobWrapper.ProfileImages(myItems[position].ReviewUserId);
                    //    if(imageBitmap==null)
                    //    {
                    //        Image.SetImageResource(Resource.Drawable.user1);
                    //    }
                    //    else
                    //    {
                    //    Image.SetImageBitmap(imageBitmap);
                    //    }
                    //}
                    Name.Text      = myItems[position].Username;
                    Name.InputType = Android.Text.InputTypes.TextFlagNoSuggestions;
                    Comments.Text  = myItems[position].RatingText;


                    int counnt;

                    counnt = myItems[position].RatingText.Length;// Length();
                    myItems[position].RatingText.Contains('\n');
                    int strcount = countofrepeatedchar(myItems[position].RatingText, '\n');


                    date.Text = myItems[position].Date.ToString("yyyy/MM/dd");
                    rb.Rating = (float)myItems[position].RatingStars;
                    if (strcount >= 3)
                    {
                        readmore.Visibility = ViewStates.Visible;
                        Comments.SetMaxLines(2);
                        readmore.Click += (sender, e) =>
                        {
                            AlertDialog.Builder alert = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme);

                            alert.SetMessage(myItems[position].RatingText);
                            alert.SetNegativeButton("Ok", delegate {
                                readmore.Visibility = ViewStates.Visible;
                            });
                            Dialog dialog = alert.Create();
                            dialog.Show();
                        };

                        readmore.Visibility = ViewStates.Visible;
                        //Image.SetImageBitmap(imageBitmap);
                    }
                    else
                    {
                        if (counnt >= 80)
                        {
                            readmore.Visibility = ViewStates.Visible;
                            Comments.SetMaxLines(2);
                            readmore.Click += (sender, e) =>
                            {
                                AlertDialog.Builder alert = new AlertDialog.Builder(myContext, Resource.Style.MyDialogTheme);

                                alert.SetMessage(myItems[position].RatingText);
                                alert.SetNegativeButton("Ok", delegate {
                                    readmore.Visibility = ViewStates.Visible;
                                });
                                Dialog dialog = alert.Create();
                                dialog.Show();
                            };

                            readmore.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            readmore.Visibility = ViewStates.Gone;
                            Comments.Text       = myItems[position].RatingText;
                        }
                    }
                }
            }
            return(row);
        }