コード例 #1
0
        public static async Task Get_MyProfileData_Api(Activity context)
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Global.Get_User_Data(UserDetails.UserId);

                if (apiStatus == 200)
                {
                    if (respond is GetUserDataObject result)
                    {
                        UserDetails.Avatar   = result.UserData.Avatar;
                        UserDetails.Cover    = result.UserData.Cover;
                        UserDetails.Username = result.UserData.Username;
                        UserDetails.FullName = result.UserData.Name;
                        UserDetails.Email    = result.UserData.Email;

                        ListUtils.MyProfileList = new ObservableCollection <UserDataObject> {
                            result.UserData
                        };

                        Glide.With(context).Load(UserDetails.Avatar).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CircleCrop()).Preload();

                        if (result.JoinedGroups.Count > 0)
                        {
                            var listGroup = result.JoinedGroups.Where(a => a.UserId == UserDetails.UserId).ToList();
                            if (listGroup.Count > 0)
                            {
                                ListUtils.MyGroupList = new ObservableCollection <GroupClass>(listGroup);
                            }
                        }

                        if (result.LikedPages.Count > 0)
                        {
                            var listPage = result.LikedPages.Where(a => a.UserId == UserDetails.UserId).ToList();
                            if (listPage.Count > 0)
                            {
                                ListUtils.MyPageList = new ObservableCollection <PageClass>(listPage);
                            }
                        }

                        context.RunOnUiThread(() =>
                        {
                            SqLiteDatabase dbDatabase = new SqLiteDatabase();
                            dbDatabase.Insert_Or_Update_To_MyProfileTable(result.UserData);
                            dbDatabase.Insert_Or_Replace_MyFollowersTable(new ObservableCollection <UserDataObject>(result.Followers));
                            dbDatabase.Insert_Or_Replace_MyContactTable(new ObservableCollection <UserDataObject>(result.Following));
                            dbDatabase.Dispose();
                        });
                    }
                }
                else
                {
                    Methods.DisplayReportResult(context, respond);
                }
            }
        }
コード例 #2
0
        public static async Task Get_MyProfileData_Api(Activity context)
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Global.Get_User_Data(UserDetails.UserId, "user_data,followers,following");

                if (apiStatus == 200)
                {
                    if (respond is GetUserDataObject result)
                    {
                        UserDetails.Avatar   = result.UserData.Avatar;
                        UserDetails.Cover    = result.UserData.Cover;
                        UserDetails.Username = result.UserData.Username;
                        UserDetails.FullName = result.UserData.Name;
                        UserDetails.Email    = result.UserData.Email;

                        ListUtils.MyProfileList = new ObservableCollection <UserDataObject> {
                            result.UserData
                        };

                        context.RunOnUiThread(() =>
                        {
                            try
                            {
                                SqLiteDatabase dbDatabase = new SqLiteDatabase();

                                // user_data
                                if (result.UserData != null)
                                {
                                    //Insert Or Update All data user_data
                                    dbDatabase.Insert_Or_Update_To_MyProfileTable(result.UserData);
                                }

                                if (result.Following.Count > 0)
                                {
                                    //Insert Or Update All data Groups
                                    dbDatabase.Insert_Or_Replace_MyContactTable(new ObservableCollection <UserDataObject>(result.Following));
                                }

                                if (result.Followers.Count > 0)
                                {
                                    //Insert Or Update All data Groups
                                    dbDatabase.Insert_Or_Replace_MyFollowersTable(new ObservableCollection <UserDataObject>(result.Followers));
                                }

                                dbDatabase.Dispose();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                }
            }
        }
コード例 #3
0
        public void Run()
        {
            try
            {
                //Toast.MakeText(Application.Context, "AppState " + Methods.AppLifecycleObserver.AppState, ToastLength.Short).Show();

                if (string.IsNullOrEmpty(Methods.AppLifecycleObserver.AppState))
                {
                    Methods.AppLifecycleObserver.AppState = "Background";
                }

                switch (Methods.AppLifecycleObserver.AppState)
                {
                case "Background":
                {
                    if (string.IsNullOrEmpty(Client.WebsiteUrl))
                    {
                        Client a = new Client(AppSettings.TripleDesAppServiceProvider);
                        Console.WriteLine(a);
                    }

                    SqLiteDatabase dbDatabase = new SqLiteDatabase();

                    if (string.IsNullOrEmpty(Current.AccessToken))
                    {
                        var login = dbDatabase.Get_data_Login_Credentials();
                        Console.WriteLine(login);
                    }

                    if (string.IsNullOrEmpty(Current.AccessToken))
                    {
                        return;
                    }

                    if (Methods.CheckConnectivity())
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                ApiPostAsync.FetchFirstNewsFeedApiPosts
                            });
                    }

                    //Toast.MakeText(Application.Context, "ResultSender wael", ToastLength.Short).Show();
                    MainHandler ??= new Handler(Looper.MainLooper);
                    MainHandler?.PostDelayed(new PostUpdaterHelper(new Handler(Looper.MainLooper)), AppSettings.RefreshPostSeconds);
                    break;
                }
                }
            }
            catch (Exception e)
            {
                //Toast.MakeText(Application.Context, "ResultSender failed",ToastLength.Short)?.Show();
                MainHandler ??= new Handler(Looper.MainLooper);
                MainHandler?.PostDelayed(new PostUpdaterHelper(new Handler(Looper.MainLooper)), AppSettings.RefreshPostSeconds);
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #4
0
        private void RejectCallButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (CallType == "Twilio_video_call")
                {
                    RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Video).ConfigureAwait(false);
                }
                else if (CallType == "Twilio_audio_call")
                {
                    RequestsAsync.Call.DeclineCallAsync(UserDetails.UserId, CallId, TypeCall.Audio).ConfigureAwait(false);
                }
                else if (CallType == "Agora_video_call_recieve" || CallType == "Agora_audio_call_recieve")
                {
                    ApiRequest.Send_Agora_Call_Action_Async("decline", CallId).ConfigureAwait(false);
                }

                if (!string.IsNullOrEmpty(CallId))
                {
                    var ckd = TabbedMainActivity.GetInstance().LastCallsTab?.MAdapter?.MCallUser?.FirstOrDefault(a => a.Id == CallId); // id >> Call_Id
                    if (ckd == null)
                    {
                        Classes.CallUser cv = new Classes.CallUser
                        {
                            Id           = CallId,
                            UserId       = UserId,
                            Avatar       = Avatar,
                            Name         = Name,
                            AccessToken  = TwilioAccessToken,
                            AccessToken2 = TwilioAccessTokenUser2,
                            FromId       = FromId,
                            Active       = Active,
                            Time         = "Missed call",
                            Status       = Status,
                            RoomName     = RoomName,
                            Type         = CallType,
                            TypeIcon     = "Cancel",
                            TypeColor    = "#FF0000"
                        };

                        TabbedMainActivity.GetInstance().LastCallsTab.MAdapter?.Insert(cv);

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();
                        dbDatabase.Insert_CallUser(cv);
                        dbDatabase.Dispose();
                    }
                }

                FinishVideoAudio();
            }
            catch (Exception exception)
            {
                FinishVideoAudio();
                Console.WriteLine(exception);
            }
        }
