Ejemplo n.º 1
0
    static int ShowWithCallback(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            string arg0 = ToLua.CheckString(L, 1);
            DG.Tweening.TweenCallback arg1 = null;
            LuaTypes funcType2             = LuaDLL.lua_type(L, 2);

            if (funcType2 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (DG.Tweening.TweenCallback)ToLua.CheckObject(L, 2, typeof(DG.Tweening.TweenCallback));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                arg1 = DelegateFactory.CreateDelegate(typeof(DG.Tweening.TweenCallback), func) as DG.Tweening.TweenCallback;
            }

            UIToast.ShowType arg2 = (UIToast.ShowType)ToLua.CheckObject(L, 3, typeof(UIToast.ShowType));
            UIToast.ShowWithCallback(arg0, arg1, arg2);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 2
0
        private void CompleteTodoItem(TodoItem item, bool completed)
        {
            if (_isRefreshingItems)
            {
                return;
            }

            _isRefreshingItems = true;
            ((MainViewController)this.MainViewController).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.CompleteTodoItem(_cts0,
                                           item.TodoItemId,
                                           completed,
                                           (todoItem) =>
            {
                _source.SetAsCompleted(todoItem.TodoItemId, todoItem.IsComplete, todoItem.CompletionDate);
                this.TaskList.ReloadData();
            },
                                           (error) =>
            {
                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                           () =>
            {
                _isRefreshingItems = false;
                ((MainViewController)this.MainViewController).UnblockUI();
            });
        }
Ejemplo n.º 3
0
        private void DeleteTodoItem(TodoItem item)
        {
            if (_isRefreshingItems)
            {
                return;
            }

            _isRefreshingItems = true;
            ((MainViewController)this.MainViewController).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.DeleteTodoItem(_cts0,
                                         item.TodoItemId,
                                         () =>
            {
                _source.RemoveItem(item);
                this.TaskList.ReloadData();

                UIToast.MakeText("An item has been removed!", UIToastLength.Long).Show();
            },
                                         (error) =>
            {
                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                         () =>
            {
                _isRefreshingItems = false;
                ((MainViewController)this.MainViewController).UnblockUI();
            });
        }
Ejemplo n.º 4
0
    public void LoadAddressList()
    {
        Debug.Log("LoadAddressList");
        //更新文件列表
        fileList.Clear();
        XmlDocument xmlDoc = new XmlDocument();
        var         path   = Application.persistentDataPath + Conf.xmlFileName;

        xmlDoc.Load(path);
        if (xmlDoc != null)
        {
            var rootNode        = xmlDoc.SelectSingleNode("root");
            var fileAddressNode = rootNode.SelectSingleNode("fileAddress");
            var nodes           = fileAddressNode.ChildNodes;
            foreach (var node in nodes)
            {
                XmlNode n = (XmlNode)node;
                fileList.Add(n.InnerText);
            }
            ShowChoseDialog();
            var newVerStr = rootNode.SelectSingleNode("appVersion");
            if (newVerStr != null && newVerStr.InnerText != Application.version)
            {
                var appUrl = rootNode.SelectSingleNode("downloadApp");
                if (appUrl != null)
                {
                    StartCoroutine(gotoDownloadNewVersion(appUrl.InnerText));
                }
            }
        }
        else
        {
            UIToast.ShowTips("读取配置文件失败!", 2.0f);
        }
    }
Ejemplo n.º 5
0
    public void LoadVocLibAndStartGame(int sceneIndex)
    {
        string vocFileName = PlayerPrefs.GetString(Conf.missionVocFileKey);
        string filePath    = Application.persistentDataPath + @"/" + vocFileName + ".txt";

        if (File.Exists(filePath))
        {
            string xmlFilePath = Application.persistentDataPath + @"/" +
                                 vocFileName + ".xml";
            if (File.Exists(xmlFilePath))
            {
                //如果已经解析过词库,直接加载xml
                Debug.Log("加载xml词库,开始游戏");
                SceneManager.LoadScene(sceneIndex);
            }
            else
            {
                //如果词库未解析,则解析词库
                Debug.Log("文件不存在:" + xmlFilePath);
                StartCoroutine(RegexMatch(vocFileName, delegate()
                {
                    LoadVocLibAndStartGame(sceneIndex);
                }));
            }
        }
        else
        {
            UIToast.ShowTips("词库不存在,请先设置词库", 2.0f);
        }
    }
Ejemplo n.º 6
0
    public void LoadXmlFile()
    {
        //如果没有网络 判断本地是否存在配置文件 如果有则去读本地文件
        var confFile = Application.persistentDataPath + Conf.xmlFileName;

        if (File.Exists(confFile))
        {
            string confContent = File.ReadAllText(confFile);
            //校验本地配置文件是否有效
            if (confContent.Length < 10)
            {
                Debug.Log("删除无效配置文件");
                File.Delete(confFile);
            }
        }
        if (File.Exists(confFile))
        {
            LoadAddressList();
        }
        else
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                UIToast.ShowTips("无法连接网络,请检查网络", 2.0f);
            }
            else
            {
                //如果有网络更新xml
                UpdateAndShowVocLibList();
            }
        }
    }
Ejemplo n.º 7
0
    private IEnumerator DownloadProgress(string path, Button[] bts)
    {
        string progress = string.Empty;

        while (!net.isDone)
        {
            progress = net.progress * 100.0 + "%";
            //.Log("进度:" + progress);
            yield return(1);
        }
        if (net.error != null)
        {
            UIToast.ShowTips("下载出错:" + net.error, 2.0f);
        }
        else
        {
            progress = "100%";
            if (null != net.text)
            {
                File.WriteAllText(path, net.text, System.Text.Encoding.UTF8);
                UIToast.ShowTips("下载完成:" + path, 2.0f);
                bts[0].interactable = false;
                bts[1].interactable = true;
                bts[2].interactable = true;
            }
        }
        yield return(1);
    }
Ejemplo n.º 8
0
    IEnumerator UpdateXmlFile(string address)
    {
        UIToast.ShowTips("正在更新词库列表...", 2.0f);
        net = new WWW(address);
        yield return(net);

        //下载xml完成后将文件写入
        while (!net.isDone)
        {
            yield return(0);
        }
        //如果本地已存在xml 则检测xml版本
        if (File.Exists(Application.persistentDataPath + Conf.xmlFileName))
        {
            if (isNewVersion(net.text))
            {
                //有新版本
                File.WriteAllText(Application.persistentDataPath + Conf.xmlFileName, net.text);
            }
        }
        else
        {
            File.WriteAllText(Application.persistentDataPath + Conf.xmlFileName, net.text);
        }

        LoadAddressList();
    }
Ejemplo n.º 9
0
    private IEnumerator gotoDownloadNewVersion(string url)
    {
        UIToast.ShowTips("发现新版本", 3f);
        yield return(new WaitForSeconds(3f));

        Application.OpenURL(url);
    }
Ejemplo n.º 10
0
        private void RefreshGimmicks()
        {
            if (_isRefreshingGimmicks)
            {
                return;
            }

            this.GimmickList.Hidden = true;

            _isRefreshingGimmicks = true;
            ((MainViewController)this.MainViewController).BlockUI();

            Gimmick[] gimmicks = null;

            _cts0 = new CancellationTokenSource();
            AppController.RefreshGimmicks(_cts0,
                                          (newGimmicks) =>
            {
                gimmicks = newGimmicks;
            },
                                          (error) =>
            {
                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                          () =>
            {
                if (gimmicks != null)
                {
                    LoadGimmicks(gimmicks);

                    if (_source?.Count > 0)
                    {
                        this.GimmickList.Hidden = false;
                    }

                    _isRefreshingGimmicks = false;
                    ((MainViewController)this.MainViewController).UnblockUI();
                }
                else
                {
                    AppController.Utility.ExecuteOnAsyncTask(_cts0.Token,
                                                             () =>
                    {
                        gimmicks = AppController.GetGimmicks();
                    },
                                                             () =>
                    {
                        LoadGimmicks(gimmicks);

                        if (_source?.Count > 0)
                        {
                            this.GimmickList.Hidden = false;
                        }

                        _isRefreshingGimmicks = false;
                        ((MainViewController)this.MainViewController).UnblockUI();
                    });
                }
            });
        }
Ejemplo n.º 11
0
        private void Application_PushNotificationReceived(object sender, PushEventArgs e)
        {
            AppController.Utility.ExecuteOnMainThread(
                () =>
            {
                switch (e.Action)
                {
                case 1:

                    _lastMessageId = Int32.Parse(e.Payload);
                    RefreshMessages();

                    break;

                case 2:

                    if (e.Payload != _email.Split('@')[0])
                    {
                        PlaySound();

                        UIToast
                        .MakeText(String.Format("Say welocome to '{0}'", e.Payload), UIToastLength.Long)
                        .Show();
                    }

                    break;
                }
            });
        }
Ejemplo n.º 12
0
    IEnumerator RegexMatch(string file, UnityEngine.Events.UnityAction callBack)
    {
        string filePath = Application.persistentDataPath + "/" + file + ".txt";

        filePath = Regex.Replace(filePath, "/", @"\");
        var www = new WWW("file://" + filePath);

        yield return(www);

        string            nText   = www.text;
        string            pattern = @"[a-zA-Z]+.*[\u4e00-\u9fa5]+|[\u4e00-\u9fa5]+.*[a-zA-Z]+";
        var               mat     = Regex.Match(nText, pattern);
        int               count   = 0;
        List <Vocabulary> vocList = new List <Vocabulary>();

        while (mat.Success)
        {
            count++;
            string str = Regex.Replace(mat.Value, @"(\[.*\])+|[\uFE30-\uFFA0]+", " ");
            str = Regex.Replace(str, @"[ \n\s*\r]+", " ");

            //匹配词性 如abj.
            var    c  = Regex.Match(str, @"[a-z]+\.");
            string en = string.Empty;
            if (c.Success)
            {
                if (c.Value.Contains("sb") || c.Value.Contains("sth"))
                {
                    en  = str.Substring(0, c.Index + c.Length);
                    str = str.Substring(c.Index + c.Length);
                }
                else
                {
                    en  = str.Substring(0, c.Index - 1);
                    str = str.Substring(c.Index);
                }
                vocList.Add(new Vocabulary(en, str));
            }
            else
            {
                var enMat = Regex.Match(str, @"[a-zA-Z]+([ -][a-zA-Z]+)*");
                str = Regex.Replace(str, @"[a-zA-Z]+([ -][a-zA-Z]+)*", "");

                vocList.Add(new Vocabulary(enMat.Value, str));
            }
            mat = mat.NextMatch();
        }
        if (vocList.Count > 0)
        {
            //SaveVocList(SortVocList(vocList), file + ".xml");
            SaveVocList(vocList, file + ".xml");
            callBack.Invoke();
        }
        else
        {
            UIToast.ShowTips("词库解析失败,请检查词库格式是否正确", 2.0f);
        }
    }
    public static void CheckAndFixDependencies(Action <FirebaseStatus> status = null)
    {
#if USE_FIREBASE
        if (instance == null)
        {
            status?.Invoke(FirebaseStatus.Faulted);
            Debug.LogError("[Firebase] NULL");
            return;
        }

        if (DependencyStatus != DependencyStatus.Available && Status != FirebaseStatus.Checking)
        {
            try
            {
                Status = FirebaseStatus.Checking;
                FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
                {
                    if (task != null)
                    {
                        DependencyStatus = task.Result;
                        if (DependencyStatus == DependencyStatus.Available)
                        {
                            Debug.Log("[Firebase] CheckDependencies: " + DependencyStatus);
                            status?.Invoke(FirebaseStatus.Available);
                        }
                        else
                        {
                            Debug.LogError("[Firebase] CheckDependencies: " + DependencyStatus);
                            UIToast.ShowError(string.Format("Could not resolve all Firebase dependencies: {0}", DependencyStatus));
                            status?.Invoke(FirebaseStatus.Faulted);
                        }
                    }
                    else
                    {
                        Debug.LogError("[Firebase] CheckDependencies: " + DependencyStatus);
                        status?.Invoke(FirebaseStatus.Faulted);
                    }
                });
            }
            catch (FirebaseException ex)
            {
                Debug.LogError("[Firebase] CheckDependencies: " + ex.Message);
                status?.Invoke(FirebaseStatus.Faulted);
            }
            catch (Exception ex)
            {
                Debug.LogError("[Firebase] CheckDependencies: " + ex.Message);
                status?.Invoke(FirebaseStatus.Faulted);
            }
        }
        else
        {
            status?.Invoke(Status);
            Debug.Log("[Firebase] CheckDependencies again: " + DependencyStatus);
        }
#endif
    }
Ejemplo n.º 14
0
        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.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = data.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime();

                    ((AppDelegate)UIApplication.SharedApplication.Delegate).RegisterToNotificationsHub();

                    var c       = new ChatViewController();
                    c.Arguments = new UIBundle();
                    c.Arguments.PutString("Email", _email);
                    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();
                });
            }
        }
    private IEnumerator DoPrepairDataToPlay(StageData stage, Action <bool> actionOnDone = null)
    {
        UIToast.ShowLoading(randomTip, 5f, UIToast.IconTip);
        UILoadGame.Init(true, null);

        while (UILoadGame.currentProcess < 0.1f)
        {
            UILoadGame.Process(0, 1, -1, LocalizedManager.Key("base_Loading") + LocalizedManager.Key("base_PleaseWait"));
            yield return(null);
        }

        if (UIToast.Status != UIAnimStatus.IsShow)
        {
            UIToast.ShowLoading(randomTip, 5f, UIToast.IconTip);
        }

        MusicManager.Stop(null, false, 0.25f);

        if (string.IsNullOrEmpty(currentMode))
        {
            currentMode = modes[0];
        }

        //Init game object
        elapsedTime    = 0f;
        loadMidiStatus = FileStatus.Download;
        loadMidiStatus = FileStatus.Success;

        GameStateManager.Init(null);

        while (GameStateManager.CurrentState == GameState.Init || UILoadGame.currentProcess < 1)
        {
            if (GameStateManager.CurrentState != GameState.Idle && elapsedTime < 5)
            {
                UILoadGame.Process();
                elapsedTime += Time.deltaTime;
                yield return(null);
            }
            else
            {
                yield return(UILoadGame.DoRollBack(() =>
                {
                    UIToast.Hide();
                    actionOnDone(false);
                }));

                yield break;
            }
        }

        UIToast.Hide();
        actionOnDone(true);
    }
