コード例 #1
0
 override public Android.App.Dialog OnCreateDialog(Bundle savedInstanceState)
 {
     Android.App.ProgressDialog progressDialog = new Android.App.ProgressDialog(GetActivity());
     progressDialog.SetIndeterminate(true);
     progressDialog.SetMessage(GetString(GetArguments().GetInt(ARG_MESSAGE)));
     return(progressDialog);
 }
コード例 #2
0
ファイル: Fragment2.cs プロジェクト: Lijun-Mud/MyAndroid
        //public override void OnActivityCreated(Bundle savedInstanceState)
        //{
        //    base.OnActivityCreated(savedInstanceState);
        //    DoWork();
        //}

        private async void DoWork()
        {
            var pr = new Android.App.ProgressDialog(globalContext);

            pr.SetMessage("Loading data");
            pr.SetCancelable(false);
            pr.Show();

            var repository = new Respository();
            //var channel = await await Task.Factory.StartNew(async() =>await repository.ReadPsi());//repository.ReadPsi();
            //var channel = await await await Task.Factory.StartNew(() =>repository.ReadPsi().ContinueWith<Task<Channel>>(t=>t,TaskContinuationOptions.OnlyOnFaulted));
            await Task.Factory.StartNew(() => BigLongImportantMethodAsync());

            var channel      = _channelResult;
            var psiInfo      = PsiInformation.Parse(channel);
            var view         = globalView;
            var foundTextbox = view.FindViewById <TextView>(Resource.Id.textViewUpdateTime);

            foundTextbox.Text = psiInfo.DisplayUpdateTime;
            foundTextbox      = view.FindViewById <TextView>(Resource.Id.textView3hrPsi);
            foundTextbox.Text = psiInfo.Psi3Hour;
            foundTextbox      = view.FindViewById <TextView>(Resource.Id.textView24hrPsi);
            foundTextbox.Text = psiInfo.Psi24Hour;

            var root = view.FindViewById <LinearLayout>(Resource.Id.linearLayoutRoot);

            root.Visibility = ViewStates.Visible;

            pr.Hide();
        }
コード例 #3
0
        private void InviteDevices(object sender, EventArgs e)
        {
#pragma warning disable 0618
            var progress = new Android.App.ProgressDialog(Context);
            progress.SetCancelable(false);
            progress.SetMessage(GetString(Resource.String.sending_invites));
            progress.Show();
#pragma warning restore 0618

            Task.Run(async() => {
                try
                {
                    var inviteCode = Globals.CloudManager.SharePersonalCloud(Globals.CloudManager.PersonalClouds[0]);
                    Activity?.RunOnUiThread(() => {
                        progress.Dismiss();
                        var dialog = new AndroidX.AppCompat.App.AlertDialog.Builder(Context, Resource.Style.AlertDialogTheme)
                                     .SetIcon(Resource.Mipmap.ic_launcher_round).SetCancelable(false)
                                     .SetTitle(Resource.String.invited_title)
                                     .SetMessage(GetString(Resource.String.invited_message, inviteCode))
                                     .SetPositiveButton(Resource.String.void_invites, (o, e) => {
                            try { Globals.CloudManager.StopSharePersonalCloud(Globals.CloudManager.PersonalClouds[0]); }
                            catch { }
                        }).Show();
                    });
                }
                catch
                {
                    Activity.RunOnUiThread(() => {
                        progress.Dismiss();
                        Activity.ShowAlert(GetString(Resource.String.error_invite), GetString(Resource.String.cannot_send_invites));
                    });
                }
            });
        }
コード例 #4
0
ファイル: LoginFrag.cs プロジェクト: AshishVerma2107/Task
        //public bool permissionmethodAsync()
        //{

        //    GetPermissionAsync();
        //    return true;
        //}
        //private async Task GetPermissionAsync()
        //{
        //    List<String> permissions = new List<String>();
        //    try
        //    {

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.AccessFineLocation) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.AccessFineLocation);
        //        }
        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.RecordAudio) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.RecordAudio);
        //        }
        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.AccessCoarseLocation) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.AccessCoarseLocation);
        //        }

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.Camera) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.Camera);
        //        }

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.ReadExternalStorage) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.ReadExternalStorage);
        //        }

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.WriteExternalStorage) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.WriteExternalStorage);
        //        }

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.CallPhone) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.CallPhone);
        //        }

        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.ReadPhoneState) == Permission.Denied)
        //        {
        //            permissions.Add(Manifest.Permission.ReadPhoneState);
        //        }



        //        if (permissions.Count > 0)
        //        {
        //            ActivityCompat.RequestPermissions(Activity, permissions.ToArray(), 100);
        //        }
        //        if (ContextCompat.CheckSelfPermission(Activity, Manifest.Permission.AccessFineLocation) == Permission.Granted)
        //        {
        //            geo = new Geolocation();
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        System.Console.WriteLine("Error", e.Message);
        //    }

        //}

        public async Task GetLogin()
        {
            Boolean result = ic.connectivity();

            if (result)
            {
                progress = new Android.App.ProgressDialog(Activity);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetCancelable(false);
                progress.SetMessage("Please wait...");
                progress.Show();
                JsonValue login_value = null;
                try
                {
                    login_value = await nextActivity("", "");
                }
                catch (Exception e)
                {
                }
                if (login_value != null)
                {
                    await ParseAndDisplay(login_value, "");
                }
            }
        }
コード例 #5
0
ファイル: Frequent.cs プロジェクト: AshishVerma2107/Task
        public async Task getData()
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            dynamic value = new ExpandoObject();

            value.DesignationId = desig_Id;

            string json = JsonConvert.SerializeObject(value);

            try
            {
                JsonValue item = await restService.FrequentList(Activity, json, geolocation).ConfigureAwait(false);

                freq = JsonConvert.DeserializeObject <List <FrequentList> >(item);

                db.InsertFrequentList(freq);
                if (freq.Count > 0)
                {
                    adapter = new FrequentAdapter(Activity, freq);
                }
                gv.Adapter = adapter;
                progress.Dismiss();
            }
            catch (Exception ex)
            {
                progress.Dismiss();
            }
            progress.Dismiss();
        }
