public async Task getDataFromServer() { //if (ic.connectivity()) //{ progress.Show(); dynamic value = new ExpandoObject(); value.task_id = task_id_to_send; string json = JsonConvert.SerializeObject(value); try { JsonValue item = await restService.GetComplianceTask(Activity, json, geolocation); comp = JsonConvert.DeserializeObject <ComplianceModel>(item); //db.ComplianceInsert(compliance); progress.Dismiss(); } catch (Exception e) { progress.Dismiss(); } //} // List< ComplianceModel>comp= db.GetCompliance(task_id_to_send); shapes1 = JsonConvert.DeserializeObject <Shapes>(comp.shapes); task_id = comp.task_id; task_description = comp.description; deadline = comp.deadline_date; meatingid = comp.Meeting_ID; rownum = comp.RowNo; //taskcreationDate = comp.task_creation_date; markby = comp.task_mark_by; taskstatus = comp.taskStatus; markto = comp.markTo; markingtype = comp.task_marking_type; taskcreatedby = comp.task_created_by; markingDate = comp.MarkingDate; creationdate = comp.task_creation_date; shapes_from_Comp = comp.shapes; task_name = comp.task_name; List <ComplianceJoinTable> lstAddedCompliance = comp.lstAddedCompliance; List <CommunicationModel> lstCommunication = comp.lstCommunication; List <TaskFilemappingModel2> lstTaskFileMapping = comp.lstTaskFileMapping; List <Comp_AttachmentModel> lstUploadedCompliance = comp.lstUploadedCompliance; image_lst = new List <ComplianceJoinTable>(); audio_lst = new List <ComplianceJoinTable>(); video_lst = new List <ComplianceJoinTable>(); for (int i = 0; i < lstAddedCompliance.Count; i++) { if (lstAddedCompliance[i].file_type.Equals("Image")) { image_lst.Add(lstAddedCompliance[i]); img_max += lstAddedCompliance[i].max_numbers; try { if (lstAddedCompliance[i].complianceType.ToLower().Equals("mandatory")) { img_min += lstAddedCompliance[i].max_numbers; } } catch (Exception e) { } } else if (lstAddedCompliance[i].file_type.Equals("Audio")) { audio_lst.Add(lstAddedCompliance[i]); aud_max += lstAddedCompliance[i].max_numbers; try { if (lstAddedCompliance[i].complianceType.ToLower().Equals("mandatory")) { aud_min += lstAddedCompliance[i].max_numbers; } } catch (Exception e) { } } else if (lstAddedCompliance[i].file_type.Equals("Video")) { video_lst.Add(lstAddedCompliance[i]); vdo_max += lstAddedCompliance[i].max_numbers; try { if (lstAddedCompliance[i].complianceType.ToLower().Equals("mandatory")) { vdo_min += lstAddedCompliance[i].max_numbers; } } catch (Exception e) { progress.Dismiss(); } } } for (int j = 0; j < lstCommunication.Count; j++) { if (lstCommunication[j].role.Equals("Assigner")) { mark_by_num = lstCommunication[j].mobile; } if (lstCommunication[j].role.Equals("Creator")) { creat_by_num = lstCommunication[j].mobile; } } // db.InsertCreatecomplianceAttachData(lstTaskFileMapping, task_id_to_send); audio_comp_lst = new List <Comp_AttachmentModel>(); video_comp_lst = new List <Comp_AttachmentModel>(); image_comp_lst = new List <Comp_AttachmentModel>(); for (int l = 0; l < lstUploadedCompliance.Count; l++) { if (lstUploadedCompliance[l].file_type.Equals("Video")) { video_comp_lst.Add(lstUploadedCompliance[l]); } if (lstUploadedCompliance[l].file_type.Equals("Audio")) { audio_comp_lst.Add(lstUploadedCompliance[l]); } if (lstUploadedCompliance[l].file_type.Equals("Image")) { image_comp_lst.Add(lstUploadedCompliance[l]); } } descrip_text.Text = task_description; createdby_text.Text = taskcreatedby; markby_text.Text = markby; creationdate_text.Text = creationdate; deadline_text.Text = deadline; name_text.Text = task_name; uploadimage.Text = image_comp_lst.Count.ToString(); uploadaudio.Text = audio_comp_lst.Count.ToString(); uploadvideo.Text = video_comp_lst.Count.ToString(); //if(!task_description.Equals("") && task_description != null) //{ // ll_task_desc.Visibility = ViewStates.Visible; // task_desc.Text = task_description; //} //else //{ // ll_task_desc.Visibility = ViewStates.Gone; //} Image_no.Text = img_max.ToString(); Video_no.Text = vdo_max.ToString(); Audio_no.Text = aud_max.ToString(); adapter1 = new GridViewAdapter_Image(Activity, image_comp_lst, FragmentManager); Gridview1.Adapter = adapter1; adapter2 = new GridViewAdapter_Video(Activity, video_comp_lst, FragmentManager); Gridview2.Adapter = adapter2; adapter3 = new GridViewAdapter_Audio(Activity, audio_comp_lst, FragmentManager); Gridview3.Adapter = adapter3; progress.Dismiss(); }
public void recording() { View view = LayoutInflater.Inflate(Resource.Layout.audio_recorder, null); Android.App.AlertDialog builder = new Android.App.AlertDialog.Builder(Activity).Create(); builder.SetView(view); builder.Window.SetLayout(600, 600); builder.SetCanceledOnTouchOutside(false); recordbtn = view.FindViewById <Button>(Resource.Id.recordbtn); stopbtn = view.FindViewById <ImageView>(Resource.Id.stopbtn); playbtn = view.FindViewById <ImageView>(Resource.Id.playbtn); Timer = view.FindViewById <TextView>(Resource.Id.timerbtn); seekBar = view.FindViewById <SeekBar>(Resource.Id.seek_bar); Done_Btn = view.FindViewById <Button>(Resource.Id.donebtn); Done_Btn.Click += delegate { long size3 = fileaudioPath.Length() / 1024; string audiosize = size3.ToString(); Comp_AttachmentModel attachmentModel = new Comp_AttachmentModel(); attachmentModel.localPath = AudioSavePathInDevice; attachmentModel.file_type = "Audio"; attachmentModel.FileName = audioname; attachmentModel.taskId = task_id_to_send; attachmentModel.GeoLocation = geolocation; attachmentModel.FileSize = audiosize; attachmentModel.file_format = ".mp3"; // attachmentModel.max_numbers = audio_max.ToString(); db.InsertAttachmentData(attachmentModel, "no"); //comp_AttachmentModels.Add(attachmentModel); //imagelist.AddRange(comp_AttachmentModels.Where(p => p.Attachment_Type == "Image" )); audio_comp_lst.AddRange(db.GetAttachmentData(audioname)); // postattachmentcomplianceAsync(attachmentModel); adapter3 = new GridViewAdapter_Audio(Activity, audio_comp_lst, FragmentManager); Gridview3.Adapter = adapter3; if (ic.connectivity()) { postattachmentcomplianceAsync(attachmentModel); // db.updateComplianceattachmentstatus("yes"); } builder.Dismiss(); }; recordbtn.Click += delegate { MediaRecorderReady(); try { timer = new Timer(); timer.Interval = 1000; // 1 second timer.Elapsed += Timer_Elapsed; timer.Start(); mediaRecorder.Stop(); mediaRecorder.Prepare(); mediaRecorder.Start(); } catch (Exception e) { // TODO Auto-generated catch block //e.printStackTrace(); } Toast.MakeText(Activity, "Recording started", ToastLength.Long).Show(); }; stopbtn.Click += delegate { try { mediaRecorder.Stop(); Timer.Text = "00:00:00"; timer.Stop(); timer = null; } catch (Exception ex) { } //stoprecorder(); //btn2.Enabled=false; //buttonPlayLastRecordAudio.setEnabled(true); //buttonStart.setEnabled(true); //buttonStopPlayingRecording.setEnabled(false); Toast.MakeText(Activity, "Recording completed", ToastLength.Long).Show(); }; //pausebtn.Click += delegate //{ // //OnPause(); // mediaRecorder.Pause(); // timer.Dispose(); //}; playbtn.Click += delegate { mediaPlayer = new MediaPlayer(); mediaPlayer.SetDataSource(AudioSavePathInDevice); mediaPlayer.Prepare(); mediaPlayer.Start(); //mediaPlayer = MediaPlayer.Create(this, Resource.Raw.AudioSavePathInDevice); seekBar.Max = mediaPlayer.Duration; run(); }; builder.Show(); }
public void recording() { View view = LayoutInflater.Inflate(Resource.Layout.audio_recorder, null); Android.App.AlertDialog builder = new Android.App.AlertDialog.Builder(this).Create(); builder.SetView(view); builder.Window.SetLayout(600, 600); builder.SetCanceledOnTouchOutside(false); recordbtn = view.FindViewById <Button>(Resource.Id.recordbtn); stopbtn = view.FindViewById <ImageView>(Resource.Id.stopbtn); playbtn = view.FindViewById <ImageView>(Resource.Id.playbtn); Timer = view.FindViewById <TextView>(Resource.Id.timerbtn); seekBar = view.FindViewById <SeekBar>(Resource.Id.seek_bar); Done_Btn = view.FindViewById <Button>(Resource.Id.donebtn); Done_Btn.Click += delegate { Comp_AttachmentModel attachmentModel = new Comp_AttachmentModel(); attachmentModel.Attachment_Path = AudioSavePathInDevice; attachmentModel.Attachment_Type = "Audio"; attachmentModel.Attachment_Name = audioname; attachmentModel.Task_id = task_id_to_send; db.InsertAttachmentData(attachmentModel); //comp_AttachmentModels.Add(attachmentModel); //imagelist.AddRange(comp_AttachmentModels.Where(p => p.Attachment_Type == "Image" )); audiolist = db.GetAttachmentData("Audio"); adapter3 = new GridViewAdapter_Audio(this, audiolist); Gridview3.Adapter = adapter3; Gridview3.setExpanded(true); Gridview3.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal; Gridview3.SetMultiChoiceModeListener(new MultiChoiceModeListener3(this)); audioCount++; builder.Dismiss(); }; recordbtn.Click += delegate { MediaRecorderReady(); try { timer = new Timer(); timer.Interval = 1000; // 1 second timer.Elapsed += Timer_Elapsed; timer.Start(); mediaRecorder.Prepare(); mediaRecorder.Start(); } catch (Exception e) { // TODO Auto-generated catch block //e.printStackTrace(); } Toast.MakeText(this, "Recording started", ToastLength.Long).Show(); }; stopbtn.Click += delegate { try { mediaRecorder.Stop(); Timer.Text = "00:00:00"; timer.Stop(); timer = null; } catch (Exception ex) { } //stoprecorder(); //btn2.Enabled=false; //buttonPlayLastRecordAudio.setEnabled(true); //buttonStart.setEnabled(true); //buttonStopPlayingRecording.setEnabled(false); Toast.MakeText(this, "Recording completed", ToastLength.Long).Show(); }; //pausebtn.Click += delegate //{ // //OnPause(); // mediaRecorder.Pause(); // timer.Dispose(); //}; playbtn.Click += delegate { mediaPlayer = new MediaPlayer(); mediaPlayer.SetDataSource(AudioSavePathInDevice); mediaPlayer.Prepare(); mediaPlayer.Start(); //mediaPlayer = MediaPlayer.Create(this, Resource.Raw.AudioSavePathInDevice); seekBar.Max = mediaPlayer.Duration; run(); }; //resumebtn.Click += delegate // { // mediaRecorder.Resume(); // timer.Start(); // }; //savebtn.Click += delegate // { // Java.IO.File path = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures); // audiofile = new Java.IO.File(path, "TaskApp"); // if (!audiofile.Exists()) // { // audiofile.Mkdirs(); // } // audioname = Utility.fileName1(); // fileImagePath = new Java.IO.File(audiofile, string.Format(audioname, Guid.NewGuid())); // AudioSavePathInDevice = fileImagePath.AbsolutePath; // mediaRecorder.SetOutputFile(AudioSavePathInDevice); // builder.Dismiss(); // }; builder.Show(); }