Ejemplo n.º 16
0
    public void OnClickButton(GameObject item, string fileName, int id)
    {
        Button[] bts = new Button[3];
        bts[0] = item.transform.Find("Buttons/Download").GetComponent <Button>();
        bts[1] = item.transform.Find("Buttons/Refresh").GetComponent <Button>();
        bts[2] = item.transform.Find("Buttons/Delete").GetComponent <Button>();
        //Debug.Log("FileList Size:" + fileList.Count);
        switch (id)
        {
        case 0:
        {
            //如果file存在 则设置为默认词库
            if (!File.Exists(Application.persistentDataPath + @"/" + fileName))
            {
                UIToast.ShowTips("请先下载词库", 2.0f);
            }
            else
            {
                PlayerPrefs.SetString(Conf.missionVocFileKey, fileName.Substring(0, fileName.Length - 4));
                PlayerPrefs.Save();
                UIToast.ShowTips("设置默认词库:" + fileName, 2.0f);
                headerTitle.text = "任务词库" + System.Environment.NewLine + PlayerPrefs.GetString(Conf.missionVocFileKey);
            }
        }
        break;

        case 1:
            //下载按钮响应
        {
            StartCoroutine(DownloadFile(item.name,
                                        Application.persistentDataPath + @"/" + fileName,
                                        bts));
        }
        break;

        case 2:
            //更新按钮响应
        {
            StartCoroutine(DownloadFile(item.name, Application.persistentDataPath + @"/" + fileName, bts));
        }
        break;

        case 3:
            //删除按钮响应
        {
            DeleteVocabularyLib(fileName, bts);
        }
        break;

        default:
            break;
        }
    }