コード例 #6
0
        private void PerformUpdate()
        {
            EdiabasInit();
            Android.App.ProgressDialog progress = new Android.App.ProgressDialog(this);
            progress.SetCancelable(false);
            progress.SetMessage(GetString(Resource.String.can_adapter_fw_update_active));
            progress.Show();

            _adapterThread = new Thread(() =>
            {
                bool updateOk  = false;
                bool connectOk = false;
                try
                {
                    connectOk = !InterfacePrepare();
                    BluetoothSocket bluetoothSocket = EdBluetoothInterface.BluetoothSocket;
                    if (bluetoothSocket == null)
                    {
                        connectOk = false;
                    }
                    else
                    {
                        connectOk = true;
                        updateOk  = PicBootloader.FwUpdate(bluetoothSocket);
                    }
                }
                catch (Exception)
                {
                    updateOk = false;
                }
                RunOnUiThread(() =>
                {
                    if (IsJobRunning())
                    {
                        _adapterThread.Join();
                    }
                    progress.Hide();
                    progress.Dispose();
                    string message;
                    if (updateOk)
                    {
                        message = GetString(Resource.String.can_adapter_fw_update_ok);
                    }
                    else
                    {
                        message = connectOk
                            ? GetString(Resource.String.can_adapter_fw_update_failed)
                            : GetString(Resource.String.can_adapter_fw_update_conn_failed);
                    }
                    _activityCommon.ShowAlert(message, updateOk ? Resource.String.alert_title_info : Resource.String.alert_title_error);
                    UpdateDisplay();
                    if (updateOk)
                    {
                        PerformRead();
                    }
                });
            });
            _adapterThread.Start();
            UpdateDisplay();
        }
コード例 #7
0
 public void LoadingShow()
 {
     progress = new Android.App.ProgressDialog(Forms.Context);
     progress.Indeterminate = true;
     progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
     progress.SetMessage("Carregando, por favor aguarde...");
     progress.SetCancelable(false);
     progress.Show();
 }
コード例 #8
0
 private void ShowProgressDialog()
 {
     progress = new Android.App.ProgressDialog(this.Context);
     progress.Indeterminate = true;
     progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
     progress.SetMessage("Please wait...");
     progress.SetCancelable(false);
     progress.Show();
 }
コード例 #9
0
ファイル: VideoFragment.cs プロジェクト: AshishVerma2107/Task
            public TaskInBackground(Context context, string path)
            {
                this.context = context;
                this.path    = path;

                progress = new Android.App.ProgressDialog(context);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetCancelable(false);
                progress.SetMessage("Please wait...");
            }
コード例 #10
0
ファイル: LoginFrag.cs プロジェクト: AshishVerma2107/Task
        public async void Validate()
        {
            var errorMsg = "";

            if (user.Text.Length == 0 && pass.Text.Length == 0)
            {
                if (user.Text.Length == 0 || pass.Text.Length == 0)
                {
                    errorMsg = "Please enter User Name ";
                }
                if (pass.Text.Length == 0 || pass.Text.Length == 0)
                {
                    errorMsg = errorMsg + "Please enter Password";
                }

                Toast.MakeText(Activity, errorMsg, ToastLength.Long).Show();
                return;
            }
            else
            {
                Boolean result = ic.connectivity();
                if (result)
                {
                    progress = new Android.App.ProgressDialog(Activity);
                    progress.Indeterminate = true;
                    progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                    progress.SetCancelable(false);
                    progress.SetMessage("Please wait...");
                    progress.Show();
                    JsonValue login_value = null;
                    try
                    {
                        login_value = await nextActivity(user.Text, pass.Text);
                    }
                    catch (Exception e)
                    {
                    }
                    if (login_value != null)
                    {
                        await ParseAndDisplay(login_value, user.Text);
                    }

                    //  loginId1 = user.Text;
                    // password1 = pass.Text;
                }
                else
                {
                    Toast.MakeText(Activity, "No Internet", ToastLength.Long).Show();
                }
            }
        }
コード例 #11
0
        protected override void OnAttachedTo(Page bindable)
        {
            base.OnAttachedTo(bindable);
#if __ANDROID__
            renderObj = new Android.App.ProgressDialog(HandSchool.Droid.MainActivity.ActivityContext);
            renderObj.SetTitle(Title);
            renderObj.SetMessage(Tips);
            renderObj.Indeterminate = true;
            renderObj.Show();
#elif __IOS__
#elif __UWP__
            bindable.IsBusy = true;
#endif
        }
コード例 #12
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait..");

            ISharedPreferences pref = Android.App.Application.Context.GetSharedPreferences("AboutUsInfo", FileCreationMode.Private);

            about_us = pref.GetString("content", String.Empty);
        }
コード例 #13
0
ファイル: LoginFragment.cs プロジェクト: Lijun-Mud/MyAndroid
        private async void LoginButton_Click(object sender, EventArgs e)
        {
            _loginButton.Enabled = false;

            var pr = new Android.App.ProgressDialog(_context);

            pr.SetMessage("Login...");
            pr.SetCancelable(false);
            pr.Show();

            await Task.Factory.StartNew(() => BigLongImportantMethodAsync());

            pr.Hide();
            _loginButton.Enabled = true;
        }
コード例 #14
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");

            pref = Android.App.Application.Context.GetSharedPreferences("BookMarkInfo", FileCreationMode.Private);

            BookMarkDetails = pref.GetString("FinalBookMark", "false");

            dba = new DBHelper();
        }
コード例 #15
0
        public async Task Send_Number()
        {
            if (ic.connectivity())
            {
                progress = new Android.App.ProgressDialog(Activity);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetCancelable(false);
                progress.SetMessage("Please wait...");
                progress.Show();

                OTPModel otp_data = new OTPModel();
                otp_data.MobileNo = number;
                otp_data.SMS      = "OTP";
                string otp_json = JsonConvert.SerializeObject(otp_data);
                try
                {
                    string item = await restService.GetOtp(Activity, licenceid, geolocation, version, otp_json);

                    if (item.Contains("Authentication Failed"))
                    {
                        progress.Dismiss();
                        AlertBox();
                    }
                    else
                    {
                        var primeArray = item.Split(',');
                        otp      = primeArray[0];
                        otp      = otp.Substring(1);
                        username = primeArray[1];
                        progress.Dismiss();
                        verification();
                    }
                }
                catch (Exception e)
                {
                    progress.Dismiss();
                }
            }
            else
            {
                progress.Dismiss();
            }
        }
