public async Task getDataFromServer() { IList <Lesson> lessons = null; try { lessons = await LessonUtil.GetLessonsByModuleAsync(module_id); } catch (Exception ex) { DialogFactory.ToastDialog(this, "Data Error", "Error Connecting to Server,please try again later!", Constants.LESSON_ERROR); } if (lessons != null) { sourceDateList = new List <SortModel> (); foreach (var lesson in lessons) { string name = lesson.Title; if (name.Length > 0) { string firstAlpha = name.Substring(0, 1).ToUpper(); SortModel temp = new SortModel(); temp.SortLetters = firstAlpha; temp.Name = name; temp.LessonId = lesson.Id; temp.ScreenCount = lesson.ScreenCount; sourceDateList.Add(temp); } else { continue; } } sourceDateList.Sort(); } }
private Boolean updateAnswers() { switch (screen.Type) { case "text_essay_audio_image": var textessayaudioimage = fragment as TextEssayAudioImageFragment; var eText = textessayaudioimage.et_answer.Text; if (string.IsNullOrEmpty(eText)) { DialogFactory.ToastDialog(this, "Empty answer", "Please type your answer", 0); return(false); } recordAnswer(eText); break; case "question": //selected var question = fragment as QuestionFragment; var checkedId = (question.choicesRadioGroup as RadioGroup).CheckedRadioButtonId; if (checkedId < 0) { //not selected DialogFactory.ToastDialog(this, "No selection", "Please select one answer", 0); return(false); } recordAnswer(checkedId + ""); recordSelectedAnswer(screen.Id, question.options [checkedId].Id); break; case "audio_question": case "question_audio": //selected var audioquestion = fragment as QuestionAudioFragment; var cId = (audioquestion.choicesRadioGroup as RadioGroup).CheckedRadioButtonId; if (cId < 0) { //not selected DialogFactory.ToastDialog(this, "No selection", "Please select one answer", 0); return(false); } recordAnswer(cId + ""); recordSelectedAnswer(screen.Id, audioquestion.options [cId].Id); break; case "text_question_audio_image": var textquestionaudioimage = fragment as TextQuestionAudioImageFragment; var tId = (textquestionaudioimage.choicesRadioGroup as RadioGroup).CheckedRadioButtonId; if (tId < 0) { //not selected DialogFactory.ToastDialog(this, "No selection", "Please select one answer", 0); return(false); } recordAnswer(tId + ""); recordSelectedAnswer(screen.Id, textquestionaudioimage.options [tId].Id); break; default: break; } return(true); }
private async Task getScreenFromServer() { try { screens = await LessonUtil.GetScreensByLessonAsync(lesson_id); } catch (Exception ex) { DialogFactory.ToastDialog(this, "Data Error", "Error Connecting to Server,please try again later!", Constants.TEXT_ERROR); } if (screens != null) { //make text and images screen = screens [0]; string type = screen.Type; if (type.Contains("text")) { var texts = screen.Texts; Utils.makeTextViews(texts, this, ll_content, Color.Black); } if (type.Contains("image")) { var imageslist = screen.Images; var images = new List <Image> (imageslist); Utils.makeTextImages(this, ll_content, images); } //make return button Utils.makeReturnButton(this, ll_content); ll_content.Visibility = ViewStates.Visible; ll_load.Visibility = ViewStates.Invisible; } }
private async void registerUser() { var result = await UserUtil.RegisterUserAsync(user); if (result.Item1 == true) { //register successfully DialogFactory.ToastDialog(this, "Register success", "Congratulations,you have registered successfully!You will receive an email with password!", Constants.REGISTER_SUCCESS); } else { //register fail DialogFactory.ToastDialog(this, "Register fail", "this email has been registered", 0); //to do: more specific error msg } }
public override void initListner () { //set edittext listener mClearEditText.AddTextChangedListener (new MyTextChangedListener (this)); //set item click listener sortListView.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) { SortModel user = sourceDateList [e.Position]; if (user.ScreenCount > 0) { Intent intent = new Intent (this, typeof(TextActivity)); intent.PutExtra ("lesson_id", user.LessonId); intent.PutExtra ("lesson_name", user.Name); StartActivity (intent); } else { DialogFactory.ToastDialog (this, "Empty lesson", "Oops,this lesson has not uploaded yet!", 0); } }; }
public async void getLessonsFromServer() { try { var lessons = await LessonUtil.GetLessonsByModuleAsync(module_id); lessonList = new List <Lesson> (lessons); } catch (Exception ex) { DialogFactory.ToastDialog(this, "Server busy", "Server is busy,please drag down to refresh later", 0); tv_pull_list_header_title.Text = "Server busy!"; tv_pull_list_header_title.SetTextColor(Color.Red); } if (lessonList != null) { lv_list.onRefreshComplete(); lv_list.Adapter = new MyListViewAdapter(this, lessonList); lv_list.setOnRefreshListener(new MyRefreshListener(this)); lv_list.Visibility = ViewStates.Visible; ll_load.Visibility = ViewStates.Invisible; } }
public async void initData() { //register battery change broadcast RegisterBatteryChangedReceiver(); //check vitamio installed? if (!LibsChecker.CheckVitamioLibs(Activity)) { return; } //get video_url video_url = Utils.EncodeURL(getVideoUrl()); if (!string.IsNullOrEmpty(video_url)) { vv.SetVideoURI(Android.Net.Uri.Parse(Utils.EncodeURL(video_url))); } else { DialogFactory.ToastDialog(Activity, "Connect error", "Connect error,please try again later!", Constants.RETURN_LIST); } vv.RequestFocus(); vv.Prepared += delegate(object sender, IO.Vov.Vitamio.MediaPlayer.PreparedEventArgs e) { e.P0.SetPlaybackSpeed(1.0f); //start play vv.Start(); //put duration string duration = Utils.formatMillis(vv.Duration); //set duration tv_duration.Text = duration; sb_video.Max = (int)vv.Duration; updateCurrentPosition(); btn_play.SetBackgroundResource(Resource.Drawable.selector_btn_pause); //set play button tv_title.Text = Activity.Intent.GetStringExtra(Constants.LESSON_TITLE) + ":" + Activity.Intent.GetStringExtra(Constants.LESSON_DES); //set video title //hide the loading progress bar hideLoadingCtl(); }; //control volume initVolume(); // scale volume maxVlumeScreenHeightScale = ((float)maxVolume) / Utils.getWindowWidth(Activity); //set screen width and height screenWidth = Utils.getWindowWidth(Activity); screenHeight = Utils.getWindowHeight(Activity); }
private async void getVideoUrlFromServer() { var result = await LessonUtil.GetScreensByLessonAsync(lessonId); if (result != null && result.Count > 0) { Constants.screens = result; //jump to screenactivity Intent intent = new Intent(this, typeof(ScreensActivity)); intent.PutExtra(Constants.LESSON_TITLE, currentLesson.Title); intent.PutExtra(Constants.LESSON_DES, currentLesson.Description); intent.PutExtra(Constants.LESSON_ID, currentLesson.Id); StartActivity(intent); Finish(); } else { lv_list.Visibility = ViewStates.Visible; ll_load.Visibility = ViewStates.Invisible; DialogFactory.ToastDialog(this, "Empty lesson", "Oops,this lesson has not uploaded yet!", 0); } }
public async void getModulesFromServer() { try { var modules = await LessonUtil.GetModulesAsync(); Constants.currentUser = await UserUtil.GetCurrentUserAsync(); moduleList = new List <Module> (modules); } catch (Exception ex) { DialogFactory.ToastDialog(activity, "Server busy", "Server is busy,please login later", Constants.LOGIN_TIMEOUT); } if (Constants.currentUser == null) { //illegal login DialogFactory.ToastDialog(activity, "Login timeout", "Timeout,please login again", Constants.LOGIN_TIMEOUT); } else { lv_list.Adapter = new MyModuleListAdapter(moduleList, this.activity); lv_list.Visibility = ViewStates.Visible; ll_load.Visibility = ViewStates.Invisible; } }
public void OnBackPressed() { DialogFactory.ToastDialog(Activity, "Back", "Please finish watching this lesson!", 0); }
/// <summary> /// Submits the answers. /// </summary> private void submitAnswers() { updateAnswers(); //toast a dialog DialogFactory.toastNegativePositiveDialog(this, "Submit", "Are you sure to submit the answers", Constants.SUBMIT_ANSWERS); }
public override void OnFinish() { DialogFactory.ToastDialog(context, "Time up", "Time is out,it will go to result screen!", Constants.TIME_UP); }
public override void OnBackPressed() { //back pressed DialogFactory.ToastDialog(this, "Return", "Please answer all questions and submit!", 0); }
/// <summary> /// Login this instance. /// </summary> public async void Login() { email = login_accounts.Text; password = login_password.Text; //loginTest (); //check internet bool isNetWorking = Utils.isNetworkAvailable(this); if (isNetWorking == true) { //todo:check empty if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { DialogFactory.ToastDialog(this, "Login", "Username and password cannot be empty!", 0); } else { //check email Match match = Regex.Match(email, "^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$"); if (match.Success) { //Authenticate View popView = View.Inflate(this, Resource.Layout.popup_authenticate, null); pop = new PopupWindow(popView, 320, 200); pop.ShowAtLocation(login_btn, GravityFlags.Center, 0, 20); //Modal ll_loginpage.Alpha = 0.5f; EnableAllViews(false); //check email and password to server try { result = await UserUtil.AuthenticateUserAsync(email, password); } catch (Exception ex) { ll_loginpage.Alpha = 1.0f; EnableAllViews(true); pop.Dismiss(); AlertDialog.Builder ab = new AlertDialog.Builder(this); ab.SetTitle("Server busy"); ab.SetMessage("Server is busy,please try again later!"); ab.SetPositiveButton("confirm", delegate(object sender, DialogClickEventArgs e) { }); ab.Create().Show(); } if (result != null) { if (result.Item2 != null) { //login successfully //remember me? bool check = auto_save_password.Checked; if (auto_save_password.Checked) { edit.PutString("email", email); edit.PutString("password", password); edit.PutBoolean("checked", check); edit.Commit(); } else { edit.PutBoolean("checked", check); edit.Commit(); } Toast.MakeText(this, "Login successfully!", ToastLength.Short).Show(); Intent intent = new Intent(this, typeof(HomeActivity)); intent.PutExtra("email", email); intent.PutExtra("token", result.Item2); StartActivity(intent); Finish(); } else { ll_loginpage.Alpha = 1.0f; pop.Dismiss(); EnableAllViews(true); //failed DialogFactory.ToastDialog(this, "Login", "Username or password is not correct!", 0); //to do:specific error msg } } } else { ll_loginpage.Alpha = 1.0f; pop.Dismiss(); EnableAllViews(true); DialogFactory.ToastDialog(this, "Login", "Email format is incorrent!", 0); } } } else { DialogFactory.ToastDialog(this, "Connect Error", "There is no internet,please connect the internet!", 0); } }
public override void initListner() { //back button btn_regback.Click += delegate(object sender, EventArgs e) { StartActivity(new Intent(this, typeof(LoginActivity))); Finish(); }; //continue button btn_continue.Click += delegate(object sender, EventArgs e) { //reset color to black clearColor(); //get edittext string firstname = et_firstname.Text; string lastname = et_lastname.Text; string email = et_email.Text; string phonenumber = et_phonenumber.Text; //string password = et_password.Text; //string confirmpwd = et_confirmpwd.Text; //Empty check if (string.IsNullOrEmpty(firstname)) { tv_firstname.SetTextColor(Color.Red); DialogFactory.ToastDialog(this, "Empty info", "Firstname cannot be empty!", 0); } else if (string.IsNullOrEmpty(lastname)) { tv_lastname.SetTextColor(Color.Red); DialogFactory.ToastDialog(this, "Empty info", "Lastname cannot be empty!", 0); } else if (string.IsNullOrEmpty(email)) { tv_email.SetTextColor(Color.Red); DialogFactory.ToastDialog(this, "Empty info", "Email cannot be empty!", 0); } else if (string.IsNullOrEmpty(phonenumber)) { tv_phonenumber.SetTextColor(Color.Red); DialogFactory.ToastDialog(this, "Empty info", "Phone number cannot be empty!", 0); } /*else if (string.IsNullOrEmpty (password)) { * tv_password.SetTextColor (Color.Red); * DialogFactory.ToastDialog (this, "Empty info", "Password cannot be empty!", 0); * } else if (string.IsNullOrEmpty (confirmpwd)) { * tv_email.SetTextColor (Color.Red); * DialogFactory.ToastDialog (this, "Empty info", "Confirm password cannot be empty!", 0); * }*/ else { //email check Match match = Regex.Match(email, "^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$"); if (match.Success) { //check password and confirmpassword //Create user and set info user = new User(); user.FirstName = firstname; user.LastName = lastname; //user.Password = password; user.Phone = phonenumber; user.Email = email; //connect to server registerUser(); } /*else { * DialogFactory.ToastDialog (this, "Password", "Password cannot match confirm password!", 0); * tv_password.SetTextColor (Color.Red); * tv_confirmpwd.SetTextColor (Color.Red); * }*/ else { //email format incorrect DialogFactory.ToastDialog(this, "Email Format", "Email format is incorrent!", 0); tv_email.SetTextColor(Color.Red); } } }; }
public override void OnBackPressed() { DialogFactory.toastNegativePositiveDialog(this, "Exit", "Are you sure to log out?", Constants.EXIT_CHOICE); }
public void initListner() { sb_voice.ProgressChanged += ((sender, e) => { if (e.FromUser) { setStreamVolume(e.Progress); } }); sb_video.ProgressChanged += delegate(object sender, SeekBar.ProgressChangedEventArgs e) { if (e.FromUser) { if (vv.IsPlaying) { vv.SeekTo(e.Progress); } else { vv.SeekTo(e.Progress); btn_play.SetBackgroundResource(Resource.Drawable.selector_btn_play); } } }; //video buffer listener vv.BufferingUpdate += delegate(object sender, IO.Vov.Vitamio.MediaPlayer.BufferingUpdateEventArgs e) { updateSecondaryProgress(e); }; //set buffered slow listener vv.Info += delegate(object sender, IO.Vov.Vitamio.MediaPlayer.InfoEventArgs e) { switch (e.P1) { //buffer started case (int)MediaInfo.BufferingStart: ll_loading.Visibility = ViewStates.Visible; break; //buffer end then play case (int)MediaInfo.BufferingEnd: hideLoadingCtl(); break; default: break; } }; if (!screen.Type.Equals("audio-text-video")) { vv.Completion += delegate(object sender, IO.Vov.Vitamio.MediaPlayer.CompletionEventArgs e) { vv.SeekTo(0); tv_current_position.Text = Utils.formatMillis(0L); var activity = Activity as ScreensActivity; //set iswatched editor.PutBoolean(screen.Id + "", true).Commit(); tv_loading.Text = "You have watched this video!"; activity.validateBtns(); }; } btn_voice.Click += delegate(object sender, EventArgs e) { toggleMute(); }; btn_exit.Click += delegate(object sender, EventArgs e) { DialogFactory.toastNegativePositiveDialog(Activity, "Return", "Are you sure to return to Lesson List?", Constants.RETURN_LIST_NEG); }; btn_play.Click += delegate(object sender, EventArgs e) { play(); }; btn_share.Click += delegate(object sender, EventArgs e) { //todo:share function }; }