예제 #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.ThreeLevelUserProfile);

                dialogsTV           = FindViewById <TextView>(Resource.Id.dialogsTV);
                message_indicatorIV = FindViewById <ImageView>(Resource.Id.message_indicatorIV);
                loginRegFragment    = new LoginRegFragment();
                fragmentManager     = this.FragmentManager;
                loc_pref            = Application.Context.GetSharedPreferences("coordinates", FileCreationMode.Private);
                activityIndicator   = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                ProfileAndExpertMethods profileAndExpertMethods = new ProfileAndExpertMethods();
                PCL.HttpMethods.ProfileAndExpertMethods profileAndExpertMethodsPCL = new PCL.HttpMethods.ProfileAndExpertMethods();
                expert_data = Application.Context.GetSharedPreferences("experts", FileCreationMode.Private);
                edit_expert = expert_data.Edit();

                profileLL        = FindViewById <LinearLayout>(Resource.Id.profileLL);
                dialogsLL        = FindViewById <LinearLayout>(Resource.Id.dialogsLL);
                profileLL.Click += (s, e) =>
                {
                    if (userMethods.UserExists())
                    {
                        StartActivity(typeof(UserProfileActivity));
                    }
                    else
                    {
                        try { loginRegFragment.Show(fragmentManager, "fragmentManager"); }
                        catch { Toast.MakeText(this, GetString(Resource.String.you_not_logined), ToastLength.Short).Show(); StartActivity(typeof(MainActivity)); }
                    }
                };
                dialogsLL.Click += (s, e) =>
                {
                    if (userMethods.UserExists())
                    {
                        edit_dialog = dialog_data.Edit();
                        edit_dialog.PutString("come_from", "Came directly from bottom");
                        edit_dialog.Apply();
                        StartActivity(typeof(ChatListActivity));
                    }
                    else
                    {
                        try { loginRegFragment.Show(fragmentManager, "fragmentManager"); }
                        catch { Toast.MakeText(this, GetString(Resource.String.you_not_logined), ToastLength.Short).Show(); StartActivity(typeof(MainActivity)); }
                    }
                };
                initWidget();
                activityIndicator.Visibility = ViewStates.Visible;
                recyclerView.Visibility      = ViewStates.Gone;
                var expert_json = await profileAndExpertMethodsPCL.ExpertProfile(expert_data.GetString("expert_id", String.Empty), loc_pref.GetString("latitude", String.Empty), loc_pref.GetString("longitude", String.Empty));

                activityIndicator.Visibility = Android.Views.ViewStates.Gone;
                recyclerView.Visibility      = ViewStates.Visible;
                deserialized_expert_profile  = JsonConvert.DeserializeObject <ExpertProfile>(expert_json);
                edit_expert_feedback         = expert_feedback_pref.Edit();
                edit_expert_feedback.PutString("expert_id", deserialized_expert_profile.id);
                edit_expert_feedback.PutString("expert_name", deserialized_expert_profile.fullName);
                edit_expert_feedback.PutString("expert_phone", deserialized_expert_profile.phone);
                edit_expert_feedback.PutBoolean("expert_online", deserialized_expert_profile.online);
                edit_expert_feedback.PutString("expert_avatar", deserialized_expert_profile.avatarUrl);
                try
                {
                    edit_expert_feedback.PutString("expert_category_id", deserialized_expert_profile.serviceCategories[0].categoryId);
                }
                catch { }
                edit_expert_feedback.Apply();
                initData();
            }
            catch (Exception ex)
            {
                StartActivity(typeof(MainActivity));
            }
        }