コード例 #16
0
        private async void BtnRegistrar_Click(object sender, EventArgs e)
        {
            progress = new Android.App.ProgressDialog(this.Context);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetMessage("Registrando...Espere...");
            progress.SetCancelable(false);
            progress.Show();

            string dni    = txtdni.Text;
            string nombre = txtnombre.Text;
            string email  = txtEmail.Text;
            string telef  = txtTele_F.Text;
            string telec  = txtTele_C.Text;

            if (!string.IsNullOrEmpty(dni) || !string.IsNullOrEmpty(nombre) || !string.IsNullOrEmpty(email) || !string.IsNullOrEmpty(telef) || !string.IsNullOrEmpty(telec))
            {
                //await
                var dato = await controller.RegistraCliente(int.Parse(dni), nombre, email, int.Parse(telef), int.Parse(telec));

                if (dato != null)
                {
                    progress.Dismiss();
                    Toast.MakeText(this.Context, "Registrado Correctamente", ToastLength.Short).Show();
                    LimpiarCasillas();
                }
                else
                {
                    progress.Dismiss();
                    Toast.MakeText(this.Context, "Error al Registrar", ToastLength.Short).Show();
                    LimpiarCasillas();
                }
            }
            else
            {
                progress.Dismiss();
                Toast.MakeText(this.Context, "Campos vacios", ToastLength.Short).Show();
            }
        }
コード例 #17
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.SetVmPolicy(builder.Build());
            StrictMode.ThreadPolicy.Builder builder1 = new StrictMode.ThreadPolicy.Builder().PermitAll();
            StrictMode.SetThreadPolicy(builder1.Build());


            base.OnCreate(savedInstanceState);

            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please Wait...");

            pref = Android.App.Application.Context.GetSharedPreferences("AboutExamInfo", FileCreationMode.Private);

            Abour_Exam = pref.GetString("FinalAboutExam", "false");

            dba = new DBHelper();
        }
コード例 #18
0
        private void DownloadFile(FileSystemEntry item, string cachePath, Action onCompletion, Action <Exception> onError)
        {
            if (File.Exists(cachePath))
            {
                Activity.ShowAlert(GetString(Resource.String.error_download_file), GetString(Resource.String.file_exists));
                return;
            }

#pragma warning disable 0618
            var progress = new Android.App.ProgressDialog(Context);
            progress.SetCancelable(false);
            progress.SetMessage(GetString(Resource.String.downloading));
            progress.Show();
#pragma warning restore 0618
            Task.Run(async() => {
                try
                {
                    var source = Path.Combine(workingPath, item.Name);
                    var target = new FileStream(cachePath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
                    await(await fileSystem.ReadFileAsync(source).ConfigureAwait(false)).CopyToAsync(target).ConfigureAwait(false);
                    await target.DisposeAsync().ConfigureAwait(false);

                    Activity.RunOnUiThread(() => {
                        progress.Dismiss();
                        onCompletion?.Invoke();
                    });
                }
                catch (Exception exception)
                {
                    try { File.Delete(cachePath); }
                    catch { }

                    Activity.RunOnUiThread(() => {
                        progress.Dismiss();
                        onError?.Invoke(exception);
                    });
                }
            });
        }
コード例 #19
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.assign, container, false);

            HasOptionsMenu = true;
            //ViewPager
            viewpager = rootView.FindViewById <ViewPager>(Resource.Id.viewpager);

            // personal =
            setupViewPager(viewpager);
            var tabLayout = rootView.FindViewById <TabLayout>(Resource.Id.tabs);

            tabLayout.SetupWithViewPager(viewpager);


            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            return(rootView);
        }
コード例 #20
0
        public async Task getorglist(string org_id)
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            dynamic value = new ExpandoObject();

            value.OrgId = org_id;

            string json = JsonConvert.SerializeObject(value);

            try
            {
                string item = await restservice.MarkingList(Activity, json, location).ConfigureAwait(false);

                markinglist = JsonConvert.DeserializeObject <List <MarkingListModel> >(item);
                db.InsertMarkingList(markinglist);

                progress.Dismiss();
            }
            catch (Exception ex)
            {
                progress.Dismiss();
            }

            if (markinglist != null)
            {
                Activity.RunOnUiThread(() =>
                {
                    marked = new MarkingListAdapter(Activity, markinglist);
                    list.SetAdapter(marked);
                });
            }
            progress.Dismiss();
        }
コード例 #21
0
        public async Task getOrgData()
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            //dynamic value = new ExpandoObject();
            //value.OrgId = orgid;

            //   string json = JsonConvert.SerializeObject(value);
            try
            {
                string item = await restservice.OrgnizationList(Activity, "", location);

                orgmodel = JsonConvert.DeserializeObject <List <OrgModel> >(item);
                for (int i = 0; i < orgmodel.Count; i++)
                {
                    OrgModel org = new OrgModel();
                    org.organizationName = orgmodel[i].organizationName;
                    orgname.Add(org);
                }
                //  db.InsertMarkingList(orgmodel);

                progress.Dismiss();
                selectorg.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Selectorg_ItemSelected);
                ArrayAdapter adapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleListItem1, orgmodel);
                selectorg.Adapter = adapter;
            }

            catch (Exception ex)
            {
                progress.Dismiss();
            }
        }
