protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.PersonalData);
                edit_city_coord_for_edit = city_coord_for_edit_prefs.Edit();
                nameET             = FindViewById <EditText>(Resource.Id.nameET);
                last_nameET        = FindViewById <EditText>(Resource.Id.last_nameET);
                patronimicET       = FindViewById <EditText>(Resource.Id.patronimicET);
                emailET            = FindViewById <EditText>(Resource.Id.emailET);
                phoneET            = FindViewById <EditText>(Resource.Id.phoneET);
                cityTV             = FindViewById <TextView>(Resource.Id.cityTV);
                saveBn             = FindViewById <Button>(Resource.Id.saveBn);
                mainRL             = FindViewById <RelativeLayout>(Resource.Id.mainRL);
                backRelativeLayout = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                back_button        = FindViewById <ImageButton>(Resource.Id.back_button);
                coordinatesTV      = FindViewById <TextView>(Resource.Id.coordinatesTV);
                activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                singleDataScrollView            = FindViewById <ScrollView>(Resource.Id.singleDataScrollView);
                back_button.Click              += (s, e) => { OnBackPressed(); };
                backRelativeLayout.Click       += (s, e) => { OnBackPressed(); };
                activityIndicator.Visibility    = Android.Views.ViewStates.Visible;
                singleDataScrollView.Visibility = Android.Views.ViewStates.Gone;
                saveBn.Visibility               = Android.Views.ViewStates.Gone;
                var user_data = await profileAndExpertMethodsPCL.UserProfileData(userMethods.GetUsersAuthToken());

                if (user_data == "401")
                {
                    Toast.MakeText(this, Resource.String.you_not_logined, ToastLength.Long).Show();
                    userMethods.ClearTable();
                    userMethods.ClearUsersDataTable();
                    userMethods.ClearTableNotif();
                    StartActivity(typeof(MainActivity));
                    return;
                }
                activityIndicator.Visibility    = Android.Views.ViewStates.Gone;
                singleDataScrollView.Visibility = Android.Views.ViewStates.Visible;
                saveBn.Visibility = Android.Views.ViewStates.Visible;

                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                FindViewById <TextView>(Resource.Id.headerTV).SetTypeface(tf, TypefaceStyle.Bold);
                FindViewById <TextView>(Resource.Id.removeBn).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textViesw2).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textVssiew2).SetTypeface(tf, TypefaceStyle.Normal);
                nameET.SetTypeface(tf, TypefaceStyle.Normal);
                last_nameET.SetTypeface(tf, TypefaceStyle.Normal);
                patronimicET.SetTypeface(tf, TypefaceStyle.Normal);
                cityTV.SetTypeface(tf, TypefaceStyle.Normal);
                coordinatesTV.SetTypeface(tf, TypefaceStyle.Normal);
                saveBn.SetTypeface(tf, TypefaceStyle.Normal);
                emailET.SetTypeface(tf, TypefaceStyle.Normal);
                phoneET.SetTypeface(tf, TypefaceStyle.Normal);

                try
                {
                    var deserialized_user_data = JsonConvert.DeserializeObject <UserProfile>(user_data);
                    try
                    {
                        string[] words = deserialized_user_data.fullName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        nameET.Text       = words[0];
                        patronimicET.Text = words[1];
                        last_nameET.Text  = words[2];
                        edit_city_coord_for_edit.PutString("surname", words[2]);
                        edit_city_coord_for_edit.PutString("name", words[0]);
                        edit_city_coord_for_edit.PutString("middlename", words[1]);
                    }
                    catch { }
                    emailET.Text = userMethods.GetUsersEmail();
                    phoneET.Text = deserialized_user_data.phone;
                    cityTV.Text  = deserialized_user_data.city.name;
                    edit_city_coord_for_edit.PutString("city_id", deserialized_user_data.city.id);
                    edit_city_coord_for_edit.PutString("city_name", deserialized_user_data.city.name);
                    edit_city_coord_for_edit.PutString("lat", deserialized_user_data.coordinates.latitude);
                    edit_city_coord_for_edit.PutString("lng", deserialized_user_data.coordinates.longitude);
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data.coordinates.latitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lat", pref.GetString("latitude", String.Empty));
                        }
                    }
                    catch { }
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data.coordinates.longitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lng", pref.GetString("longitude", String.Empty));
                        }
                    }
                    catch { }
                    edit_city_coord_for_edit.PutString("phone", deserialized_user_data.phone);
                    edit_city_coord_for_edit.PutString("email", userMethods.GetUsersEmail());
                    edit_city_coord_for_edit.Apply();
                }
                catch
                {
                    deserialized_user_data_categs_empty = JsonConvert.DeserializeObject <UserProfileServiceCategoriesEmpty>(user_data);
                    try
                    {
                        string[] words = deserialized_user_data_categs_empty.fullName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        nameET.Text       = words[0];
                        patronimicET.Text = words[1];
                        last_nameET.Text  = words[2];
                        edit_city_coord_for_edit.PutString("surname", words[2]);
                        edit_city_coord_for_edit.PutString("name", words[0]);
                        edit_city_coord_for_edit.PutString("middlename", words[1]);
                    }
                    catch { }
                    emailET.Text = userMethods.GetUsersEmail();
                    phoneET.Text = deserialized_user_data_categs_empty.phone;
                    cityTV.Text  = deserialized_user_data_categs_empty.city.name;
                    edit_city_coord_for_edit.PutString("city_id", deserialized_user_data_categs_empty.city.id);
                    edit_city_coord_for_edit.PutString("city_name", deserialized_user_data_categs_empty.city.name);
                    edit_city_coord_for_edit.PutString("lat", deserialized_user_data_categs_empty.coordinates.latitude);
                    edit_city_coord_for_edit.PutString("lng", deserialized_user_data_categs_empty.coordinates.longitude);
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data_categs_empty.coordinates.latitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lat", pref.GetString("latitude", String.Empty));
                        }
                    }
                    catch { }
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data_categs_empty.coordinates.longitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lng", pref.GetString("longitude", String.Empty));
                        }
                    }
                    catch { }
                    edit_city_coord_for_edit.PutString("phone", deserialized_user_data_categs_empty.phone);
                    edit_city_coord_for_edit.PutString("email", userMethods.GetUsersEmail());
                    edit_city_coord_for_edit.Apply();
                }
                FindViewById <RelativeLayout>(Resource.Id.cityRL).Click += (s, e) =>
                {
                    StartActivity(typeof(CountryForProfileCityActivity));
                };
                FindViewById <RelativeLayout>(Resource.Id.locationRL).Click += (s, e) =>
                {
                    StartActivity(typeof(NewProfileCoordsMapActivity));
                };
                saveBn.Click += async(s, e) =>
                {
                    if (
                        !String.IsNullOrEmpty(last_nameET.Text) &&
                        !String.IsNullOrEmpty(nameET.Text) &&
                        !String.IsNullOrEmpty(phoneET.Text) &&
                        !String.IsNullOrEmpty(patronimicET.Text) &&
                        !String.IsNullOrEmpty(emailET.Text))
                    {
                        activityIndicator.Visibility    = Android.Views.ViewStates.Visible;
                        singleDataScrollView.Visibility = Android.Views.ViewStates.Gone;
                        saveBn.Visibility = Android.Views.ViewStates.Gone;
                        var res = await profileAndExpertMethods.EditMyProfileInfo(
                            userMethods.GetUsersAuthToken(),
                            phoneET.Text,
                            emailET.Text,
                            last_nameET.Text,
                            nameET.Text,
                            patronimicET.Text,
                            city_coord_for_edit_prefs.GetString("city_id", String.Empty),
                            city_coord_for_edit_prefs.GetString("lat", String.Empty),
                            city_coord_for_edit_prefs.GetString("lng", String.Empty));

                        activityIndicator.Visibility    = Android.Views.ViewStates.Gone;
                        singleDataScrollView.Visibility = Android.Views.ViewStates.Visible;
                        saveBn.Visibility = Android.Views.ViewStates.Visible;
                        if (res.Contains("с таким email уже"))
                        {
                            Toast.MakeText(this, GetString(Resource.String.email_already_exists), ToastLength.Short).Show();
                        }
                        else if (res.Contains("или неверно заполнен те"))
                        {
                            Toast.MakeText(this, GetString(Resource.String.wrong_phone), ToastLength.Short).Show();
                        }
                        else
                        {
                            ISharedPreferences       pref = Application.Context.GetSharedPreferences("reg_data", FileCreationMode.Private);
                            ISharedPreferencesEditor edit = pref.Edit();
                            edit.PutString("surname", "");
                            edit.PutString("name", "");
                            edit.PutString("patronymic", "");
                            edit.PutString("phone", "");
                            edit.PutString("email", "");
                            edit.Apply();
                            var token = JsonConvert.DeserializeObject <SingleToken>(res).authToken;
                            userMethods.InsertUser(token, emailET.Text);

                            StartActivity(typeof(UserProfileActivity));
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetString(Resource.String.fill_all_entries), ToastLength.Short).Show();
                    }
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
示例#2
0
        protected override async void OnResume()
        {
            base.OnResume();
            try
            {
                ISharedPreferences       expert_feedback_pref = Application.Context.GetSharedPreferences("expert_feedback_pref", FileCreationMode.Private);
                ISharedPreferencesEditor edit_expert_feedback;
                ISharedPreferencesEditor edit = specialization_for_edit_pref.Edit();
                timer          = new System.Timers.Timer();
                timer.Interval = 100;

                if (userMethods.UserExists())
                {
                    SetContentView(Resource.Layout.FullProfile);
                    dialogsTV            = FindViewById <TextView>(Resource.Id.dialogsTV);
                    message_indicatorIV  = FindViewById <ImageView>(Resource.Id.message_indicatorIV);
                    profileLL            = FindViewById <LinearLayout>(Resource.Id.profileLL);
                    dialogsLL            = FindViewById <LinearLayout>(Resource.Id.dialogsLL);
                    specialistsLL        = FindViewById <LinearLayout>(Resource.Id.specialistsLL);
                    go_to_my_reviewsLL   = FindViewById <LinearLayout>(Resource.Id.go_to_my_reviewsLL);
                    singleDataScrollView = FindViewById <ScrollView>(Resource.Id.singleDataScrollView);
                    service_categs_list.Clear();
                    editBn              = FindViewById <Button>(Resource.Id.editBn);
                    profile_image       = FindViewById <ImageView>(Resource.Id.profile_image);
                    choose_photoIV      = FindViewById <ImageView>(Resource.Id.choose_photoIV);
                    add_skillIV         = FindViewById <Button>(Resource.Id.add_skillIV);
                    edit_skillIV        = FindViewById <ImageView>(Resource.Id.edit_skillIV);
                    edit_skillRL        = FindViewById <RelativeLayout>(Resource.Id.edit_skillRL);
                    tintLL              = FindViewById <LinearLayout>(Resource.Id.tintLL);
                    gridLL              = FindViewById <LinearLayout>(Resource.Id.gridLL);
                    recyclerView        = FindViewById <RecyclerView>(Resource.Id.recyclerView);
                    this.mLayoutManager = new LinearLayoutManager(this);
                    this.recyclerView.SetLayoutManager(mLayoutManager);
                    activityIndicator       = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                    expertNameTV            = FindViewById <TextView>(Resource.Id.expertNameTV);
                    skillNameTV             = FindViewById <TextView>(Resource.Id.skillNameTV);
                    onlineValueTV           = FindViewById <TextView>(Resource.Id.onlineValueTV);
                    rating_valueTV          = FindViewById <TextView>(Resource.Id.rating_valueTV);
                    description_text_dataTV = FindViewById <TextView>(Resource.Id.description_text_dataTV);
                    reviewCountTV           = FindViewById <TextView>(Resource.Id.reviewCountTV);
                    image_activityIndicator = FindViewById <ProgressBar>(Resource.Id.image_activityIndicator);
                    activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                    image_activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                    activityIndicator.Visibility = ViewStates.Visible;
                    ImageRL                     = FindViewById <RelativeLayout>(Resource.Id.ImageRL);
                    feedbackRL                  = FindViewById <RelativeLayout>(Resource.Id.feedbackRL);
                    onlineIV                    = FindViewById <ImageView>(Resource.Id.onlineIV);
                    onlyWithReviewsS            = FindViewById <Switch>(Resource.Id.onlyWithReviewsS);
                    specializationCV            = FindViewById <CardView>(Resource.Id.specializationCV);
                    specializationCV.Visibility = ViewStates.Gone;
                    go_to_my_reviewsLL.Click   += (s, e) =>
                    {
                        StartActivity(typeof(AllReviewsByMeActivity));
                    };

                    Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                    FindViewById <TextView>(Resource.Id.specialistsTV).SetTypeface(tf, TypefaceStyle.Normal);
                    dialogsTV.SetTypeface(tf, TypefaceStyle.Normal);
                    FindViewById <TextView>(Resource.Id.profileTV).SetTypeface(tf, TypefaceStyle.Normal);
                    expertNameTV.SetTypeface(tf, TypefaceStyle.Bold);
                    FindViewById <TextView>(Resource.Id.dsadas).SetTypeface(tf, TypefaceStyle.Bold);
                    onlineValueTV.SetTypeface(tf, TypefaceStyle.Normal);
                    FindViewById <TextView>(Resource.Id.sdsddsddddwww).SetTypeface(tf, TypefaceStyle.Normal);
                    skillNameTV.SetTypeface(tf, TypefaceStyle.Bold);
                    FindViewById <TextView>(Resource.Id.textView1).SetTypeface(tf, TypefaceStyle.Normal);
                    description_text_dataTV.SetTypeface(tf, TypefaceStyle.Normal);
                    reviewCountTV.SetTypeface(tf, TypefaceStyle.Bold);
                    rating_valueTV.SetTypeface(tf, TypefaceStyle.Normal);
                    FindViewById <TextView>(Resource.Id.textsssView1).SetTypeface(tf, TypefaceStyle.Normal);
                    editBn.SetTypeface(tf, TypefaceStyle.Bold);
                    skillNameTV.SetTypeface(tf, TypefaceStyle.Bold);
                    add_skillIV.SetTypeface(tf, TypefaceStyle.Normal);

                    var token     = userMethods.GetUsersAuthToken();
                    var user_data = await profileAndExpertMethodsPCL.UserProfileData(token);

                    edit.PutString("user_data", user_data);
                    edit.Apply();
                    if (user_data == "401")
                    {
                        Toast.MakeText(this, Resource.String.you_not_logined, ToastLength.Long).Show();
                        userMethods.ClearTable();
                        userMethods.ClearUsersDataTable();
                        userMethods.ClearTableNotif();
                        StartActivity(typeof(MainActivity));
                        return;
                    }

                    userMethods.InsertProfileData(user_data);
                    dialogsLL.Click += (s, e) =>
                    {
                        edit_dialog = dialog_data.Edit();
                        edit_dialog.PutString("come_from", "Came directly from bottom");
                        edit_dialog.Apply();
                        StartActivity(typeof(ChatListActivity));
                    };
                    specialistsLL.Click += (s, e) =>
                    {
                        StartActivity(typeof(SpecialistsCategoryActivity));
                    };
                    activityIndicator.Visibility = ViewStates.Gone;
                    try
                    {
                        var deserialized_user_data = JsonConvert.DeserializeObject <UserProfile>(user_data);

                        if (deserialized_user_data.myReviews == "0")
                        {
                            go_to_my_reviewsLL.Visibility = ViewStates.Gone;
                        }

                        if (!String.IsNullOrEmpty(deserialized_user_data.notify_alerts.msg_cnt_new.ToString()) && deserialized_user_data.notify_alerts.msg_cnt_new.ToString() != "0")
                        {
                            message_indicatorIV.Visibility = ViewStates.Visible;
                            dialogsTV.Text = GetString(Resource.String.dialogs) + " (" + deserialized_user_data.notify_alerts.msg_cnt_new + ")";
                        }
                        else
                        {
                            message_indicatorIV.Visibility = ViewStates.Gone;
                            dialogsTV.Text = GetString(Resource.String.dialogs);
                        }

                        this.listItems = new List <IExpertProfileDataType>();
                        listItems.Add(new UserProfileGroupData(
                                          null,
                                          null,
                                          null,
                                          deserialized_user_data.avatarUrl,
                                          deserialized_user_data.reviews,
                                          deserialized_user_data.rating,
                                          deserialized_user_data.id,
                                          deserialized_user_data.aboutExpert,
                                          deserialized_user_data.fullName,
                                          deserialized_user_data.phone,
                                          deserialized_user_data.city.name,
                                          deserialized_user_data.distance,
                                          deserialized_user_data.online));
                        int count = 0;
                        foreach (var item in deserialized_user_data.mainCategories)
                        {
                            count++;
                            var spec_obj = new UserProfileGroupData(count, item.name, item.spec_id, deserialized_user_data.id, deserialized_user_data.avatarUrl, "", "", "");

                            if (item.subcategories != null)
                            {
                                foreach (var subitem in item.subcategories)
                                {
                                    UserProfileEntryData spec_data = new UserProfileEntryData(1, subitem.name, subitem.categoryId, count - 1, subitem.services, subitem.photos /*, item.rating, item.reviews*/, subitem.description);
                                    spec_obj.items.Add(spec_data);
                                }
                            }
                            listItems.Add(spec_obj);
                        }
                        ;
                        userProfileExpandableAdapter             = new UserProfileExpandableAdapter(this, listItems, deserialized_user_data, tf);
                        userProfileExpandableAdapter.GroupClick += OnGroupClick;
                        recyclerView.SetAdapter(userProfileExpandableAdapter);
                        singleDataScrollView.Visibility        = ViewStates.Gone;
                        recyclerView.Visibility                = ViewStates.Visible;
                        UserProfileExpandableAdapter.image_url = "https://api.iamnearby.net" + deserialized_user_data.avatarUrl;
                    }
                    catch
                    {
                        deserialized_user_data_categs_empty = JsonConvert.DeserializeObject <UserProfileServiceCategoriesEmpty>(user_data);
                        if (deserialized_user_data_categs_empty.myReviews == "0")
                        {
                            go_to_my_reviewsLL.Visibility = ViewStates.Gone;
                        }
                        if (!String.IsNullOrEmpty(deserialized_user_data_categs_empty.notify_alerts.msg_cnt_new.ToString()) && deserialized_user_data_categs_empty.notify_alerts.msg_cnt_new.ToString() != "0")
                        {
                            message_indicatorIV.Visibility = ViewStates.Visible;
                            dialogsTV.Text = GetString(Resource.String.dialogs) + " (" + deserialized_user_data_categs_empty.notify_alerts.msg_cnt_new + ")";
                        }
                        else
                        {
                            message_indicatorIV.Visibility = ViewStates.Gone;
                            dialogsTV.Text = GetString(Resource.String.dialogs);
                        }
                        specializationCV.Visibility     = ViewStates.Gone;
                        singleDataScrollView.Visibility = ViewStates.Visible;
                        recyclerView.Visibility         = ViewStates.Gone;
                        /*var d = */
                        Thread backgroundThread = new Thread(new ThreadStart(() =>
                        {
                            Glide.Get(Application.Context).ClearDiskCache();
                        }));
                        backgroundThread.IsBackground = true;
                        backgroundThread.Start();
                        Glide.Get(this).ClearMemory();
                        Glide.With(Application.Context)
                        .Load("https://api.iamnearby.net/" + deserialized_user_data_categs_empty.avatarUrl)
                        .Apply(new Com.Bumptech.Glide.Request.RequestOptions()
                               .SkipMemoryCache(true))
                        //.Placeholder(Resource.Drawable.specialization_imageIV)
                        .Into(profile_image);

                        profile_image.Click += (s, e) =>
                        {
                            if (!String.IsNullOrEmpty(deserialized_user_data_categs_empty.avatarUrl))
                            {
                                DisplayMyPhotoActivity.image_url = "https://api.iamnearby.net" + deserialized_user_data_categs_empty.avatarUrl;
                                StartActivity(typeof(DisplayMyPhotoActivity));
                            }
                        };

                        if (deserialized_user_data_categs_empty.online)
                        {
                            onlineValueTV.SetTextColor(Color.Green);
                            onlyWithReviewsS.Checked = true;
                            onlineValueTV.Text       = GetString(Resource.String.online_text);
                        }
                        else
                        {
                            onlyWithReviewsS.Checked = false;
                            onlineValueTV.Text       = GetString(Resource.String.offline_text);
                            onlineValueTV.SetTextColor(Color.Red);
                        }

                        expertNameTV.Text = deserialized_user_data_categs_empty.fullName;
                        try
                        {
                            skillNameTV.Text = deserialized_user_data_categs_empty.serviceCategories[1].ToString();
                        }
                        catch { }
                    }
                    onlyWithReviewsS.CheckedChange += async(s, e) =>
                    {
                        if (onlyWithReviewsS.Checked)
                        {
                            onlineValueTV.Text = GetString(Resource.String.online_text);
                            onlineValueTV.SetTextColor(Color.Green);
                            var res = await profileAndExpertMethods.EditMyOnline(userMethods.GetUsersAuthToken(), true);
                        }
                        else
                        {
                            onlineValueTV.SetTextColor(Color.Red);
                            onlineValueTV.Text = GetString(Resource.String.offline_text);
                            var res = await profileAndExpertMethods.EditMyOnline(userMethods.GetUsersAuthToken(), false);
                        }
                    };

                    var folder = Android.OS.Environment.ExternalStorageDirectory + Java.IO.File.Separator + "DCIM/Camera";
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }

                    //var filesList
                    List <string> filesList = new List <string>();
                    try
                    {
                        filesList = Directory.GetFiles(folder).ToList <string>();
                    }
                    catch (Exception ex)
                    {
                    }
                    var reverseList = filesList.AsEnumerable().Reverse().ToList <string>();
                    reverseList.Insert(0, Resource.Drawable.open_camera.ToString());
                    reverseList.Insert(1, Resource.Drawable.open_gallery.ToString());

                    var gridview = FindViewById <GridView>(Resource.Id.gridview);
                    gridview.Adapter = new ImageAdapter(this, reverseList, Resources.DisplayMetrics.WidthPixels);

                    gridview.ItemClick += async delegate(object sender, AdapterView.ItemClickEventArgs args)
                    {
                        previous_base64 = "dsaads";

                        if (args.Position > 1)
                        {
                            Glide.With(Application.Context)
                            .Load(reverseList[args.Position])
                            //.Placeholder(Resource.Drawable.specialization_imageIV)
                            .Into(profile_image);
                            new UserProfileExpandableAdapter().LoadImage(reverseList[args.Position], null, null);
                            try { userProfileExpandableAdapter.NotifyDataSetChanged(); } catch { }
                        }
                        else if (args.Position == 0)
                        {
                            if (pictureMethods.IsThereAnAppToTakePictures(this))
                            {
                                PictureMethods.cameraOrGalleryIndicator = "camera";
                                pictureMethods.CreateDirectoryForPictures();
                                pictureMethods.TakeAPicture(this);
                            }
                        }
                        else if (args.Position == 1)
                        {
                            PictureMethods.cameraOrGalleryIndicator = "gallery";
                            var imageIntent = new Intent();
                            imageIntent.SetType("image/*");
                            //imageIntent.SetType("file/*");
                            imageIntent.SetAction(Intent.ActionGetContent);
                            StartActivityForResult(
                                Intent.CreateChooser(imageIntent, "Select photo"), 0);
                        }

                        if (args.Position > 1)
                        {
                            if (!String.IsNullOrEmpty(previous_base64))
                            {
                                try
                                {
                                    chosen_bitmap = ((BitmapDrawable)profile_image.Drawable).Bitmap;
                                    MemoryStream chosen_memStream = new MemoryStream();
                                    chosen_bitmap.Compress(Bitmap.CompressFormat.Png, 0, chosen_memStream);
                                    byte[] chosen_ba = chosen_memStream.ToArray();
                                    chosen_base64 = Base64.EncodeToString(chosen_ba, Base64.Default);
                                }
                                catch { }
                                timer.Elapsed += delegate
                                {
                                    try
                                    {
                                        chosen_bitmap = ((BitmapDrawable)profile_image.Drawable).Bitmap;
                                        MemoryStream chosen_memStream = new MemoryStream();
                                        chosen_bitmap.Compress(Bitmap.CompressFormat.Jpeg, 90, chosen_memStream);
                                        byte[] chosen_ba = chosen_memStream.ToArray();
                                        chosen_base64 = Base64.EncodeToString(chosen_ba, Base64.Default);
                                        if (chosen_base64 != previous_base64)
                                        {
                                            RunOnUiThread(async() =>
                                            {
                                                var res = await upload_avatar();
                                                if (res != null)
                                                {
                                                    timer.Stop();
                                                    var intent = new Intent(this, typeof(UserProfileActivity));
                                                    intent.SetFlags(ActivityFlags.NoHistory);
                                                    intent.SetFlags(ActivityFlags.NewTask);
                                                    StartActivity(intent);
                                                    Finish();
                                                }
                                            });
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                };
                                timer.Start();
                                timer.Enabled = true;
                            }
                        }
                    };

                    tintLL.Click += (s, e) =>
                    {
                        add_skillIV.Visibility = ViewStates.Visible;
                        tintLL.Visibility      = ViewStates.Gone;
                        gridLL.Visibility      = ViewStates.Gone;
                    };
                    add_skillIV.Click += (s, e) =>
                    {
                        StartActivity(typeof(YourSpecializationActivity));
                    };
                    editBn.Click += (s, e) =>
                    {
                        StartActivity(typeof(PersonalDataActivity));
                    };

                    choose_photoIV.Click += async(s, e) =>
                    {
                        var granted = await checkCameraPermission();

                        if (!granted)
                        {
                            return;
                        }
                        if (tintLL.Visibility == ViewStates.Visible)
                        {
                            tintLL.Visibility      = ViewStates.Gone;
                            gridLL.Visibility      = ViewStates.Gone;
                            add_skillIV.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            tintLL.Visibility      = ViewStates.Visible;
                            gridLL.Visibility      = ViewStates.Visible;
                            add_skillIV.Visibility = ViewStates.Gone;
                        }
                    };
                }
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }