//Save data private void BtnApplyOnClick(object sender, EventArgs e) { try { var dbDatabase = new SqLiteDatabase(); var newSettingsFilter = new DataTables.FilterLastChatTb { Status = Status, Type = Type, }; dbDatabase.InsertOrUpdate_FilterLastChat(newSettingsFilter); dbDatabase.Dispose(); ContextMain.LastChatTab.MAdapter.OnlineUsers = Status == "online" || Status == "both"; ContextMain.LastChatTab.OnlineUsers = Status == "online" || Status == "both"; MainSettings.SharedData.Edit().PutBoolean("onlineuser_key", ContextMain.LastChatTab.OnlineUsers).Commit(); ContextMain.LastChatTab.MAdapter.ChatList.Clear(); ContextMain.LastChatTab.MAdapter.NotifyDataSetChanged(); if (Status == "both") { Status = ""; } ContextMain.LastChatTab.StartApiService(Type, Status); Dismiss(); } catch (Exception exception) { Console.WriteLine(exception); } }
private void GetFilter() { try { var dbDatabase = new SqLiteDatabase(); var data = dbDatabase.GetFilterLastChatById(); if (data != null) { Status = data.Status; Type = data.Type; TxtTypeChat.Text = Type; //////////////////////////// Status ////////////////////////////// //Select Status >> Both (both) //Select Status >> Online (on) //Select Status >> Offline (off) switch (data.Status) { case "offline": ButtonOffline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); ButtonOffline.SetTextColor(Color.ParseColor("#ffffff")); BothStatusButton.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); BothStatusButton.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); ButtonOnline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOnline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); Status = "offline"; break; case "online": ButtonOnline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); ButtonOnline.SetTextColor(Color.ParseColor("#ffffff")); BothStatusButton.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); BothStatusButton.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); ButtonOffline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOffline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); Status = "online"; break; case "both": BothStatusButton.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); BothStatusButton.SetTextColor(Color.ParseColor("#ffffff")); ButtonOnline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOnline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); ButtonOffline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOffline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); Status = "both"; break; } } else { var newSettingsFilter = new DataTables.FilterLastChatTb { Status = "both", Type = "all", }; dbDatabase.InsertOrUpdate_FilterLastChat(newSettingsFilter); Status = "both"; Type = "all"; TxtTypeChat.Text = Context.GetString(Resource.String.Lbl_All); //////////////////////////// Status ////////////////////////////// BothStatusButton.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends_pressed); BothStatusButton.SetTextColor(Color.ParseColor("#ffffff")); ButtonOnline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOnline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); ButtonOffline.SetBackgroundResource(Resource.Drawable.follow_button_profile_friends); ButtonOffline.SetTextColor(AppSettings.SetTabDarkTheme ? Color.ParseColor("#ffffff") : Color.ParseColor("#444444")); } dbDatabase.Dispose(); } catch (Exception e) { Console.WriteLine(e); } }