コード例 #22
0
        public async Task getData()
        {
            if (ic.connectivity())
            {
                progress = new Android.App.ProgressDialog(Activity);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetCancelable(false);
                progress.SetMessage("Please wait...");
                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);
                    taskuploaded = comp.lstUploadedCompliance;
                    db.complianceoutbox_insert(comp);
                }
                catch (Exception ex)
                {
                    progress.Dismiss();
                }
            }
            else
            {
                datacomp = db.GetCompliance_for_outbox(task_id_to_send);
                db.insertuploadedtask_for_outbox(comp.lstUploadedCompliance);
                taskuploaded = db.gettaskuploaded(task_id_to_send);
                // taskuploaded = comp.lstUploadedCompliance;

                db.insertCommunicationdetail(comp.lstCommunication, task_id_to_send);
                List <CommunicationModel> lstCommunication = db.GetCommunicationModels(task_id_to_send);
            }
            //if (datacomp.Count == 0)
            //{
            //    Toast.MakeText(Activity, "Please connect to the Internet.", ToastLength.Long).Show();
            //}
            //else
            //{


            //}
            // List<CommunicationModel> lstCommunication = comp.lstCommunication;

            if (taskuploaded != null)
            {
                for (int i = 0; i < taskuploaded.Count; i++)
                {
                    if (taskuploaded[i].file_type.Equals("Image"))
                    {
                        imagelistoutbox.Add(taskuploaded[i]);
                    }
                    else if (taskuploaded[i].file_type.Equals("Video"))
                    {
                        videolistoutbox.Add(taskuploaded[i]);
                    }
                    else if (taskuploaded[i].file_type.Equals("Audio"))
                    {
                        audiolistoutbox.Add(taskuploaded[i]);
                    }
                }

                for (int i = 0; i < taskuploaded.Count; i++)
                {
                    filetype    = taskuploaded[i].file_type;
                    filename    = taskuploaded[i].FileName;
                    file_format = taskuploaded[i].file_format;
                    path        = taskuploaded[i].Path;
                    geolocation = taskuploaded[i].GeoLocation;
                    filesize    = taskuploaded[i].FileSize;
                    if (filetype == "Image")
                    {
                        gridimagecomp     = new GridImagecomplianceoutbox(Activity, imagelistoutbox, FragmentManager);
                        imagegrid.Adapter = gridimagecomp;
                        imagegrid.setExpanded(true);
                    }
                    if (filetype == "Video")
                    {
                        gridvideocomp         = new GridVideocomplianceoutbox(Activity, videolistoutbox, FragmentManager);
                        videolistview.Adapter = gridvideocomp;
                        videolistview.setExpanded(true);
                    }
                    if (filetype == "Audio")
                    {
                        gridaudiocomp         = new GridAudiocomplianceOutbox(Activity, audiolistoutbox, FragmentManager);
                        audiolistview.Adapter = gridaudiocomp;
                        audiolistview.setExpanded(true);
                    }
                }

                //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;


                progress.Dismiss();
            }

            settingValues();

            for (int i = 0; i <= taskuploaded.Count; i++)
            {
                max_num     = comp.lstUploadedCompliance[i].max_numbers;
                file_format = comp.lstUploadedCompliance[i].file_format;
                filetype    = comp.lstUploadedCompliance[i].file_type;
                //  taskoverview = comp.lstUploadedCompliance[i].task_overview;
                //uploaded = comp.lstUploadedCompliance[i].Uploaded;

                if (filetype.Equals("Image"))
                {
                    image_max = Convert.ToInt32(max_num);
                }
                else if (filetype.Equals("Video"))
                {
                    video_max = Convert.ToInt32(max_num);
                }
                else if (filetype.Equals("Audio"))
                {
                    audio_max = Convert.ToInt32(max_num);
                }
                //Image_no.Text = image_max.ToString();
                //Video_no.Text = video_max.ToString();
                //Audio_no.Text = audio_max.ToString();
            }
        }
コード例 #23
0
        private void ExecuteTestFormat()
        {
            _textViewTestFormatOutput.Text = string.Empty;
            if ((_selectedJob == null) || (_selectedResult == null))
            {
                return;
            }

            Android.App.ProgressDialog progress = new Android.App.ProgressDialog(this);
            progress.SetCancelable(false);
            progress.SetMessage(GetString(Resource.String.xml_tool_execute_test_job));
            progress.Show();

            string resultText    = string.Empty;
            bool   executeFailed = false;
            Thread jobThread     = new Thread(() =>
            {
                try
                {
                    _ediabas.ResolveSgbdFile(_ecuInfo.Sgbd);

                    _ediabas.ArgString       = string.Empty;
                    _ediabas.ArgBinaryStd    = null;
                    _ediabas.ResultsRequests = string.Empty;
                    _ediabas.ExecuteJob(_selectedJob.Name);

                    List <Dictionary <string, EdiabasNet.ResultData> > resultSets = _ediabas.ResultSets;
                    if (resultSets != null && resultSets.Count >= 2)
                    {
                        int dictIndex = 0;
                        foreach (Dictionary <string, EdiabasNet.ResultData> resultDict in resultSets)
                        {
                            if (dictIndex == 0)
                            {
                                dictIndex++;
                                continue;
                            }
                            EdiabasNet.ResultData resultData;
                            if (resultDict.TryGetValue(_selectedResult.Name, out resultData))
                            {
                                resultText = EdiabasNet.FormatResult(resultData, _selectedResult.Format) ?? string.Empty;
                                break;
                            }
                            dictIndex++;
                        }
                    }
                }
                catch (Exception)
                {
                    executeFailed = true;
                }

                RunOnUiThread(() =>
                {
                    progress.Hide();
                    progress.Dispose();
                    _textViewTestFormatOutput.Text = resultText;

                    if (executeFailed)
                    {
                        _activityCommon.ShowAlert(GetString(Resource.String.xml_tool_read_test_job_failed), Resource.String.alert_title_error);
                    }
                });
            });

            jobThread.Start();
        }
コード例 #24
0
 override public Android.App.Dialog OnCreateDialog(Bundle savedInstanceState)
 {
    Android.App.ProgressDialog progressDialog = new Android.App.ProgressDialog(GetActivity());
    progressDialog.SetIndeterminate(true);
    progressDialog.SetMessage(GetString(GetArguments().GetInt(ARG_MESSAGE)));
    return progressDialog;
 }