예제 #2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.main);

            PCL.HttpMethods.ProfileAndExpertMethods ksg = new PCL.HttpMethods.ProfileAndExpertMethods();



            loginRegFragment = new LoginRegFragment();
            fragmentManager  = this.FragmentManager;

            edit_dialog = dialog_data.Edit();
            if (Intent.Extras != null)
            {
                string type = "";
                foreach (var key in Intent.Extras.KeySet())
                {
                    var value = Intent.Extras.GetString(key);
                    Log.Debug(TAG, "Key: {0} Value: {1}", key, value);
                    if (key == "message_from")
                    {
                        edit_dialog.PutString("expert_id", value);
                    }
                    if (key == "name")
                    {
                        edit_dialog.PutString("expert_name", value);
                    }
                    if (key == "avatar")
                    {
                        edit_dialog.PutString("expert_avatar", value);
                    }
                    if (key == "type")
                    {
                        type = value;
                    }
                    //
                    //break;
                }
                edit_dialog.Apply();
                from_push = true;
                if (type == "message")
                {
                    StartActivity(typeof(DialogActivity));
                }
                else
                {
                    string review_id         = "";
                    string reviewText        = "";
                    string reviewAnswer      = "";
                    string companionId       = "";
                    string companionFullName = "";
                    string companionAvatar   = "";
                    string myFullName        = "";
                    string myId        = "";
                    string myAvatar    = "";
                    string is_online   = "";
                    string timestamp   = "";
                    string rating      = "";
                    string categoryId  = "";
                    string msg_cnt_new = "";

                    foreach (var key in Intent.Extras.KeySet())
                    {
                        var value = Intent.Extras.GetString(key);
                        if (key == "review_id")
                        {
                            review_id = value;
                        }
                        if (key == "reviewText")
                        {
                            reviewText = value;
                        }
                        if (key == "reviewAnswer")
                        {
                            reviewAnswer = value;
                        }
                        if (key == "companionId")
                        {
                            companionId = value;
                        }
                        if (key == "companionFullName")
                        {
                            companionFullName = value;
                        }
                        if (key == "companionAvatar")
                        {
                            companionAvatar = value;
                        }
                        if (key == "myFullName")
                        {
                            myFullName = value;
                        }
                        if (key == "myAvatar")
                        {
                            myAvatar = value;
                        }
                        if (key == "is_online")
                        {
                            is_online = value;
                        }
                        if (key == "timestamp")
                        {
                            timestamp = value;
                        }
                        if (key == "rating")
                        {
                            rating = value;
                        }
                        if (key == "categoryId")
                        {
                            categoryId = value;
                        }
                        if (key == "myId")
                        {
                            myId = value;
                        }
                        if (key == "msg_cnt_new")
                        {
                            msg_cnt_new = value;
                        }
                    }
                    var activity2 = new Intent(this, typeof(ReviewFromPushActivity));
                    activity2.PutExtra("type", type);
                    activity2.PutExtra("review_id", review_id);
                    activity2.PutExtra("reviewText", reviewText);
                    activity2.PutExtra("companionId", companionId);
                    activity2.PutExtra("companionFullName", companionFullName);
                    activity2.PutExtra("companionAvatar", companionAvatar);
                    activity2.PutExtra("myFullName", myFullName);
                    activity2.PutExtra("myAvatar", myAvatar);
                    activity2.PutExtra("reviewAnswer", reviewAnswer);
                    activity2.PutExtra("review_rating", rating);
                    activity2.PutExtra("review_date", timestamp);
                    activity2.PutExtra("review_online", is_online);
                    activity2.PutExtra("categoryId", categoryId);
                    activity2.PutExtra("myId", myId);
                    activity2.PutExtra("msg_cnt_new", msg_cnt_new);
                    StartActivity(activity2);
                }
            }
            else
            {
                from_push = false;
            }

            IsPlayServicesAvailable();

            CreateNotificationChannel();

            AppCenter.Start("0a86243f-1b34-4bca-bc65-133580015fc1", typeof(Analytics), typeof(Crashes));
            var    context       = Application.Context;
            String androidOS     = Build.VERSION.Release;
            String androidId     = Settings.Secure.GetString(context.ContentResolver, Settings.Secure.AndroidId);
            var    VersionNumber = context.PackageManager.GetPackageInfo(context.PackageName, PackageInfoFlags.MetaData).VersionName;
            var    package_name  = context.PackageName;

            var device_obj = new PCL.Models.Device
            {
                platform    = "Android",
                deviceToken = androidId,
                osVersion   = androidOS,
                appVersion  = VersionNumber,
                packageName = package_name,
            };

            var device_Json = JsonConvert.SerializeObject(device_obj);

            device_info_prefs      = Application.Context.GetSharedPreferences("device_info", FileCreationMode.Private);
            edit_device_info_prefs = device_info_prefs.Edit();
            edit_device_info_prefs.PutString("device_json", device_Json);
            new MyFirebaseIIDService().OnTokenRefresh();
            var tokenFirebase = await GetToken();

            edit_device_info_prefs.PutString("firebase_token", tokenFirebase);
            edit_device_info_prefs.Apply();

            loc_pref           = Application.Context.GetSharedPreferences("coordinates", FileCreationMode.Private);
            edit               = loc_pref.Edit();
            i_need_help_LL     = FindViewById <RelativeLayout>(Resource.Id.i_need_help_LL);
            i_want_to_help_LL  = FindViewById <RelativeLayout>(Resource.Id.i_want_to_help_LL);
            LogoRL             = FindViewById <RelativeLayout>(Resource.Id.LogoRL);
            mainRL             = FindViewById <RelativeLayout>(Resource.Id.mainRL);
            tintLL             = FindViewById <RelativeLayout>(Resource.Id.tintLL);
            EnterMyAccTV       = FindViewById <TextView>(Resource.Id.EnterMyAccTV);
            your_city_valueTV  = FindViewById <TextView>(Resource.Id.your_city_valueTV);
            getting_positionTV = FindViewById <TextView>(Resource.Id.getting_positionTV);
            noTV               = FindViewById <TextView>(Resource.Id.noTV);
            yesTV              = FindViewById <TextView>(Resource.Id.yesTV);
            restartBn          = FindViewById <Button>(Resource.Id.restartBn);
            activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
            activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);

            Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");

            EnterMyAccTV.SetTypeface(tf, TypefaceStyle.Normal);
            your_city_valueTV.SetTypeface(tf, TypefaceStyle.Normal);
            getting_positionTV.SetTypeface(tf, TypefaceStyle.Normal);
            noTV.SetTypeface(tf, TypefaceStyle.Normal);
            yesTV.SetTypeface(tf, TypefaceStyle.Normal);
            FindViewById <TextView>(Resource.Id.textView5).SetTypeface(tf, TypefaceStyle.Normal);
            FindViewById <TextView>(Resource.Id.textView4).SetTypeface(tf, TypefaceStyle.Normal);
            FindViewById <TextView>(Resource.Id.textView3).SetTypeface(tf, TypefaceStyle.Bold);
            FindViewById <TextView>(Resource.Id.textView2).SetTypeface(tf, TypefaceStyle.Bold);
            restartBn.SetTypeface(tf, TypefaceStyle.Normal);

            restartBn.Visibility  = ViewStates.Gone;
            i_need_help_LL.Click += (s, e) =>
            {
                if (tintLL.Visibility != ViewStates.Visible)
                {
                    StartActivity(typeof(SpecialistsCategoryActivity));
                }
            };
            i_want_to_help_LL.Click += (s, e) =>
            {
                if (tintLL.Visibility != ViewStates.Visible)
                {
                    try
                    {
                        if (!userMethods.UserExists())
                        {
                            loginRegFragment.Show(fragmentManager, "fragmentManager");
                        }
                        else
                        {
                            StartActivity(typeof(UserProfileActivity));
                        }
                    }
                    catch { Toast.MakeText(this, GetString(Resource.String.you_not_logined), ToastLength.Short).Show(); StartActivity(typeof(MainActivity)); }
                }
            };
            EnterMyAccTV.Click += (s, e) =>
            {
                if (tintLL.Visibility != ViewStates.Visible)
                {
                    StartActivity(typeof(AuthorizationActivity));
                }
            };

            if (userMethods.UserExists())
            {
                EnterMyAccTV.Visibility = ViewStates.Gone;
            }

            if (checkInternetConnection())
            {
                //checking if GPS is enabled
                if (IsGeolocationEnabled())
                {
                    activityIndicator.Visibility = ViewStates.Visible;
                    await Geolocation();
                }
                else
                {
                    turnGPSon();
                }
            }
            else
            {
                restartBn.Visibility          = ViewStates.Visible;
                activityIndicator.Visibility  = ViewStates.Gone;
                getting_positionTV.Visibility = ViewStates.Gone;
                Toast.MakeText(this, Resource.String.turn_internet_on, ToastLength.Long).Show();
            }
            restartBn.Click += (s, e) =>
            {
                StartActivity(typeof(MainActivity));
            };
            var granted = await checkLocPermission();

            if (!granted)
            {
                checkLocPermission();
            }

            if (checkInternetConnection() && IsGeolocationEnabled())
            {
                if (userMethods.UserExists())
                {
                    if (!from_push)
                    {
                        StartActivity(typeof(UserProfileActivity));
                    }
                }
            }
        }