コード例 #5
0
ファイル: SplashScreenActivity.cs プロジェクト: surnek/tm-15v
        private void FirstRunExcite()
        {
            try
            {
                DbDatabase = new SqLiteDatabase();
                DbDatabase.CheckTablesStatus();

                if (!string.IsNullOrEmpty(AppSettings.Lang))
                {
                    LangController.SetApplicationLang(this, AppSettings.Lang);
                }
                else
                {
                    UserDetails.LangName = Resources.Configuration.Locales.Get(0).Language.ToLower();
                    LangController.SetApplicationLang(this, UserDetails.LangName);
                }

                var result = DbDatabase.Get_data_Login_Credentials();
                if (result != null)
                {
                    Current.AccessToken = result.AccessToken;

                    switch (result.Status)
                    {
                    case "Active":
                        UserDetails.IsLogin = true;
                        StartActivity(new Intent(this, typeof(HomeActivity)));
                        break;

                    case "Pending":
                        UserDetails.IsLogin = false;
                        StartActivity(new Intent(this, typeof(HomeActivity)));
                        break;

                    default:
                        StartActivity(new Intent(this, typeof(FirstActivity)));
                        break;
                    }
                }
                else
                {
                    StartActivity(new Intent(this, typeof(FirstActivity)));
                }
                DbDatabase.Dispose();

                if (AppSettings.ShowAdMobBanner || AppSettings.ShowAdMobInterstitial || AppSettings.ShowAdMobRewardVideo)
                {
                    MobileAds.Initialize(this, GetString(Resource.String.admob_app_id));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Toast.MakeText(this, e.Message, ToastLength.Short).Show();
            }
        }
コード例 #6
0
        public static async void Logout(Activity context)
        {
            try
            {
                if (RunLogout == false)
                {
                    RunLogout = true;

                    await RemoveData("Logout");

                    context.RunOnUiThread(() =>
                    {
                        Methods.Path.DeleteAll_MyFolderDisk();

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();

                        Runtime.GetRuntime().RunFinalization();
                        Runtime.GetRuntime().Gc();
                        TrimCache(context);

                        dbDatabase.ClearAll();
                        dbDatabase.DropAll();

                        ListUtils.ClearAllList();

                        UserDetails.ClearAllValueUserDetails();

                        dbDatabase.CheckTablesStatus();
                        dbDatabase.Dispose();

                        var intentService = new Intent(context, typeof(ScheduledApiService));
                        context.StopService(intentService);

                        HomeActivity.GetInstance()?.NewsFeedFragment?.MainHandler?.RemoveCallbacks(HomeActivity.GetInstance().NewsFeedFragment.Runnable);
                        HomeActivity.GetInstance().NewsFeedFragment.MainHandler = null;

                        MainSettings.SharedData.Edit().Clear().Commit();

                        Intent intent = new Intent(context, typeof(FirstActivity));
                        intent.AddCategory(Intent.CategoryHome);
                        intent.SetAction(Intent.ActionMain);
                        intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);
                        context.StartActivity(intent);
                        context.FinishAffinity();
                        context.Finish();
                    });

                    RunLogout = false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #7
0
        public void OnSelection(MaterialDialog p0, View p1, int itemId, ICharSequence itemString)
        {
            try
            {
                if (itemString.ToString() == GetText(Resource.String.Lbl_CreateNewGroup))
                {
                    StartActivity(new Intent(Activity, typeof(CreateGroupChatActivity)));
                }
                else if (itemString.ToString() == GetText(Resource.String.Lbl_GroupRequest))
                {
                    StartActivity(new Intent(Activity, typeof(GroupRequestActivity)));
                }
                else if (itemString.ToString() == GetText(Resource.String.Lbl_Blocked_User_List))
                {
                    StartActivity(new Intent(Activity, typeof(BlockedUsersActivity)));
                }
                else if (itemString.ToString() == GetText(Resource.String.Lbl_Settings))
                {
                    StartActivity(new Intent(Activity, typeof(GeneralAccountActivity)));
                }
                else if (itemString.ToString() == GetText(Resource.String.Lbl_Clear_call_log))
                {
                    var dialog = new MaterialDialog.Builder(Activity).Theme(AppSettings.SetTabDarkTheme
                        ? Theme.Dark
                        : Theme.Light);
                    dialog.Title(GetText(Resource.String.Lbl_Warning));
                    dialog.Content(GetText(Resource.String.Lbl_Clear_call_log));
                    dialog.PositiveText(GetText(Resource.String.Lbl_Yes)).OnPositive((materialDialog, action) =>
                    {
                        try
                        {
                            LastCallsTab?.MAdapter?.MCallUser?.Clear();
                            LastCallsTab?.MAdapter?.NotifyDataSetChanged();
                            LastCallsTab?.ShowEmptyPage();

                            //Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long)?.Show();

                            SqLiteDatabase dbDatabase = new SqLiteDatabase();
                            dbDatabase.Clear_CallUser_List();
                        }
                        catch (Exception e)
                        {
                            Methods.DisplayReportResultTrack(e);
                        }
                    });
                    dialog.NegativeText(GetText(Resource.String.Lbl_No)).OnNegative(new WoWonderTools.MyMaterialDialog());
                    dialog.AlwaysCallSingleChoiceCallback();
                    dialog.Build().Show();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #8
0
        //Status >> OnlineUser
        private void PrivacyOnlineUserPref_OnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs)
        {
            try
            {
                if (eventArgs.Handled)
                {
                    var dataUser = ListUtils.MyProfileList?.FirstOrDefault();
                    var etp      = (SwitchPreferenceCompat)sender;
                    var value    = eventArgs.NewValue.ToString();
                    etp.Checked = bool.Parse(value);
                    if (etp.Checked) //Online >> value = 0
                    {
                        SOnlineUsersPref = "0";

                        if (dataUser != null)
                        {
                            dataUser.Status = "0";
                            var sqLiteDatabase = new SqLiteDatabase();
                            sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser);
                        }
                    }
                    else //Offline >> value = 1
                    {
                        SOnlineUsersPref = "1";

                        if (dataUser != null)
                        {
                            dataUser.Status = "1";
                            var sqLiteDatabase = new SqLiteDatabase();
                            sqLiteDatabase.Insert_Or_Update_To_MyProfileTable(dataUser);
                        }
                    }

                    if (Methods.CheckConnectivity())
                    {
                        var dataPrivacy = new Dictionary <string, string>
                        {
                            { "status", SOnlineUsersPref }
                        };

                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Global.Update_User_Data(dataPrivacy)
                        });
                    }
                    else
                    {
                        Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #9
0
        //Get Messages From API
        private async void GetMessages_API()
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    SwipeRefreshLayout.Refreshing = false;
                    SwipeRefreshLayout.Enabled    = false;

                    Toast.MakeText(this, Resource.String.Lbl_CheckYourInternetConnection, ToastLength.Long).Show();
                }
                else
                {
                    BeforeMessageId = "0";

                    var(apiStatus, respond) = await RequestsAsync.Messages.GetUserMessages(Userid, "30", "0");

                    if (apiStatus == 200)
                    {
                        if (respond is GetUserMessagesObject result)
                        {
                            if (result.data.Messages.Count > 0)
                            {
                                MAdapter.MessageList = new ObservableCollection <GetUserMessagesObject.Message>(result.data.Messages.OrderBy(a => a.Time));
                                MAdapter.BindEnd();

                                //Insert to DataBase
                                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                                dbDatabase.InsertOrReplaceMessages(MAdapter.MessageList);
                                dbDatabase.Dispose();

                                //Scroll Down >>
                                ChatBoxRecylerView.ScrollToPosition(MAdapter.MessageList.Count - 1);

                                SwipeRefreshLayout.Refreshing = false;
                                SwipeRefreshLayout.Enabled    = false;
                            }
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }

                    SwipeRefreshLayout.Refreshing = false;
                    SwipeRefreshLayout.Enabled    = false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                SwipeRefreshLayout.Refreshing = false;
                SwipeRefreshLayout.Enabled    = false;
            }
        }
コード例 #10
0
        private void NotificationLikedMyPostPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs)
        {
            try
            {
                if (eventArgs.Handled)
                {
                    var dataUser = ListUtils.MyProfileList.FirstOrDefault();
                    var etp      = (SwitchPreferenceCompat)sender;
                    var value    = eventArgs.NewValue.ToString();
                    etp.Checked = bool.Parse(value);
                    if (etp.Checked)
                    {
                        if (dataUser != null)
                        {
                            dataUser.NOnLike = "1";
                        }
                        LikedMyPostPref = "1";
                    }
                    else
                    {
                        if (dataUser != null)
                        {
                            dataUser.NOnLike = "0";
                        }
                        LikedMyPostPref = "0";
                    }

                    if (dataUser != null)
                    {
                        dataUser.NOnLike = LikedMyPostPref;
                    }

                    SqLiteDatabase dbDatabase = new SqLiteDatabase();
                    dbDatabase.InsertOrUpdateToMyProfileTable(dataUser);
                    dbDatabase.Dispose();

                    if (Methods.CheckConnectivity())
                    {
                        var dataPrivacy = new Dictionary <string, string>
                        {
                            { "n_on_like", LikedMyPostPref }
                        };
                        RequestsAsync.User.SaveSettings(dataPrivacy).ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #11
0
        public void Get_CallUser()
        {
            try
            {
                var dbDatabase = new SqLiteDatabase();

                var LocalList = dbDatabase.Get_CallUserList();
                if (LocalList?.Count > 0)
                {
                    if (mAdapter.mCallUser.Count > 0)
                    {
                        //Bring new users
                        var listnew = LocalList.Where(c => !mAdapter.mCallUser.Select(fc => fc.id).Contains(c.id)).ToList(); // id >> Call_Id
                        if (listnew.Count > 0)
                        {
                            //Results differ
                            Classes.AddRange(mAdapter.mCallUser, listnew);

                            var callUser =
                                new ObservableCollection <Classes.Call_User>(mAdapter.mCallUser.OrderBy(a => a.id));
                            mAdapter.mCallUser = new ObservableCollection <Classes.Call_User>(callUser);
                            mAdapter.BindEnd();
                        }
                        else
                        {
                            mAdapter.mCallUser =
                                new ObservableCollection <Classes.Call_User>(LocalList.OrderBy(a => a.id));
                            mAdapter.BindEnd();
                        }
                    }
                    else
                    {
                        mAdapter.mCallUser = new ObservableCollection <Classes.Call_User>(LocalList.OrderBy(a => a.id));
                        mAdapter.BindEnd();
                    }
                }

                if (mAdapter.mCallUser.Count > 0)
                {
                    LastCallsRecyler.Visibility = ViewStates.Visible;
                    LastCalls_Empty.Visibility  = ViewStates.Gone;
                }
                else
                {
                    LastCallsRecyler.Visibility = ViewStates.Gone;
                    LastCalls_Empty.Visibility  = ViewStates.Visible;
                }

                dbDatabase.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #12
0
        private void FirstRunExcite()
        {
            try
            {
                DbDatabase = new SqLiteDatabase();
                DbDatabase.CheckTablesStatus();

                if (!string.IsNullOrEmpty(AppSettings.Lang))
                {
                    LangController.SetApplicationLang(this, AppSettings.Lang);
                }
                else
                {
                    UserDetails.LangName = Resources.Configuration.Locale.Language.ToLower();
                    LangController.SetApplicationLang(this, UserDetails.LangName);
                }

                var result = DbDatabase.Get_data_Login_Credentials();
                if (result != null)
                {
                    switch (result.Status)
                    {
                    case "Active":
                    case "Pending":
                        StartActivity(new Intent(Application.Context, typeof(TabbedMainActivity)));
                        break;

                    default:
                        StartActivity(new Intent(Application.Context, typeof(FirstActivity)));
                        break;
                    }
                }
                else
                {
                    StartActivity(new Intent(Application.Context, typeof(FirstActivity)));
                }

                DbDatabase.Dispose();

                if (AppSettings.ShowAdMobBanner || AppSettings.ShowAdMobInterstitial || AppSettings.ShowAdMobRewardVideo || AppSettings.ShowAdMobNative || AppSettings.ShowAdMobNativePost)
                {
                    MobileAds.Initialize(this, GetString(Resource.String.admob_app_id));
                }

                if (AppSettings.ShowFbBannerAds || AppSettings.ShowFbInterstitialAds || AppSettings.ShowFbRewardVideoAds)
                {
                    InitializeFacebook.Initialize(this);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                Toast.MakeText(this, exception.Message, ToastLength.Short).Show();
            }
        }
コード例 #13
0
        public void OnInput(MaterialDialog p0, ICharSequence p1)
        {
            try
            {
                if (p1.Length() <= 0)
                {
                    return;
                }

                var strName = p1.ToString();
                if (!string.IsNullOrEmpty(strName) || !string.IsNullOrWhiteSpace(strName))
                {
                    switch (TypeDialog)
                    {
                    case "About":
                    {
                        MainSettings.SharedData?.Edit()?.PutString("about_me_key", strName)?.Commit();
                        AboutMePref.Summary = strName;

                        var dataUser = ListUtils.MyProfileList?.FirstOrDefault();
                        if (dataUser != null)
                        {
                            dataUser.About = strName;
                            SAbout         = strName;

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

                        if (Methods.CheckConnectivity())
                        {
                            var dataPrivacy = new Dictionary <string, string>
                            {
                                { "about", strName }
                            };

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    () => RequestsAsync.Global.UpdateUserDataAsync(dataPrivacy)
                                });
                        }
                        else
                        {
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                        }

                        break;
                    }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #14
0
        private void PrivacyCanFollowPrefOnPreferenceChange(object sender, Preference.PreferenceChangeEventArgs eventArgs)
        {
            try
            {
                if (eventArgs.Handled)
                {
                    var etp         = (ListPreference)sender;
                    var value       = eventArgs.NewValue.ToString();
                    var valueAsText = etp.GetEntries()[int.Parse(value)];

                    if (value == "0")
                    {
                        etp.Summary   = ActivityContext.GetString(Resource.String.Lbl_No_body);
                        CanFollowPref = "0";
                    }
                    else if (value == "1")
                    {
                        etp.Summary   = ActivityContext.GetString(Resource.String.Lbl_Followers);
                        CanFollowPref = "1";
                    }
                    else
                    {
                        etp.Summary   = ActivityContext.GetString(Resource.String.Lbl_Everyone);
                        CanFollowPref = "2";
                    }

                    if (Methods.CheckConnectivity())
                    {
                        var dataUser = ListUtils.MyProfileList.FirstOrDefault();
                        if (dataUser != null)
                        {
                            dataUser.PPrivacy = CanFollowPref;
                        }

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();
                        dbDatabase.InsertOrUpdateToMyProfileTable(dataUser);
                        dbDatabase.Dispose();

                        var dataPrivacy = new Dictionary <string, string>
                        {
                            { "p_privacy", CanFollowPref }
                        };
                        RequestsAsync.User.SaveSettings(dataPrivacy).ConfigureAwait(false);
                    }
                    else
                    {
                        Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #15
0
        //Get Messages From API
        private async void GetMessages_API()
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    SwipeRefreshLayout.Refreshing = false;
                    SwipeRefreshLayout.Enabled    = false;

                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short);
                }
                else
                {
                    BeforeMessageId = 0;

                    var(apiStatus, respond) = await RequestsAsync.Chat.GetChatConversationsAsync(Userid.ToString());

                    if (apiStatus == 200)
                    {
                        if (respond is GetChatConversationsObject result)
                        {
                            if (result.Data.Count > 0)
                            {
                                MAdapter.MessageList = new ObservableCollection <ChatMessagesDataObject>(result.Data);
                                MAdapter.NotifyDataSetChanged();

                                //Insert to DataBase
                                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                                dbDatabase.InsertOrReplaceMessages(MAdapter.MessageList);
                                dbDatabase.Dispose();

                                //Scroll Down >>
                                ChatBoxRecyclerView.ScrollToPosition(MAdapter.MessageList.Count - 1);

                                SwipeRefreshLayout.Refreshing = false;
                                SwipeRefreshLayout.Enabled    = false;
                            }
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }

                    SwipeRefreshLayout.Refreshing = false;
                    SwipeRefreshLayout.Enabled    = false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                SwipeRefreshLayout.Refreshing = false;
                SwipeRefreshLayout.Enabled    = false;
            }
        }
コード例 #16
0
        private string LoadMoreMessagesDatabase()
        {
            try
            {
                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                var            localList  = dbDatabase.GetMessageList(Convert.ToInt32(UserDetails.UserId), Userid, FirstMessageId);
                if (localList?.Count > 0) //Database.. Get Messages Local
                {
                    localList = new List <DataTables.MessageTb>(localList.OrderByDescending(a => a.Id));

                    foreach (var message in localList.Select(messages => new ChatMessagesDataObject
                    {
                        Id = messages.Id,
                        FromId = messages.FromId,
                        ToId = messages.ToId,
                        Text = messages.Text,
                        Seen = messages.Seen,
                        Time = messages.Time,
                        FromDeleted = messages.FromDeleted,
                        ToDeleted = messages.ToDeleted,
                        SentPush = messages.SentPush,
                        NotificationId = messages.NotificationId,
                        TypeTwo = messages.TypeTwo,
                        Image = messages.Image,
                        FullImage = messages.FullImage,
                        ApiPosition = JsonConvert.DeserializeObject <ApiPosition>(messages.ApiPosition),
                        ApiType = JsonConvert.DeserializeObject <ApiType>(messages.ApiType),
                    }))
                    {
                        MAdapter.MessageList.Insert(0, message);
                        MAdapter.NotifyItemInserted(MAdapter.MessageList.IndexOf(MAdapter.MessageList.FirstOrDefault()));

                        var index = MAdapter.MessageList.FirstOrDefault(a => a.Id == FirstMessageId);
                        if (index == null)
                        {
                            continue;
                        }
                        MAdapter.NotifyItemChanged(MAdapter.MessageList.IndexOf(index));
                        //Scroll Down >>
                        ChatBoxRecyclerView.ScrollToPosition(MAdapter.MessageList.IndexOf(index));
                    }

                    dbDatabase.Dispose();
                    return("1");
                }

                dbDatabase.Dispose();
                return("0");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return("0");
            }
        }
コード例 #17
0
        public static async Task Get_MyProfileData_Api(Activity context)
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Global.Get_User_Data(UserDetails.UserId);

                if (apiStatus == 200)
                {
                    if (respond is GetUserDataObject result)
                    {
                        UserDetails.Avatar   = result.UserData.Avatar;
                        UserDetails.Cover    = result.UserData.Cover;
                        UserDetails.Username = result.UserData.Username;
                        UserDetails.FullName = result.UserData.Name;
                        UserDetails.Email    = result.UserData.Email;

                        ListUtils.MyProfileList = new ObservableCollection <UserDataObject> {
                            result.UserData
                        };

                        if (result.Followers?.Count > 0)
                        {
                            ListUtils.MyFollowersList = new ObservableCollection <UserDataObject>(result.Followers);
                        }

                        context?.RunOnUiThread(() =>
                        {
                            try
                            {
                                Glide.With(Application.Context).Load(UserDetails.Avatar).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CircleCrop()).Preload();
                            }
                            catch (Exception e)
                            {
                                Methods.DisplayReportResultTrack(e);
                            }
                        });

                        await Task.Factory.StartNew(() =>
                        {
                            SqLiteDatabase dbDatabase = new SqLiteDatabase();
                            dbDatabase.Insert_Or_Update_To_MyProfileTable(result.UserData);

                            if (result.Following?.Count > 0)
                            {
                                dbDatabase.Insert_Or_Replace_MyContactTable(new ObservableCollection <UserDataObject>(result.Following));
                            }
                        });
                    }
                }
                else
                {
                    Methods.DisplayReportResult(context, respond);
                }
            }
        }
コード例 #18
0
        // send data and send api and show liner add code email
        private void SaveButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                switch (TypeTwoFactor)
                {
                case "1":
                {
                    TypeDialog = "ConfirmationCode";
                    var dialog = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light);
                    dialog.Title(Resource.String.Lbl_ConfirmationEmailSent);
                    dialog.Input(Resource.String.Lbl_ConfirmationCode, 0, false, this);
                    dialog.InputType(InputTypes.ClassNumber);
                    dialog.PositiveText(GetText(Resource.String.Lbl_Send)).OnPositive(this);
                    dialog.NegativeText(GetText(Resource.String.Lbl_Cancel)).OnNegative(this);
                    dialog.AlwaysCallSingleChoiceCallback();
                    dialog.Build().Show();

                    break;
                }

                case "0":
                    var dictionary = new Dictionary <string, string>
                    {
                        { "two_factor", "0" },
                    };

                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => RequestsAsync.Users.UpdateProfileAsync(dictionary)
                    });
                    var local = ListUtils.MyUserInfo.FirstOrDefault();
                    if (local != null)
                    {
                        local.TwoFactor = "0";

                        var sqLiteDatabase = new SqLiteDatabase();
                        sqLiteDatabase.InsertOrUpdate_DataMyInfo(local);
                        sqLiteDatabase.Dispose();
                    }
                    Finish();
                    break;
                }
            }
            catch (Exception exception)
            {
                AndHUD.Shared.Dismiss(this);
                Console.WriteLine(exception);
            }
        }
コード例 #19
0
        // send data and send api and show liner add code email
        private async void SaveButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                //Show a progress
                AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading) + "...");

                var dictionary = new Dictionary <string, string>
                {
                    { "settings_type", "two_factor" },
                    { "two_factor", TypeTwoFactor },
                };

                var(apiStatus, respond) = await RequestsAsync.Global.Update_UserData_General_Http(dictionary);

                if (apiStatus == 200)
                {
                    if (!(respond is MessageObject result))
                    {
                        return;
                    }
                    Console.WriteLine(result.Message);

                    var local = ListUtils.MyChannelList.FirstOrDefault();
                    if (local != null)
                    {
                        local.TwoFactor = TypeTwoFactor;

                        var sqLiteDatabase = new SqLiteDatabase();
                        sqLiteDatabase.InsertOrUpdate_DataMyChannel(local);
                        sqLiteDatabase.Dispose();
                    }

                    Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();
                    AndHUD.Shared.Dismiss(this);
                    Finish();
                }
                else
                {
                    Methods.DisplayReportResult(this, respond);
                }
            }
            catch (Exception exception)
            {
                AndHUD.Shared.Dismiss(this);
                Console.WriteLine(exception);
            }
        }
コード例 #20
0
        // check code email if good or no than update data user
        private async void SendButtonOnClick()
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                if (string.IsNullOrEmpty(TxtTwoFactorCode.Text) || string.IsNullOrWhiteSpace(TxtTwoFactorCode.Text))
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Please_enter_your_data), ToastLength.Short).Show();
                    return;
                }

                //Show a progress
                AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading) + "...");

                var(apiStatus, respond) = await RequestsAsync.Global.UpdateTwoFactorAsync("verify", TxtTwoFactorCode.Text);

                if (apiStatus == 200)
                {
                    if (respond is MessageObject result)
                    {
                        Console.WriteLine(result.Message);

                        var local = ListUtils.MyProfileList.FirstOrDefault();
                        if (local != null)
                        {
                            local.TwoFactor = "1";

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

                        Toast.MakeText(this, GetText(Resource.String.Lbl_TwoFactorOn), ToastLength.Short).Show();
                        AndHUD.Shared.Dismiss(this);

                        Finish();
                    }
                }
                else
                {
                    Methods.DisplayAndHUDErrorResult(this, respond);
                }
            }
            catch (Exception exception)
            {
                AndHUD.Shared.Dismiss(this);
                Console.WriteLine(exception);
            }
        }