コード例 #25
0
        private async System.Threading.Tasks.Task CreatetaskService()
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();

            //models = db.GetFullAttachmentData(task_id_to_send);

            for (int i = 0; i < listmapping2.Count; i++)
            {
                byte[] img  = GetStreamFromFile(listmapping2[i].localPath);
                var    url1 = await blob.UploadPhotoAsync(img, listmapping2[i].localPath.Substring(listmapping2[i].localPath.LastIndexOf("/") + 1));

                if (url1 != null)
                {
                    listmapping2[i].Path = url1;
                }
            }
            dynamic value = new ExpandoObject();

            value.task_name          = taskname;
            value.description        = taskdescri;
            value.deadline_date      = deadline;
            value.taskCreatethrough  = "mobile";
            value.markTo             = markto;
            value.lstTaskFileMapping = listmapping2;
            value.lstAddedCompliance = CreateTaskFrag.modelsaddcompliance;
            string json = JsonConvert.SerializeObject(value);

            try
            {
                string item = await restService.CreateTaskMethod(Activity, json, geolocation);

                if (item.Contains("Task Created successfully"))
                {
                    //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto, "yes");


                    //Toast.MakeText(Activity, "Task Assign Successfully..", ToastLength.Long).Show();
                    Toast.MakeText(Activity, "Task Assign Successfully...", ToastLength.Long).Show();
                    CreateTaskFrag.modelsaddcompliance.Clear();
                    progress.Dismiss();
                }
                else
                {
                    //db.InsertCreateTaskData(taskname, taskdescri, deadline, "mobile", markto,"yes",listmapping2);

                    tasknametext.Text    = null;
                    taskdescription.Text = null;

                    deadlinetext.Text = null;
                    markedontext.Text = null;

                    designationtext.Text = null;
                    nametext.Text        = null;

                    Toast.MakeText(Activity, "Task saved Successfully.. you have not internet connection", ToastLength.Long).Show();
                    progress.Dismiss();
                }
            }
            catch (Exception ex)
            {
                progress.Dismiss();
            }

            progress.Dismiss();
        }
コード例 #26
0
        public void OnItemLongClick(int position)
        {
            if (position == 0 && workingPath.Length != 1)
            {
                return;
            }

            var item  = items[workingPath.Length == 1 ? position : (position - 1)];
            var view  = layoutManager.FindViewByPosition(position);
            var popup = new PopupMenu(Context, view);

            popup.MenuInflater.Inflate(Resource.Menu.file_actions, popup.Menu);

            if (item.IsDirectory)
            {
                popup.Menu.FindItem(Resource.Id.action_download).SetVisible(false);
            }
            if (item.IsReadOnly)
            {
                popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_delete).SetVisible(false);
            }
            if (item.Attributes.HasFlag(FileAttributes.Device))
            {
                popup.Menu.FindItem(Resource.Id.action_rename).SetVisible(false);
                popup.Menu.FindItem(Resource.Id.action_move).SetVisible(false);
            }

            popup.MenuItemClick += (o, e) => {
                switch (e.Item.ItemId)
                {
                case Resource.Id.action_download:
                {
                    opSource = item;
                    this.StartActivityForResult(typeof(ChooseFolderActivity), CallbackDownload);
                    return;
                }

                case Resource.Id.action_move:
                {
                    opSource = item;
                    var intent        = new Intent(Context, typeof(ChooseDestinationActivity));
                    var deviceRoot    = workingPath.Substring(1);
                    var nextSeparator = deviceRoot.IndexOf(Path.AltDirectorySeparatorChar);
                    if (nextSeparator == -1)
                    {
                        deviceRoot = "/" + deviceRoot;
                    }
                    else
                    {
                        deviceRoot = "/" + deviceRoot.Substring(0, nextSeparator);
                    }
                    intent.PutExtra(ChooseDestinationActivity.ExtraRootPath, deviceRoot);
                    StartActivityForResult(intent, CallbackMove);
                    return;
                }

                case Resource.Id.action_rename:
                {
                    Activity.ShowEditorAlert(GetString(Resource.String.new_file_name), item.Name, item.Name, GetString(Resource.String.action_save), text => {
                            if (string.IsNullOrWhiteSpace(text))
                            {
                                Activity.ShowAlert(GetString(Resource.String.bad_file_name), null);
                                return;
                            }

                            if (text == item.Name)
                            {
                                return;
                            }

#pragma warning disable 0618
                            var progress = new Android.App.ProgressDialog(Context);
                            progress.SetCancelable(false);
                            progress.SetMessage(GetString(Resource.String.renaming));
                            progress.Show();
#pragma warning restore 0618
                            Task.Run(async() => {
                                try
                                {
                                    var path = Path.Combine(workingPath, item.Name);
                                    await fileSystem.RenameAsync(path, text).ConfigureAwait(false);

                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        RefreshDirectory(this, EventArgs.Empty);
                                    });
                                }
                                catch (HttpRequestException exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                                    });
                                }
                                catch (Exception exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_rename_file), exception.GetType().Name);
                                    });
                                }
                            });
                        }, GetString(Resource.String.action_cancel), null);
                    return;
                }

                case Resource.Id.action_delete:
                {
                    Activity.ShowAlert(GetString(Resource.String.delete_permanently),
                                       GetString(Resource.String.delete_all_contents, item.Name),
                                       GetString(Resource.String.action_cancel), null, GetString(Resource.String.action_delete), () => {
#pragma warning disable 0618
                            var progress = new Android.App.ProgressDialog(Context);
                            progress.SetCancelable(false);
                            progress.SetMessage(GetString(Resource.String.deleting));
                            progress.Show();
#pragma warning restore 0618

                            Task.Run(async() => {
                                try
                                {
                                    var path = Path.Combine(workingPath, item.Name);
                                    if (item.IsDirectory)
                                    {
                                        path += Path.AltDirectorySeparatorChar;
                                    }
                                    await fileSystem.DeleteAsync(path).ConfigureAwait(false);

                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        RefreshDirectory(this, EventArgs.Empty);
                                    });
                                }
                                catch (HttpRequestException exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                                    });
                                }
                                catch (Exception exception)
                                {
                                    Activity.RunOnUiThread(() => {
                                        progress.Dismiss();
                                        Activity.ShowAlert(GetString(Resource.String.error_delete_file), exception.GetType().Name);
                                    });
                                }
                            });
                        });
                    return;
                }
                }
            };

            if (popup.Menu.Size() != 0)
            {
                var helper = new MenuPopupHelper(Context, (MenuBuilder)popup.Menu, view);
                helper.SetForceShowIcon(true);
                helper.Show();
            }
        }