Ejemplo n.º 17
0
 public void SelectDefaultFolderOrNot(Activity activity)
 {
     if (AppFileUtil.NeedScopedStorageAdaptation())
     {
         if (activity != null && TextUtils.IsEmpty(AppStorageManager.GetInstance(activity).DefaultFolder))
         {
             AppFileUtil.CheckCallDocumentTreeUriPermission(activity, MainActivity.REQUEST_SELECT_DEFAULT_FOLDER,
                                                            Uri.Parse(AppFileUtil.ExternalRootDocumentTreeUriPath));
             UIToast.GetInstance(activity).Show("Please select the default folder,you can create one when it not exists.");
         }
     }
 }
Ejemplo n.º 18
0
 private IEnumerator DownloadFile(string address, string path, Button[] bts)
 {
     if (Application.internetReachability != NetworkReachability.NotReachable)
     {
         net = new WWW(address);
         yield return(StartCoroutine(DownloadProgress(path, bts)));
     }
     else
     {
         UIToast.ShowTips("无网络连接...", 2.0f);
         yield return(0);
     }
 }
Ejemplo n.º 19
0
        private void SendMessage()
        {
            string content = this.MessageText.Text;

            if (!String.IsNullOrWhiteSpace(content))
            {
                if (_isSendingMessage)
                {
                    return;
                }

                _isSendingMessage = true;

                // Add message to the message list
                Message message = new Message {
                    Sender = null, Content = content, SendDate = DateTime.MinValue
                };
                _source.AddItem(message);
                this.MessageList.ReloadData();
                this.MessageList.ScrollToRow(
                    NSIndexPath.FromItemSection((nint)(_source.Count - 1), 0),
                    UITableViewScrollPosition.Bottom,
                    false);

                _cts1 = new CancellationTokenSource();
                AppController.SendMessage(_cts1,
                                          _email,
                                          content,
                                          (data) =>
                {
                    message.MessageId = data.MessageId;
                    message.SendDate  = data.SendDate.GetValueOrDefault();
                    this.MessageList.ReloadData();
                },
                                          (error) =>
                {
                    message.SendDate = DateTime.MaxValue;
                    this.MessageList.ReloadData();

                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                          () =>
                {
                    _isSendingMessage = false;
                });

                // Ready to send new message
                this.MessageText.Text = String.Empty;
                AdjustMessageTextHeight();
            }
        }
Ejemplo n.º 20
0
        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();
                    });
                });
            }
        }
Ejemplo n.º 21
0
 static int Show(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         UIToast.Show(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 22
0
    public void Ins_OnSelected()
    {
        if (currStageData.isUnlocked)
        {
            //DataManager.CurrentStage = currStageData;

            DataManager.CurrentStage = DataManager.Next();
            GameStateManager.LoadGame(null);
        }
        else
        {
            UIToast.ShowNotice($"{currStageData.name} is locked!");
        }
    }
Ejemplo n.º 23
0
    public void OnButtonClick(int tag)
    {
        switch (tag)
        {
        //选择词库
        case 1:
        {
            Debug.Log("点击选择词库");
            //读取词库列表,显示在选择词库对话框
            loader.LoadXmlFile();
        }
        break;

        //游戏说明
        case 2:
        {
            Debug.Log("游戏说明");
            var textObj = loader.aboutDialog.transform.Find("Window/Scroll View/Viewport/Content/UserDefine");
            if (textObj)
            {
                var text = textObj.GetComponent <Text>();
                text.text = "Version:" + Application.version + System.Environment.NewLine +
                            System.Environment.NewLine +
                            "自定义词库存放目录:" +
                            System.Environment.NewLine + Application.persistentDataPath;
            }
            loader.aboutDialog.SetActive(true);
        }
        break;

        case 3:
        {
            loader.LoadVocLibAndStartGame(1);
        }
        break;

        case 4:
        {
            //DataLoader.Instance(this).LoadVocLibAndStartGame(2);
            UIToast.ShowTips("呼呼~ 此功能正在开发中...", 2.0f);
        }
        break;

        case 5:
            //退出
            Application.Quit();
            break;
        }
    }
Ejemplo n.º 24
0
        public bool ValidateInput()
        {
            var validator = new WidgetValidator()
                            .AddValidator(() => this.PasswordText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a password.")
                            .AddValidator(() => this.PasswordText.Text, WidgetValidator.IsPasswordMin8, "Your password is not valid!");

            string errorMessage;

            if (!validator.Validate(out errorMessage))
            {
                UIToast.MakeText(errorMessage, UIToastLength.Long).Show();
                return(false);
            }

            return(true);
        }
 public virtual void ShowResult()
 {
     UIToast.ShowLoading("", 1);
     InitResultData();
     Status = UIAnimStatus.IsAnimationShow;
     if (anim.Status != UIAnimStatus.IsShow)
     {
         anim.Show(() => {
             animResult.Show(null, () => OnShowResult());
         });
     }
     else
     {
         animResult.Show(null, () => OnShowResult());
     }
 }
Ejemplo n.º 26
0
        private bool ValidateInput()
        {
            var validator = new WidgetValidator()
                            .AddValidator(() => this.EmailText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a valid email")
                            .AddValidator(() => this.EmailText.Text, WidgetValidator.IsEmail, "Your email is not valid!");

            string errorMessage;

            if (!validator.Validate(out errorMessage))
            {
                UIToast.MakeText(errorMessage, UIToastLength.Long).Show();
                return(false);
            }

            return(true);
        }
Ejemplo n.º 27
0
        public void DataRequestHandler(GraphRequestConnection connection, NSObject result, NSError err)
        {
            try
            {
                string fbId    = result.ValueForKey(new NSString("id")).ToString();
                string fbToken = AccessToken.CurrentAccessToken.TokenString;
                string fbEmail = result.ValueForKey(new NSString("email")).ToString();

                _email = fbEmail;

                // Create a new cancellation token for this request
                _cts0 = new CancellationTokenSource();
                AppController.LoginUser(_cts0, fbId, fbEmail, fbToken,
                                        // Service call success
                                        (data) =>
                {
                    AppController.Settings.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = data.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime();

                    ((AppDelegate)UIApplication.SharedApplication.Delegate).RegisterToNotificationsHub();

                    var c       = new ChatViewController();
                    c.Arguments = new UIBundle();
                    c.Arguments.PutString("Email", _email);
                    this.NavigationController.PushViewController(c, true);
                },
                                        // Service call error
                                        (error) =>
                {
                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                        // Service call finished
                                        () =>
                {
                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
            catch (Exception ex)
            {
                ((MainViewController)this.MainViewController).UnblockUI();

                UIToast.MakeText("Error", UIToastLength.Long).Show();
            }
        }
Ejemplo n.º 28
0
        private bool ValidateInput()
        {
            var validator = new WidgetValidator()
                            .AddValidator(() => this.TitleText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a title!")
                            .AddValidator(() => this.DescriptionText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a description!");

            string errorMessage;

            if (!validator.Validate(out errorMessage))
            {
                UIToast.MakeText(errorMessage, UIToastLength.Long).Show();

                return(false);
            }

            return(true);
        }
Ejemplo n.º 29
0
        private bool ValidateInput()
        {
            var validator = new WidgetValidator()
                            .AddValidator(() => this.TitleText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a title!")
                            .AddValidator(() => this.DescriptionText.Text, WidgetValidator.IsNotNullOrEmpty, "Please insert a description!")
                            .AddValidator(() => this.TagsText.Text, (string s) => String.IsNullOrWhiteSpace(s) || !s.Contains(" "), "Tags must be comma separated list, no blanks!");

            string errorMessage;

            if (!validator.Validate(out errorMessage))
            {
                UIToast.MakeText(errorMessage, UIToastLength.Long).Show();

                return(false);
            }

            return(true);
        }
Ejemplo n.º 30
0
        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
                ((MainViewController)this.MainViewController).BlockUI();

                this.VerifyButton.Hidden = true;

                // Create a new cancellation token for this request
                _cts1 = new CancellationTokenSource();
                AppController.VerifyUser(_cts1, _email, _password,
                                         // Service call success
                                         () =>
                {
                    UIToast.MakeText("You should receive a new mail!", UIToastLength.Long).Show();
                },
                                         // Service call error
                                         (error) =>
                {
                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                         // Service call finished
                                         () =>
                {
                    _isConfirmingUser = false;

                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
        }