コード例 #21
0
        public void LoadContacts(int afterContact = 0)
        {
            try
            {
                var dbDatabase = new SqLiteDatabase();
                var localList  = dbDatabase.Get_MyContact(afterContact, 100);
                if (localList?.Count > 0)
                {
                    RunOnUiThread(() =>
                    {
                        var listNew = localList?.Where(c => !CallAdapter.mCallUserContacts.Select(fc => fc.UserId).Contains(c.UserId)).ToList();
                        if (listNew.Count > 0)
                        {
                            Classes.AddRange(CallAdapter.mCallUserContacts, localList);
                            var lastCountItem = CallAdapter.ItemCount;
                            CallAdapter.NotifyItemRangeInserted(lastCountItem, listNew.Count);
                            CallAdapter.BindEnd();
                        }
                        else
                        {
                            Get_Contacts_APi();
                        }
                    });
                }
                else
                {
                    Get_Contacts_APi();
                }

                RunOnUiThread(() =>
                {
                    //Set Event Scroll
                    if (OnMainScrolEvent == null)
                    {
                        var xamarinRecyclerViewOnScrollListener = new XamarinRecyclerViewOnScrollListener(ContactsLayoutManager);
                        OnMainScrolEvent = xamarinRecyclerViewOnScrollListener;
                        OnMainScrolEvent.LoadMoreEvent += MyContact_OnScroll_OnLoadMoreEvent;
                        CalluserRecylerView.AddOnScrollListener(OnMainScrolEvent);
                        CalluserRecylerView.AddOnScrollListener(new ScrollDownDetector());
                    }
                    else
                    {
                        OnMainScrolEvent.IsLoading = false;
                    }
                });

                dbDatabase.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                LoadContacts(afterContact);
            }
        }