コード例 #27
0
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            switch (requestCode)
            {
            case CallbackUpload:
            {
                if ((Android.App.Result)resultCode != Android.App.Result.Ok)
                {
                    return;
                }
                var path = data.GetStringExtra(UploadFilesActivity.ResultPath);
                if (string.IsNullOrEmpty(path))
                {
                    throw new InvalidOperationException();
                }

#pragma warning disable 0618
                var progress = new Android.App.ProgressDialog(Context);
                progress.SetCancelable(false);
                progress.SetMessage(GetString(Resource.String.uploading_file));
                progress.Show();
#pragma warning restore 0618
                Task.Run(async() => {
                        var shouldDelete = false;
                        var fileName     = Path.GetFileName(path);
                        var remotePath   = Path.Combine(workingPath, fileName);
                        try
                        {
                            var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                            await fileSystem.WriteFileAsync(remotePath, stream).ConfigureAwait(false);

                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                RefreshDirectory(this, EventArgs.Empty);
                            });
                        }
                        catch (HttpRequestException exception)
                        {
                            shouldDelete = true;
                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                            });
                        }
                        catch (Exception exception)
                        {
                            shouldDelete = true;
                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                Activity.ShowAlert(GetString(Resource.String.error_upload_file), exception.GetType().Name);
                            });
                        }

                        /*
                         * if (shouldDelete)
                         * {
                         *  try { await fileSystem.DeleteAsync(remotePath).ConfigureAwait(false); }
                         *  catch { } // Ignored.
                         * }
                         */
                    });
                return;
            }

            case CallbackDownload:
            {
                if ((Android.App.Result)resultCode != Android.App.Result.Ok || opSource is null)
                {
                    return;
                }
                var path = data.GetStringExtra(ChooseFolderActivity.ResultPath);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                path = Path.Combine(path, opSource.Name);
                PreparePlaceholder(opSource, path, () => {
                        Activity.ShowAlert(GetString(Resource.String.downloaded), GetString(Resource.String.downloaded_as, opSource.Name, path));
                        opSource = null;
                    }, exception => {
                        if (exception is HttpRequestException http)
                        {
                            Activity.ShowAlert(GetString(Resource.String.error_remote), http.Message);
                        }
                        else
                        {
                            Activity.ShowAlert(GetString(Resource.String.error_download_file), exception.GetType().Name);
                        }
                        opSource = null;
                    });
                return;
            }

            case CallbackMove:
            {
                if ((Android.App.Result)resultCode != Android.App.Result.Ok || opSource is null)
                {
                    return;
                }
                var path = data.GetStringExtra(ChooseDestinationActivity.ResultPath);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

#pragma warning disable 0618
                var progress = new Android.App.ProgressDialog(Context);
                progress.SetCancelable(false);
                progress.SetMessage(GetString(Resource.String.moving_file));
                progress.Show();
#pragma warning restore 0618

                Task.Run(async() => {
                        try
                        {
                            var sourcePath = Path.Combine(workingPath, opSource.Name);
                            path           = Path.Combine(path, opSource.Name);
                            await fileSystem.RenameAsync(sourcePath, path).ConfigureAwait(false);
                            opSource = null;

                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                RefreshDirectory(this, EventArgs.Empty);
                            });
                        }
                        catch (HttpRequestException exception)
                        {
                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                            });
                        }
                        catch (Exception exception)
                        {
                            Activity.RunOnUiThread(() => {
                                progress.Dismiss();
                                Activity.ShowAlert(GetString(Resource.String.error_move_file), exception.GetType().Name);
                            });
                        }
                    });
                return;
            }

            default:
            {
                base.OnActivityResult(requestCode, resultCode, data);
                return;
            }
            }
        }
コード例 #28
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.finder_home:
            {
                workingPath = "/";
                RefreshDirectory(this, EventArgs.Empty);
                return(true);
            }

            case Resource.Id.finder_connect:
            {
                this.StartActivity(typeof(ManageConnectionsActivity));
                return(true);
            }

            case Resource.Id.action_new_folder:
            {
                Activity.ShowEditorAlert(GetString(Resource.String.new_folder_name), GetString(Resource.String.new_folder_placeholder), null, GetString(Resource.String.new_folder_create), text => {
                        if (string.IsNullOrWhiteSpace(text))
                        {
                            Activity.ShowAlert(GetString(Resource.String.bad_folder_name), null);
                            return;
                        }

#pragma warning disable 0618
                        var progress = new Android.App.ProgressDialog(Context);
                        progress.SetCancelable(false);
                        progress.SetMessage(GetString(Resource.String.creating_new_folder));
                        progress.Show();
#pragma warning restore 0618
                        Task.Run(async() => {
                            try
                            {
                                var path = Path.Combine(workingPath, text);
                                await fileSystem.CreateDirectoryAsync(path).ConfigureAwait(false);

                                Activity.RunOnUiThread(() => {
                                    progress.Dismiss();
                                    RefreshDirectory(this, EventArgs.Empty);
                                });
                            }
                            catch (HttpRequestException exception)
                            {
                                Activity.RunOnUiThread(() => {
                                    progress.Dismiss();
                                    Activity.ShowAlert(GetString(Resource.String.error_remote), exception.Message);
                                });
                            }
                            catch (Exception exception)
                            {
                                Activity.RunOnUiThread(() => {
                                    progress.Dismiss();
                                    Activity.ShowAlert(GetString(Resource.String.error_new_folder), exception.GetType().Name);
                                });
                            }
                        });
                    }, GetString(Resource.String.action_cancel), null);
                return(true);
            }

            case Resource.Id.action_upload_file:
            {
                this.StartActivityForResult(typeof(UploadFilesActivity), CallbackUpload);
                return(true);
            }

            default:
            {
                return(base.OnOptionsItemSelected(item));
            }
            }
        }
コード例 #29
0
        public async Task getData()
        {
            progress = new Android.App.ProgressDialog(Activity);
            progress.Indeterminate = true;
            progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
            progress.SetCancelable(false);
            progress.SetMessage("Please wait...");
            progress.Show();
            dynamic value = new ExpandoObject();

            value.UserId = userid;

            string json = JsonConvert.SerializeObject(value);

            try
            {
                JsonValue item = await restService.TaskOutbox(Activity, json, geolocation);

                List <TaskOutboxModel> taskOutbox = JsonConvert.DeserializeObject <List <TaskOutboxModel> >(item);
                dbHelper.insertdataoutbox(taskOutbox);

                for (int i = 0; i < taskOutbox.Count; i++)
                {
                    TaskOutboxModel detail = new TaskOutboxModel
                    {
                        TaskPercentage     = taskOutbox[i].TaskPercentage,
                        Task_id            = taskOutbox[i].Task_id,
                        Task_name          = taskOutbox[i].Task_name,
                        Description        = taskOutbox[i].Description,
                        deadline_date      = taskOutbox[i].deadline_date,
                        mark_to            = taskOutbox[i].mark_to,
                        task_status        = taskOutbox[i].task_status,
                        Task_created_by    = taskOutbox[i].Task_created_by,
                        Task_creation_date = taskOutbox[i].Task_creation_date,
                        task_mark_by       = taskOutbox[i].task_mark_by,
                        MarkingDate        = taskOutbox[i].MarkingDate,
                        task_marking_type  = taskOutbox[i].task_marking_type
                    };


                    im_model.Add(detail);
                }
                if (im_model.Count != 0)
                {
                    recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false);
                    recyclerview.SetLayoutManager(recyclerview_layoutmanger);
                    recyclerview_adapter = new TaskOutboxAdapter(Activity, im_model, recyclerview, FragmentManager);
                    recyclerview.SetAdapter(recyclerview_adapter);
                }
                else
                {
                    TextView textView = new TextView(Activity);

                    textView.Text = "Oops ! You haven't assigned any task yet";
                    LinearLayout.AddView(textView);
                }

                progress.Dismiss();
            }
            catch (Exception ex)
            {
                progress.Dismiss();
            }
            progress.Dismiss();
        }
コード例 #30
0
ファイル: TaskInboxFrag.cs プロジェクト: AshishVerma2107/Task
        public async Task getData()
        {
            Boolean connectivity = con.connectivity();

            if (connectivity)
            {
                progress = new Android.App.ProgressDialog(Activity);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetCancelable(false);
                progress.SetMessage("Please wait...");
                progress.Show();
                dynamic value = new ExpandoObject();
                value.UserId = u_id;

                string json = JsonConvert.SerializeObject(value);
                try
                {
                    JsonValue item = await restService.TaskInbox(Activity, json, geolocation);

                    freq = JsonConvert.DeserializeObject <List <TaskInboxModel> >(item);
                    dbHelper.insertdatainbox(freq);
                    progress.Dismiss();

                    //if (freq.Count != 0)
                    //{
                    //    recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false);
                    //    recyclerview.SetLayoutManager(recyclerview_layoutmanger);
                    //    recyclerview_adapter = new TaskInboxAdapter(Activity, freq, recyclerview, FragmentManager);
                    //    recyclerview.SetAdapter(recyclerview_adapter);
                    //}

                    //else
                    //{
                    //    LayoutParams lparams = new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
                    //    TextView textView = new TextView(Activity);
                    //    textView.LayoutParameters = lparams;
                    //    lparams.Gravity = GravityFlags.Center;
                    //    textView.Text = "Oops ! You haven't assigned any task yet";
                    //    linearLayout.AddView(textView);
                    //}
                    //progress.Dismiss();
                }
                catch (Exception ex)
                {
                    progress.Dismiss();
                }
            }
            taskdata = dbHelper.GetTaskInbox();
            if (taskdata.Count != 0)
            {
                recyclerview_layoutmanger = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false);
                recyclerview.SetLayoutManager(recyclerview_layoutmanger);
                recyclerview_adapter = new TaskInboxAdapter(Activity, taskdata, recyclerview, FragmentManager);
                recyclerview.SetAdapter(recyclerview_adapter);
            }

            else
            {
                LayoutParams lparams  = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
                TextView     textView = new TextView(Activity);
                textView.LayoutParameters = lparams;
                textView.Text             = "Oops ! You haven't assigned any task yet";
                linearLayout.AddView(textView);
            }
        }
コード例 #31
0
        /// <summary>
        /// Start adapter detection
        /// </summary>
        /// <param name="deviceAddress">Device Bluetooth address</param>
        /// <param name="deviceName">Device Bleutooth name</param>
        private void DetectAdapter(string deviceAddress, string deviceName)
        {
            Android.App.ProgressDialog progress = new Android.App.ProgressDialog(this);
            progress.SetCancelable(false);
            progress.SetMessage(GetString(Resource.String.detect_adapter));
            progress.Show();

            _sbLog.Clear();

            Thread detectThread = new Thread(() =>
            {
                AdapterType adapterType = AdapterType.Unknown;
                try
                {
                    BluetoothDevice device = _btAdapter.GetRemoteDevice(deviceAddress);
                    if (device != null)
                    {
                        BluetoothSocket bluetoothSocket = null;

                        adapterType = AdapterType.ConnectionFailed;
                        if (adapterType == AdapterType.ConnectionFailed)
                        {
                            try
                            {
                                bluetoothSocket = device.CreateRfcommSocketToServiceRecord(SppUuid);
                                if (bluetoothSocket != null)
                                {
                                    try
                                    {
                                        bluetoothSocket.Connect();
                                    }
                                    catch (Exception)
                                    {
                                        // sometimes the second connect is working
                                        bluetoothSocket.Connect();
                                    }
                                    adapterType = AdapterTypeDetection(bluetoothSocket);
                                }
                            }
                            catch (Exception)
                            {
                                adapterType = AdapterType.ConnectionFailed;
                            }
                            finally
                            {
                                bluetoothSocket?.Close();
                            }
                        }

                        if (adapterType == AdapterType.ConnectionFailed)
                        {
                            try
                            {
                                // this socket sometimes looses data for long telegrams
                                IntPtr createRfcommSocket = Android.Runtime.JNIEnv.GetMethodID(device.Class.Handle,
                                                                                               "createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;");
                                if (createRfcommSocket == IntPtr.Zero)
                                {
                                    throw new Exception("No createRfcommSocket");
                                }
                                IntPtr rfCommSocket = Android.Runtime.JNIEnv.CallObjectMethod(device.Handle,
                                                                                              createRfcommSocket, new Android.Runtime.JValue(1));
                                if (rfCommSocket == IntPtr.Zero)
                                {
                                    throw new Exception("No rfCommSocket");
                                }
                                bluetoothSocket = GetObject <BluetoothSocket>(rfCommSocket, Android.Runtime.JniHandleOwnership.TransferLocalRef);
                                if (bluetoothSocket != null)
                                {
                                    bluetoothSocket.Connect();
                                    adapterType = AdapterTypeDetection(bluetoothSocket);
                                }
                            }
                            catch (Exception)
                            {
                                adapterType = AdapterType.ConnectionFailed;
                            }
                            finally
                            {
                                bluetoothSocket?.Close();
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    adapterType = AdapterType.ConnectionFailed;
                }

                RunOnUiThread(() =>
                {
                    progress.Hide();
                    progress.Dispose();
                    switch (adapterType)
                    {
                    case AdapterType.ConnectionFailed:
                        _altertInfoDialog = new AlertDialog.Builder(this)
                                            .SetPositiveButton(Resource.String.button_yes, (sender, args) =>
                        {
                            ReturnDeviceType(deviceAddress, deviceName);
                        })
                                            .SetNegativeButton(Resource.String.button_no, (sender, args) =>
                        {
                        })
                                            .SetCancelable(true)
                                            .SetMessage(Resource.String.adapter_connection_failed)
                                            .SetTitle(Resource.String.alert_title_error)
                                            .Show();
                        _altertInfoDialog.DismissEvent += (sender, args) =>
                        {
                            _altertInfoDialog = null;
                        };
                        break;

                    case AdapterType.Unknown:
                        {
                            bool yesSelected  = false;
                            _altertInfoDialog = new AlertDialog.Builder(this)
                                                .SetPositiveButton(Resource.String.button_yes, (sender, args) =>
                            {
                                yesSelected = true;
                            })
                                                .SetNegativeButton(Resource.String.button_no, (sender, args) =>
                            {
                            })
                                                .SetCancelable(true)
                                                .SetMessage(Resource.String.unknown_adapter_type)
                                                .SetTitle(Resource.String.alert_title_error)
                                                .Show();
                            _altertInfoDialog.DismissEvent += (sender, args) =>
                            {
                                _altertInfoDialog = null;
                                _activityCommon.RequestSendMessage(_appDataDir, _sbLog.ToString(),
                                                                   PackageManager.GetPackageInfo(PackageName, 0), GetType(), (o, eventArgs) =>
                                {
                                    if (yesSelected)
                                    {
                                        ReturnDeviceType(deviceAddress, deviceName);
                                    }
                                });
                            };
                            break;
                        }

                    case AdapterType.Elm327:
                        {
                            _altertInfoDialog = new AlertDialog.Builder(this)
                                                .SetNeutralButton(Resource.String.button_ok, (sender, args) =>
                            {
                                ReturnDeviceType(deviceAddress + ";" + EdBluetoothInterface.Elm327Tag, deviceName);
                            })
                                                .SetCancelable(true)
                                                .SetMessage(Resource.String.adapter_elm_replacement)
                                                .SetTitle(Resource.String.alert_title_info)
                                                .Show();
                            _altertInfoDialog.DismissEvent += (sender, args) =>
                            {
                                _altertInfoDialog = null;
                            };
                            TextView messageView = _altertInfoDialog.FindViewById <TextView>(Android.Resource.Id.Message);
                            if (messageView != null)
                            {
                                messageView.MovementMethod = new LinkMovementMethod();
                            }
                            break;
                        }

                    case AdapterType.Elm327Invalid:
                    case AdapterType.Elm327Fake21:
                        {
                            string message =
                                GetString(adapterType == AdapterType.Elm327Fake21
                                    ? Resource.String.fake_elm_adapter_type
                                    : Resource.String.invalid_adapter_type);
                            message          += "<br>" + GetString(Resource.String.recommened_adapter_type);
                            _altertInfoDialog = new AlertDialog.Builder(this)
                                                .SetNeutralButton(Resource.String.button_ok, (sender, args) =>
                            {
                            })
                                                .SetCancelable(true)
                                                .SetMessage(Html.FromHtml(message))
                                                .SetTitle(Resource.String.alert_title_error)
                                                .Show();
                            _altertInfoDialog.DismissEvent += (sender, args) =>
                            {
                                _altertInfoDialog = null;
                                _activityCommon.RequestSendMessage(_appDataDir, _sbLog.ToString(), PackageManager.GetPackageInfo(PackageName, 0), GetType());
                            };
                            TextView messageView = _altertInfoDialog.FindViewById <TextView>(Android.Resource.Id.Message);
                            if (messageView != null)
                            {
                                messageView.MovementMethod = new LinkMovementMethod();
                            }
                            break;
                        }

                    case AdapterType.Custom:
                    case AdapterType.CustomUpdate:
                        _altertInfoDialog = new AlertDialog.Builder(this)
                                            .SetPositiveButton(Resource.String.button_yes, (sender, args) =>
                        {
                            ReturnDeviceType(deviceAddress, deviceName, true);
                        })
                                            .SetNegativeButton(Resource.String.button_no, (sender, args) =>
                        {
                            ReturnDeviceType(deviceAddress, deviceName);
                        })
                                            .SetCancelable(true)
                                            .SetMessage(adapterType == AdapterType.CustomUpdate ? Resource.String.adapter_fw_update : Resource.String.adapter_cfg_required)
                                            .SetTitle(Resource.String.alert_title_info)
                                            .Show();
                        _altertInfoDialog.DismissEvent += (sender, args) =>
                        {
                            _altertInfoDialog = null;
                        };
                        break;

                    default:
                        {
                            ReturnDeviceType(deviceAddress, deviceName);
                            break;
                        }
                    }
                });
            })
            {
                Priority = System.Threading.ThreadPriority.Highest
            };

            detectThread.Start();
        }