public static void RequestShowCheckinDialog(this IDialogManager dialogManager, IAppContext context)
        {
            var dataRepository      = context.GetDataRepository();
            var checkinConfigResult = dataRepository.GetContainer <CheckinConfigResult>(DataKey.CheckinConfigResult);
            var remoteAPI           = context.GetRemoteAPI();

            dialogManager.RequestDialog <CheckinDialog>(
                DialogName.CheckinDialog,
                () =>
            {
                checkinConfigResult.ClearNotInvalidate();
                remoteAPI.RequestCheckinConfig();
            },
                () =>
            {
                var data = checkinConfigResult.Read();
                if (data == null)
                {
                    return(null);
                }

                if (data.res.code == ResultCode.OK)
                {
                    return(TaskResult.Success());
                }
                else
                {
                    return(TaskResult.Fail(data.res.code, data.res.msg));
                }
            },
                () =>
            {
                dialogManager.ShowDialog <CheckinDialog>(DialogName.CheckinDialog, false, false,
                                                         (dialog) =>
                {
                    dialogManager.AddDialogToCacheDialog(DialogName.CheckinDialog, dialog);
                    dialog.Show();
                });
            },
                (errCode, errMsg) =>
            {
                // fail
                if (!string.IsNullOrEmpty(errMsg))
                {
                    dialogManager.ShowToast(errMsg, 3, true);
                }
                else
                {
                    dialogManager.ShowToast("请求签到数据失败", 3, true);
                }
            }
                );
        }
예제 #2
0
        public void OnRuleBtnClicked()
        {
            _dialogManager.RequestDialog <RaceIntroduceDialog>(
                DialogName.RaceIntroduceDialog,
                () =>
            {
                _raceDescriptionResult.ClearNotInvalidate();
                GetRaceDescriptionResult();
            },
                () =>
            {
                var data = _raceDescriptionResult.Read();
                if (data == null)
                {
                    return(null);
                }

                if (data.result == RaceDescriptionResult.Ok)
                {
                    return(TaskResult.Success());
                }
                else
                {
                    return(TaskResult.Fail(data.result, data.error));
                }
            },
                () =>
            {
                _dialogManager.ShowDialog <RaceIntroduceDialog>(DialogName.RaceIntroduceDialog, false, false,
                                                                (dialog) =>
                {
                    dialog.Apply(_data, _raceDescriptionResult.Read());
                    dialog.Show();
                });
            },
                (errCode, errMsg) =>
            {
                if (!string.IsNullOrEmpty(errMsg))
                {
                    _dialogManager.ShowToast(errMsg, 3, true);
                }
                else
                {
                    _dialogManager.ShowToast("获取比赛信息失败", 3, true);
                }
            }
                );
        }
        public static void ShowUserTaskDialog(this IDialogManager dialogManager, IAppContext context)
        {
            var dataRepository     = context.GetDataRepository();
            var userTaskListResult = dataRepository.GetContainer <UserTaskListResult>(DataKey.UserTaskListResult);

            dialogManager.RequestDialog <UserTaskDialog>(DialogName.UserTaskDialog,
                                                         () =>
            {
                var remoteApi = context.GetRemoteAPI();
                userTaskListResult.ClearNotInvalidate();
                remoteApi.RequestUserTaskList();
            },
                                                         () =>
            {
                var data = userTaskListResult.Read();
                if (data == null)
                {
                    return(null);
                }

                var res = data.res;
                if (res == null)
                {
                    return(null);
                }

                if (res.code == ResultCode.OK)
                {
                    var taskList = data.user_task_state;
                    if (taskList == null || taskList.Count <= 0)
                    {
                        return(TaskResult.Fail(ResultCode.FAILED, "没有任务数据"));
                    }
                    return(TaskResult.Success());
                }
                else
                {
                    return(TaskResult.Fail(res.code, res.msg));
                }
            },
                                                         () =>
            {
                dialogManager.ShowDialog <UserTaskDialog>(DialogName.UserTaskDialog, false, false,
                                                          (dialog) =>
                {
                    var data = userTaskListResult.Read();
                    if (data != null)
                    {
                        dialogManager.AddDialogToCacheDialog(DialogName.UserTaskDialog, dialog);
                        dialog.Show();
                    }
                });
            },
                                                         (errCode, errMsg) =>
            {
                if (!string.IsNullOrEmpty(errMsg))
                {
                    dialogManager.ShowToast(errMsg, 3, true);
                }
                else
                {
                    dialogManager.ShowToast("获取任务信息失败", 3, true);
                }
            });
        }