コード例 #22
0
ファイル: ApiRequest.cs プロジェクト: divitiae/playtube
        public static async Task <UserDataObject> GetChannelData(Activity activity, string userId)
        {
            if (!Methods.CheckConnectivity())
            {
                return(null);
            }
            var(apiStatus, respond) = await RequestsAsync.Global.Get_Channel_Info_HttP(userId);

            if (apiStatus == 200)
            {
                if (respond is GetChannelInfoObject result)
                {
                    if (userId == UserDetails.UserId)
                    {
                        UserDetails.Avatar   = result.DataResult.Avatar;
                        UserDetails.Cover    = result.DataResult.Cover;
                        UserDetails.Username = result.DataResult.Username;
                        UserDetails.FullName = AppTools.GetNameFinal(result.DataResult);

                        ListUtils.MyChannelList.Clear();
                        ListUtils.MyChannelList.Add(result.DataResult);

                        try
                        {
                            var profileImage = TabbedMainActivity.GetInstance()?.FragmentBottomNavigator?.ProfileImage;
                            if (profileImage != null)
                            {
                                GlideImageLoader.LoadImage(activity, UserDetails.Avatar, profileImage, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }


                        var sqlEntity = new SqLiteDatabase();
                        sqlEntity.InsertOrUpdate_DataMyChannel(result.DataResult);
                        sqlEntity.Dispose();

                        return(result.DataResult);
                    }
                    else
                    {
                        return(result.DataResult);
                    }
                }
            }
            else
            {
                Methods.DisplayReportResult(activity, respond);
            }
            return(null);
        }
コード例 #23
0
        public static async Task GetStickers(Activity activity)
        {
            if (Methods.CheckConnectivity())
            {
                var(apiStatus, respond) = await RequestsAsync.Common.GetStickersAsync();

                if (apiStatus == 200)
                {
                    if (respond is GetStickersObject result)
                    {
                        if (result.Data.Count > 0)
                        {
                            ListUtils.StickersList.Clear();
                            ListUtils.StickersList = new ObservableCollection <DataFile>(result.Data);

                            SqLiteDatabase sqLiteDatabase = new SqLiteDatabase();
                            sqLiteDatabase.InsertAllStickers(ListUtils.StickersList);
                            sqLiteDatabase.Dispose();

                            await Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    foreach (var item in result.Data)
                                    {
                                        var url = item.File.Contains("media3.giphy.com/");
                                        if (url)
                                        {
                                            item.File = item.File.Replace(Client.WebsiteUrl, "");
                                        }

                                        Methods.MultiMedia.DownloadMediaTo_DiskAsync(Methods.Path.FolderDiskSticker, item.File);

                                        Glide.With(activity).Load(item.File).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            }).ConfigureAwait(false);
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(activity, respond);
                }
            }
            else
            {
                Toast.MakeText(activity, activity.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
コード例 #24
0
        public static async Task <(int, dynamic)> Get_users_friends_Async(string Aftercontact)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var formContent = new FormUrlEncodedContent(new[]
                    {
                        new KeyValuePair <string, string>("user_id", UserDetails.User_id),
                        new KeyValuePair <string, string>("user_profile_id", UserDetails.User_id),
                        new KeyValuePair <string, string>("s", UserDetails.access_token),
                        new KeyValuePair <string, string>("after_user_id", Aftercontact),
                        new KeyValuePair <string, string>("list_type", "all"),
                    });

                    var response = await client.PostAsync(API_Get_users_friends, formContent);

                    response.EnsureSuccessStatusCode();
                    string json = await response.Content.ReadAsStringAsync();

                    var data = JsonConvert.DeserializeObject <Classes.UserContacts.Rootobject>(json);
                    if (data.api_status == 200)
                    {
                        if (data.users.Length > 0)
                        {
                            //Classes.UserContactsList = new ObservableCollection<Classes.UserContacts.User>(data.users);

                            if (is_Friend)
                            {
                                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                                //Insert Or Replace To Database
                                dbDatabase.Insert_Or_Replace_MyContactTable(new ObservableCollection <Classes.UserContacts.User>(data.users));
                                dbDatabase.Dispose();

                                is_Friend = false;
                            }
                        }

                        return(200, data);
                    }
                    else
                    {
                        var error = JsonConvert.DeserializeObject <Error_Object>(json);
                        return(404, error);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("error : " + e.Message);
                Crashes.TrackError(e);
                return(400, e.Message);
            }
        }
コード例 #25
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position, IList <Object> payloads)
        {
            try
            {
                if (payloads.Count > 0)
                {
                    if (viewHolder is SuggestionsAdapterViewHolder holder)
                    {
                        var users = UserList[position];

                        var data = (string)payloads[0];
                        if (data == "true")
                        {
                            holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed);
                            holder.Button.SetTextColor(Color.ParseColor("#ffffff"));
                            if (AppSettings.ConnectivitySystem == 1) // Following
                            {
                                holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Following);
                                holder.Button.Tag  = "true";
                                users.IsFollowing  = "1";
                            }
                            else // Request Friend
                            {
                                holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                                holder.Button.SetTextColor(Color.ParseColor("#444444"));
                                holder.Button.Text = ActivityContext.GetText(Resource.String.Lbl_Request);
                                holder.Button.Tag  = "Request";
                                users.IsFollowing  = "2";
                            }
                        }
                        else
                        {
                            holder.Button.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends);
                            holder.Button.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                            holder.Button.Text = ActivityContext.GetText(AppSettings.ConnectivitySystem == 1 ? Resource.String.Lbl_Follow : Resource.String.Lbl_AddFriends);
                            holder.Button.Tag  = "false";
                            users.IsFollowing  = "0";
                            var dbDatabase = new SqLiteDatabase();
                            dbDatabase.Delete_UsersContact(users.UserId);
                            dbDatabase.Dispose();
                        }
                    }
                }
                else
                {
                    base.OnBindViewHolder(viewHolder, position, payloads);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                base.OnBindViewHolder(viewHolder, position, payloads);
            }
        }
コード例 #26
0
 public TapochekSite(SqLiteDatabase sql)
 {
     this.sql   = sql;
     hostUrl    = string.Format("http://{0}", EnumHelper.GetAttributeOfType(SiteType.Tapochek));
     indexUrl   = string.Format("{0}/index.php", hostUrl);
     loginUrl   = string.Format("{0}/login.php", hostUrl);
     profileUrl = string.Format("{0}/profile.php", hostUrl);
     searchUrl  = string.Format("{0}/tracker.php?nm", hostUrl);
     topicUrl   = string.Format("{0}/viewtopic.php?t", hostUrl);
     userUrl    = string.Format("{0}/tracker.php?rid", hostUrl);
     GetCred();
 }
コード例 #27
0
        private void SetDataRegister(RegisterObject auth)
        {
            try
            {
                if (auth != null)
                {
                    UserDetails.Username    = EmailEditText.Text;
                    UserDetails.FullName    = EmailEditText.Text;
                    UserDetails.Password    = PasswordEditText.Text;
                    UserDetails.AccessToken = auth.AccessToken;
                    UserDetails.UserId      = auth.Data.Id;
                    UserDetails.Status      = "Active";
                    UserDetails.Cookie      = auth.AccessToken;
                    UserDetails.Email       = EmailEditText.Text;

                    Current.AccessToken = auth.AccessToken;

                    //Insert user data to database
                    var user = new DataTables.LoginTb
                    {
                        UserId      = UserDetails.UserId.ToString(),
                        AccessToken = UserDetails.AccessToken,
                        Cookie      = UserDetails.Cookie,
                        Username    = EmailEditText.Text,
                        Password    = PasswordEditText.Text,
                        Status      = "Active",
                        Lang        = "",
                        DeviceId    = UserDetails.DeviceId
                    };
                    UserDetails.IsLogin = true;

                    ListUtils.DataUserLoginList.Clear();
                    ListUtils.DataUserLoginList.Add(user);

                    var dbDatabase = new SqLiteDatabase();
                    dbDatabase.InsertOrUpdateLogin_Credentials(user);

                    if (auth.Data != null)
                    {
                        ListUtils.MyUserInfoList.Add(auth.Data);
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => ApiRequest.GetInfoData(this, UserDetails.UserId.ToString())
                        });
                    }

                    dbDatabase.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #28
0
        public static async void Logout(Activity context)
        {
            try
            {
                if (RunLogout == false)
                {
                    RunLogout = true;

                    await RemoveData("Logout");


                    context?.RunOnUiThread(() =>
                    {
                        Methods.Path.DeleteAll_MyFolderDisk();

                        SqLiteDatabase dbDatabase = new SqLiteDatabase();

                        Runtime.GetRuntime()?.RunFinalization();
                        Runtime.GetRuntime()?.Gc();
                        TrimCache(context);

                        dbDatabase.ClearAll();
                        dbDatabase.DropAll();

                        ListUtils.ClearAllList();

                        UserDetails.ClearAllValueUserDetails();

                        dbDatabase.CheckTablesStatus();
                        dbDatabase.Dispose();

                        context.StopService(new Intent(context, typeof(ScheduledApiService)));

                        MainSettings.SharedData.Edit()?.Clear()?.Commit();
                        MainSettings.InAppReview.Edit()?.Clear()?.Commit();

                        Intent intent = new Intent(context, typeof(FirstActivity));
                        intent.AddCategory(Intent.CategoryHome);
                        intent.SetAction(Intent.ActionMain);
                        intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask | ActivityFlags.ClearTask);
                        context.StartActivity(intent);
                        context.FinishAffinity();
                        context.Finish();
                    });

                    RunLogout = false;
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #29
0
        public static async Task <GetSiteSettingsObject.Config> GetSettings_Api(Activity context)
        {
            if (Methods.CheckConnectivity())
            {
                await SetLangUserAsync(context).ConfigureAwait(false);

                (var apiStatus, dynamic respond) = await Current.GetSettings();

                if (apiStatus != 200 || !(respond is GetSiteSettingsObject result) || result.config == null)
                {
                    return(Methods.DisplayReportResult(context, respond));
                }

                ListUtils.SettingsSiteList = result.config;

                AppSettings.OneSignalAppId = result.config.AndroidMPushId;
                OneSignalNotification.RegisterNotificationDevice();

                //Products Categories
                var listProducts = result.config.ProductsCategories.Select(cat => new Classes.Categories
                {
                    CategoriesId    = cat.Key,
                    CategoriesName  = cat.Value,
                    CategoriesColor = "#ffffff"
                }).ToList();

                ListUtils.ListCategoriesProducts.Clear();
                ListUtils.ListCategoriesProducts = new ObservableCollection <Classes.Categories>(listProducts);

                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                dbDatabase.InsertOrUpdateSettings(result.config);
                dbDatabase.Dispose();

                try
                {
                    if (ListUtils.ListCategoriesProducts.Count == 0)
                    {
                        Methods.DialogPopup.InvokeAndShowDialog(context, "ReportMode", "List Categories Products Not Found, Please check api get_site_settings ", "Close");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                return(result.config);
            }
            else
            {
                Toast.MakeText(context, context.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                return(null);
            }
        }
コード例 #30
0
        public static void UpdateRecyclerLastMessageView(MessageData result, GetUsersListObject.User user, int index, MsgTabbedMainActivity context)
        {
            try
            {
                if (IsImageExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendImageFile);
                }
                else if (IsVideoExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendVideoFile);
                }
                else if (IsAudioExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendAudioFile);
                }
                else if (IsFileExtension(result.MediaFileName))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendFile);
                }
                else if (result.MediaFileName.Contains(".gif") || result.MediaFileName.Contains(".GIF"))
                {
                    result.Text = WindowActivity?.GetText(Resource.String.Lbl_SendGifFile);
                }
                else
                {
                    result.Text = Methods.FunString.DecodeString(result.Text);
                }

                context.Activity?.RunOnUiThread(() =>
                {
                    try
                    {
                        context.LastChatTab?.MAdapter?.NotifyItemChanged(index, "WithoutBlob");
                    }
                    catch (Exception e)
                    {
                        Methods.DisplayReportResultTrack(e);
                    }
                });

                SqLiteDatabase dbDatabase = new SqLiteDatabase();
                //Update All data users to database
                dbDatabase.Insert_Or_Update_LastUsersChat(GlobalContext.Context, new ObservableCollection <GetUsersListObject.User> {
                    user
                });
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }