public override void OnCreate() { base.OnCreate(); // Setup Application AppController.EnableSettings(new AdMaiora.AppKit.Data.UserSettingsPlatformAndroid()); AppController.EnableUtilities(new AdMaiora.AppKit.Utils.ExecutorPlatformAndroid()); AppController.EnableFileSystem(new AdMaiora.AppKit.IO.FileSystemPlatformAndroid()); AppController.EnableImageLoader(new AdMaiora.AppKit.Utils.ImageLoaderPlatofrmAndroid()); AppController.EnableDataStorage(new AdMaiora.AppKit.Data.DataStoragePlatformAndroid()); AppController.EnableServices(new AdMaiora.AppKit.Services.ServiceClientPlatformAndroid()); }
private void LoginUser() { if (ValidateInput()) { if (_isLogginUser) { return; } _isLogginUser = true; _email = this.EmailText.Text; _password = this.PasswordText.Text; // Prevent user form tapping views while logging ((MainViewController)this.MainViewController).BlockUI(); // Create a new cancellation token for this request _cts1 = new CancellationTokenSource(); AppController.LoginUser(_cts1, _email, _password, // Service call success (data) => { AppController.Settings.LastLoginUserIdUsed = data.UserId; AppController.Settings.LastLoginUsernameUsed = _email; AppController.Settings.AuthAccessToken = data.AuthAccessToken; AppController.Settings.AuthExpirationDate = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime(); AppController.Settings.GoogleSignedIn = false; var c = new GimmicksViewController(); this.NavigationController.PushViewController(c, true); }, // Service call error (error) => { if (error.Contains("confirm")) { this.VerifyButton.Hidden = false; } UIToast.MakeText(error, UIToastLength.Long).Show(); }, // Service call finished () => { _isLogginUser = false; // Allow user to tap views ((MainViewController)this.MainViewController).UnblockUI(); }); } }
public void RegisterUser() { if (ValidateInput()) { DismissKeyboard(); AppController.Utility.ExecuteDelayedAction(300, default(System.Threading.CancellationToken), () => { if (_isRegisteringUser) { return; } _isRegisteringUser = true; _password = this.PasswordText.Text; // Prevent user form tapping views while logging ((MainViewController)this.MainViewController).BlockUI(); // Create a new cancellation token for this request _cts = new CancellationTokenSource(); AppController.RegisterUser(_cts, _email, _password, // Service call success (data) => { var c = new RegistrationDoneViewController(); this.NavigationController.PopToViewController(this.NavigationController.ViewControllers.Single(x => x is LoginViewController), false); this.NavigationController.PushViewController(c, true); }, // Service call error (error) => { this.PasswordText.RequestUserInput(); UIToast.MakeText(error, UIToastLength.Long).Show(); }, // Service call finished () => { _isRegisteringUser = false; // Allow user to tap views ((MainViewController)this.MainViewController).UnblockUI(); }); }); } }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Setup Application AppController.EnableSettings(new AdMaiora.AppKit.Data.UserSettingsPlatformiOS()); AppController.EnableUtilities(new AdMaiora.AppKit.Utils.ExecutorPlatformiOS()); AppController.EnableFileSystem(new AdMaiora.AppKit.IO.FileSystemPlatformiOS()); AppController.EnableImageLoader(new AdMaiora.AppKit.Utils.ImageLoaderPlatofrmiOS()); AppController.EnableDataStorage(new AdMaiora.AppKit.Data.DataStoragePlatformiOS()); AppController.EnableServices(new AdMaiora.AppKit.Services.ServiceClientPlatformiOS()); // Override point for customization after application launch. // If not required for your application you can safely delete this method return(RegisterMainLauncher(new SplashViewController(), launchOptions)); }
private void VerifyUser() { if (ValidateInput()) { if (_isConfirmingUser) { return; } _isConfirmingUser = true; _email = this.EmailText.Text; _password = this.PasswordText.Text; // Prevent user form tapping views while logging ((MainActivity)this.Activity).BlockUI(); this.VerifyButton.Visibility = ViewStates.Gone; // Create a new cancellation token for this request _cts1 = new CancellationTokenSource(); AppController.VerifyUser(_cts1, _email, _password, // Service call success () => { Toast.MakeText(this.Activity.Application, "You should receive a new mail!", ToastLength.Long).Show(); }, // Service call error (error) => { Toast.MakeText(this.Activity.Application, error, ToastLength.Long).Show(); }, // Service call finished () => { _isConfirmingUser = false; // Allow user to tap views ((MainActivity)this.Activity).UnblockUI(); }); } }
private void PostMessage() { if (_isSendingMessage) { return; } string content = this.MessageText.Text; if (String.IsNullOrWhiteSpace(content)) { return; } _isSendingMessage = true; ((MainActivity)this.Activity).BlockUI(); _cts0 = new CancellationTokenSource(); AppController.PostMessage(_cts0, _issue.IssueId, _userId, content, (message) => { if (_adapter != null) { _adapter.Insert(message); this.MessageList.ReloadData(); this.MessageList.Visibility = ViewStates.Visible; this.MessageText.Text = String.Empty; } }, (error) => { Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show(); }, () => { _isSendingMessage = false; ((MainActivity)this.Activity).UnblockUI(); }); }
private void PostMessage() { if (_isSendingMessage) { return; } string content = this.MessageText.Text; if (String.IsNullOrWhiteSpace(content)) { return; } _isSendingMessage = true; ((MainViewController)this.MainViewController).BlockUI(); _cts0 = new CancellationTokenSource(); AppController.PostMessage(_cts0, _issue.IssueId, _userId, content, (message) => { if (_source != null) { _source.Insert(message); this.MessageList.ReloadData(); this.MessageList.Hidden = false; this.MessageText.Text = String.Empty; } }, (error) => { UIToast.MakeText(error, UIToastLength.Long).Show(); }, () => { _isSendingMessage = false; ((MainViewController)this.MainViewController).UnblockUI(); }); }
public void DidSignIn(SignIn signIn, GoogleUser user, NSError error) { try { string gClientId = AppController.Globals.GoogleClientId_iOS; string gEmail = user.Profile.Email; string gToken = user.Authentication.IdToken; _cts0 = new CancellationTokenSource(); AppController.LoginUser(_cts0, gClientId, gEmail, gToken, (d) => { AppController.Settings.LastLoginUserIdUsed = d.UserId; AppController.Settings.LastLoginUsernameUsed = _email; AppController.Settings.AuthAccessToken = d.AuthAccessToken; AppController.Settings.AuthExpirationDate = d.AuthExpirationDate.GetValueOrDefault().ToLocalTime(); AppController.Settings.GoogleSignedIn = true; var c = new GimmicksViewController(); this.NavigationController.PushViewController(c, true); }, (err) => { UIToast.MakeText(err, UIToastLength.Long).Show(); }, () => { ((MainViewController)this.MainViewController).UnblockUI(); }); } catch (Exception ex) { ((MainViewController)this.MainViewController).UnblockUI(); UIToast.MakeText("Error logging with Google!", UIToastLength.Long).Show(); } finally { // Do nothing... } }
private bool RestoreUser() { if (!AppController.IsUserRestorable) { return(false); } if (_isLogginUser) { return(true); } _isLogginUser = true; // Create a new cancellation token for this request _cts = new CancellationTokenSource(); AppController.RestoreUser(_cts, AppController.Settings.AuthAccessToken, // Service call success (data) => { Bundle b = new Bundle(); b.PutBoolean("UserRestored", true); MakeRoot(typeof(MainActivity), b); }, // Service call error (error) => { Toast.MakeText(this.Application, error, ToastLength.Long).Show(); MakeRoot(typeof(MainActivity)); }, // Service call finished () => { _isLogginUser = false; }); return(true); }
private void AddIssue() { if (_isSendingIssue) { return; } if (!ValidateInput()) { return; } string title = this.TitleText.Text; string description = this.DescriptionText.Text; _isSendingIssue = true; ((MainViewController)this.MainViewController).BlockUI(); _cts0 = new CancellationTokenSource(); AppController.AddIssue(_cts0, _gimmickId, _userId, title, description, _currentIssueType, (todoItem) => { this.NavigationController.PopViewController(true); }, (error) => { UIToast.MakeText(error, UIToastLength.Long).Show(); }, () => { _isSendingIssue = false; ((MainViewController)this.MainViewController).UnblockUI(); }); }
private void AddIssue() { if (_isSendingIssue) { return; } if (!ValidateInput()) { return; } string title = this.TitleText.Text; string description = this.DescriptionText.Text; _isSendingIssue = true; ((MainActivity)this.Activity).BlockUI(); _cts0 = new CancellationTokenSource(); AppController.AddIssue(_cts0, _gimmickId, _userId, title, description, _currentIssueType, (todoItem) => { this.FragmentManager.PopBackStack(); }, (error) => { Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show(); }, () => { _isSendingIssue = false; ((MainActivity)this.Activity).UnblockUI(); }); }
private void RefreshStats() { if (_gimmick == null) { return; } if (_isRefreshingStats) { return; } this.NameLabel.Text = _gimmick.Name; this.OwnerLabel.Text = _gimmick.Owner; _isRefreshingStats = true; ((MainViewController)this.MainViewController).BlockUI(); this.ViewOpenedButton.Enabled = false; this.ViewWorkingButton.Enabled = false; this.ViewClosedButton.Enabled = false; Dictionary <string, int> stats = null; _cts0 = new CancellationTokenSource(); AppController.RefreshStats(_cts0, _gimmick.GimmickId, (newStats) => { stats = newStats; }, (error) => { UIToast.MakeText(error, UIToastLength.Long).Show(); }, () => { if (stats != null) { LoadStatistics(stats); _isRefreshingStats = false; ((MainViewController)this.MainViewController).UnblockUI(); } else { AppController.Utility.ExecuteOnAsyncTask(_cts0.Token, () => { stats = AppController.GetStats(_gimmick.GimmickId); }, () => { LoadStatistics(stats); _isRefreshingStats = false; ((MainViewController)this.MainViewController).UnblockUI(); }); } }); }
private void RefreshIssues(int filter) { if (_isRefreshingIssues) { return; } _filter = filter; HilightFilterButton(filter); this.IssueList.Visibility = ViewStates.Gone; _isRefreshingIssues = true; ((MainActivity)this.Activity).BlockUI(); Issue[] issues = null; _cts0 = new CancellationTokenSource(); AppController.RefreshIssues(_cts0, _gimmickId, (newIssues) => { issues = newIssues; }, (error) => { Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show(); }, () => { if (issues != null) { LoadIssues(issues, filter); if (_adapter?.ItemCount > 0) { this.IssueList.Visibility = ViewStates.Visible; } _isRefreshingIssues = false; ((MainActivity)this.Activity).UnblockUI(); } else { AppController.Utility.ExecuteOnAsyncTask(_cts0.Token, () => { issues = AppController.GetIssues(_gimmickId); }, () => { LoadIssues(issues, filter); if (_adapter?.ItemCount > 0) { this.IssueList.Visibility = ViewStates.Visible; } _isRefreshingIssues = false; ((MainActivity)this.Activity).UnblockUI(); }); } }); }
private void RefreshIssues(int filter) { if (_isRefreshingIssues) { return; } _filter = filter; HilightFilterButton(filter); this.IssueList.Hidden = true; _isRefreshingIssues = true; ((MainViewController)this.MainViewController).BlockUI(); Issue[] issues = null; _cts0 = new CancellationTokenSource(); AppController.RefreshIssues(_cts0, _gimmickId, (newIssues) => { issues = newIssues; }, (error) => { UIToast.MakeText(error, UIToastLength.Long).Show(); }, () => { if (issues != null) { LoadIssues(issues, filter); if (_source?.Count > 0) { this.IssueList.Hidden = false; } _isRefreshingIssues = false; ((MainViewController)this.MainViewController).UnblockUI(); } else { AppController.Utility.ExecuteOnAsyncTask(_cts0.Token, () => { issues = AppController.GetIssues(_gimmickId); }, () => { LoadIssues(issues, filter); if (_source?.Count > 0) { this.IssueList.Hidden = false; } _isRefreshingIssues = false; ((MainViewController)this.MainViewController).UnblockUI(); }); } }); }
private void RefreshMessages() { if (_isRefreshingMessage) { return; } this.MessageList.Visibility = ViewStates.Gone; _isRefreshingMessage = true; ((MainActivity)this.Activity).BlockUI(); Model.Message[] messages = null; _cts1 = new CancellationTokenSource(); AppController.RefreshMessages(_cts1, _issue.IssueId, (newMessages) => { messages = newMessages; }, (error) => { Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show(); }, () => { if (messages != null) { LoadMessages(messages); if (_adapter?.ItemCount > 0) { this.MessageList.Visibility = ViewStates.Visible; } _isRefreshingMessage = false; ((MainActivity)this.Activity).UnblockUI(); } else { AppController.Utility.ExecuteOnAsyncTask(_cts1.Token, () => { messages = AppController.GetMessages(_issue.IssueId); }, () => { LoadMessages(messages); if (_adapter?.ItemCount > 0) { this.MessageList.Visibility = ViewStates.Visible; } _isRefreshingMessage = false; ((MainActivity)this.Activity).UnblockUI(); }); } }); }
private void RefreshMessages() { if (_isRefreshingMessage) { return; } this.MessageList.Hidden = true; _isRefreshingMessage = true; ((MainViewController)this.MainViewController).BlockUI(); Model.Message[] messages = null; _cts1 = new CancellationTokenSource(); AppController.RefreshMessages(_cts1, _issue.IssueId, (newMessages) => { messages = newMessages; }, (error) => { UIToast.MakeText(error, UIToastLength.Long).Show(); }, () => { if (messages != null) { LoadMessages(messages); if (_source?.Count > 0) { this.MessageList.Hidden = false; } _isRefreshingMessage = false; ((MainViewController)this.MainViewController).UnblockUI(); } else { AppController.Utility.ExecuteOnAsyncTask(_cts1.Token, () => { messages = AppController.GetMessages(_issue.IssueId); }, () => { LoadMessages(messages); if (_source?.Count > 0) { this.MessageList.Hidden = false; } _isRefreshingMessage = false; ((MainViewController)this.MainViewController).UnblockUI(); }); } }); }