private static async Task RemoveData(string type)
        {
            try
            {
                if (type == "Logout")
                {
                    if (Methods.CheckConnectivity())
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            RequestsAsync.Global.Get_Delete_Token
                        });
                    }
                }
                else if (type == "Delete")
                {
                    if (Methods.CheckConnectivity())
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Global.Delete_User(UserDetails.Password)
                        });
                    }
                }

                try
                {
                    if (AppSettings.ShowGoogleLogin && LoginActivity.MGoogleApiClient != null)
                    {
                        if (Auth.GoogleSignInApi != null)
                        {
                            Auth.GoogleSignInApi.SignOut(LoginActivity.MGoogleApiClient);
                            LoginActivity.MGoogleApiClient.Disconnect();
                            LoginActivity.MGoogleApiClient = null;
                        }
                    }

                    if (AppSettings.ShowFacebookLogin)
                    {
                        var accessToken = AccessToken.CurrentAccessToken;
                        var isLoggedIn  = accessToken != null && !accessToken.IsExpired;
                        if (isLoggedIn && Profile.CurrentProfile != null)
                        {
                            LoginManager.Instance.LogOut();
                        }
                    }

                    OneSignalNotification.Un_RegisterNotificationDevice();

                    ListUtils.ClearAllList();

                    UserDetails.ClearAllValueUserDetails();

                    Methods.DeleteNoteOnSD();

                    TabbedMainActivity.Receiver = null;

                    GC.Collect();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
                await Task.Delay(0);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Esempio n. 2
0
        private static async Task SetLangUserAsync()
        {
            try
            {
                if (string.IsNullOrEmpty(Current.AccessToken) || !AppSettings.SetLangUser)
                {
                    return;
                }

                string lang;
                if (UserDetails.LangName.Contains("en"))
                {
                    lang = "english";
                }
                else if (UserDetails.LangName.Contains("ar"))
                {
                    lang = "arabic";
                }
                else if (UserDetails.LangName.Contains("de"))
                {
                    lang = "german";
                }
                else if (UserDetails.LangName.Contains("el"))
                {
                    lang = "greek";
                }
                else if (UserDetails.LangName.Contains("es"))
                {
                    lang = "spanish";
                }
                else if (UserDetails.LangName.Contains("fr"))
                {
                    lang = "french";
                }
                else if (UserDetails.LangName.Contains("it"))
                {
                    lang = "italian";
                }
                else if (UserDetails.LangName.Contains("ja"))
                {
                    lang = "japanese";
                }
                else if (UserDetails.LangName.Contains("nl"))
                {
                    lang = "dutch";
                }
                else if (UserDetails.LangName.Contains("pt"))
                {
                    lang = "portuguese";
                }
                else if (UserDetails.LangName.Contains("ro"))
                {
                    lang = "romanian";
                }
                else if (UserDetails.LangName.Contains("ru"))
                {
                    lang = "russian";
                }
                else if (UserDetails.LangName.Contains("sq"))
                {
                    lang = "albanian";
                }
                else if (UserDetails.LangName.Contains("sr"))
                {
                    lang = "serbian";
                }
                else if (UserDetails.LangName.Contains("tr"))
                {
                    lang = "turkish";
                }
                else
                {
                    lang = string.IsNullOrEmpty(UserDetails.LangName) ? AppSettings.Lang : "";
                }

                await Task.Factory.StartNew(() =>
                {
                    if (lang != "")
                    {
                        var dataPrivacy = new Dictionary <string, string>
                        {
                            { "language", lang }
                        };

                        var dataUser = ListUtils.MyProfileList.FirstOrDefault();
                        if (dataUser != null)
                        {
                            dataUser.Language = lang;

                            var sqLiteDatabase = new SqLiteDatabase();
                            sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser);
                            sqLiteDatabase.Dispose();
                        }

                        if (Methods.CheckConnectivity())
                        {
                            PollyController.RunRetryPolicyFunction(new List <Func <Task> >
                            {
                                () => RequestsAsync.Global.Update_User_Data(dataPrivacy)
                            });
                        }
                        else
                        {
                            Toast.MakeText(Application.Context, Application.Context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
                        }
                    }
                });
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private static async Task SetLangUserAsync(Activity context)
        {
            try
            {
                if (string.IsNullOrEmpty(Current.AccessToken) || !AppSettings.SetLangUser)
                {
                    return;
                }

                string lang;
                if (AppSettings.Lang.Contains("en"))
                {
                    lang = "english";
                }
                else if (AppSettings.Lang.Contains("ar"))
                {
                    lang = "arabic";
                }
                else if (AppSettings.Lang.Contains("de"))
                {
                    lang = "german";
                }
                else if (AppSettings.Lang.Contains("el"))
                {
                    lang = "greek";
                }
                else if (AppSettings.Lang.Contains("es"))
                {
                    lang = "spanish";
                }
                else if (AppSettings.Lang.Contains("fr"))
                {
                    lang = "french";
                }
                else if (AppSettings.Lang.Contains("it"))
                {
                    lang = "italian";
                }
                else if (AppSettings.Lang.Contains("ja"))
                {
                    lang = "japanese";
                }
                else if (AppSettings.Lang.Contains("nl"))
                {
                    lang = "dutch";
                }
                else if (AppSettings.Lang.Contains("pt"))
                {
                    lang = "portuguese";
                }
                else if (AppSettings.Lang.Contains("ro"))
                {
                    lang = "romanian";
                }
                else if (AppSettings.Lang.Contains("ru"))
                {
                    lang = "russian";
                }
                else if (AppSettings.Lang.Contains("sq"))
                {
                    lang = "albanian";
                }
                else if (AppSettings.Lang.Contains("sr"))
                {
                    lang = "serbian";
                }
                else if (AppSettings.Lang.Contains("tr"))
                {
                    lang = "turkish";
                }
                else
                {
                    lang = string.IsNullOrEmpty(UserDetails.LangName) ? UserDetails.LangName : "english";
                }

                var dataPrivacy = new Dictionary <string, string>
                {
                    { "language", lang }
                };

                if (Methods.CheckConnectivity())
                {
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Global.Update_User_Data(dataPrivacy)
                    });
                }
                else
                {
                    Toast.MakeText(context, context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }

                await Task.Delay(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }