void TestDetaylariniGetir(int Position, string TestID, TextView AyName, TextView GunText, TextView BaslikText, TextView AciklamaText, TextView KonuText, TextView SoruSayisiText)
 {
     new System.Threading.Thread(new System.Threading.ThreadStart(delegate
     {
         WebService webService = new WebService();
         var Donus             = webService.OkuGetir("user-tests/" + TestID, UsePoll: true);
         if (Donus != null)
         {
             var Icerik = Newtonsoft.Json.JsonConvert.DeserializeObject <OLUSTURULAN_TESTLER>(Donus.ToString());
             if (Icerik != null)
             {
                 mData[Position].Aciklama = Icerik.description;
                 mData[Position].Baslik   = Icerik.name;
                 mData[Position].Tarih    = Convert.ToDateTime(Icerik.startDate);
                 mData[Position].TestKonuVeyaSinavAlani = Icerik.lessonName + " - " + Icerik.topicName;
                 mData[Position].TestSoruSayisi         = Icerik.questionCount.ToString() + " Soru";
                 mData[Position].UIUygulandimi          = true;
                 BaseActivity.RunOnUiThread(delegate() {
                     AyName.Text         = Convert.ToDateTime(Icerik.startDate).ToString("MMMM");
                     GunText.Text        = Convert.ToDateTime(Icerik.startDate).Day.ToString();
                     BaslikText.Text     = mData[Position].Baslik;
                     AciklamaText.Text   = mData[Position].Aciklama;
                     KonuText.Text       = mData[Position].TestKonuVeyaSinavAlani;
                     SoruSayisiText.Text = mData[Position].TestSoruSayisi;
                 });
             }
         }
     })).Start();
 }
示例#2
0
        void GetLocationOtherInfo(HaritaListeDataModel gelendto, int locid, List <string> catid, string townid, TextView LokasyonTuru, TextView UzaklikveSemt)
        {
            new System.Threading.Thread(new System.Threading.ThreadStart(delegate
            {
                WebService webService = new WebService();

                #region Uzaklik Ve Sempt
                if (!string.IsNullOrEmpty(townid))
                {
                    var Donus1 = webService.OkuGetir("towns/" + townid.ToString());
                    if (Donus1 != null)
                    {
                        JSONObject js = new JSONObject(Donus1.ToString());
                        var TownName  = js.GetString("townName");
                        BaseActivity.RunOnUiThread(() => {
                            var km = new DistanceCalculator().GetUserCityCountryAndDistance(StartLocationCall.UserLastLocation.Latitude,
                                                                                            StartLocationCall.UserLastLocation.Longitude,
                                                                                            gelendto.coordinateX,
                                                                                            gelendto.coordinateY);
                            UzaklikveSemt.Text = TownName + " / " + km + " km";
                        });
                    }
                    else
                    {
                        BaseActivity.RunOnUiThread(() => {
                            UzaklikveSemt.Text = "";
                        });
                    }
                }
                #endregion

                #region LokasyonTuru
                if (catid != null)
                {
                    if (catid.Count > 0)
                    {
                        if (!string.IsNullOrEmpty(catid[0]))
                        {
                            var Donus2 = webService.OkuGetir("categories/ " + catid[0].ToString());
                            if (Donus2 != null)
                            {
                                JSONObject js   = new JSONObject(Donus2.ToString());
                                var KategoriAdi = js.GetString("name");
                                BaseActivity.RunOnUiThread(() => {
                                    LokasyonTuru.Text = KategoriAdi;
                                });
                            }
                            else
                            {
                                BaseActivity.RunOnUiThread(() => {
                                    LokasyonTuru.Text = "";
                                });
                            }
                        }
                    }
                }
                #endregion
            })).Start();
        }
示例#3
0
 public void Start()
 {
     _remainingTime = Duration;
     _timer.Start();
     _activity.RunOnUiThread(() =>
                             _displayTextView.Text = $"{_remainingTime.Value.Minutes:D2}:{_remainingTime.Value.Seconds:D2}"
                             );
 }
示例#4
0
 public void OnWeatherLoaded(LocationData location, Weather weather)
 {
     AppCompatActivity?.RunOnUiThread(() =>
     {
         if (weather?.IsValid() == true)
         {
             if (Settings.FollowGPS && location.locationType == LocationType.GPS)
             {
                 gpsPanelViewModel.SetWeather(weather);
                 gpsPanel.SetWeatherBackground(gpsPanelViewModel);
                 gpsPanel.SetWeather(gpsPanelViewModel);
             }
             else
             {
                 // Update panel weather
                 var panel = mAdapter.Dataset.First(panelVM => panelVM.LocationData.query.Equals(location.query));
                 // Just in case
                 if (panel == null)
                 {
                     panel = mAdapter.Dataset.First(panelVM => panelVM.LocationData.name.Equals(location.name) &&
                                                    panelVM.LocationData.latitude.Equals(location.latitude) &&
                                                    panelVM.LocationData.longitude.Equals(location.longitude) &&
                                                    panelVM.LocationData.tz_long.Equals(location.tz_long));
                 }
                 panel.SetWeather(weather);
                 mAdapter.NotifyItemChanged(mAdapter.Dataset.IndexOf(panel));
             }
         }
     });
 }
示例#5
0
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.RunOnUiThread(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);

                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            snackBar.Dismiss();
                        }
                        catch
                        {
                            // catch and swallow
                        }
                    });
                }
            }));
        }
示例#6
0
        protected virtual IDisposable ShowDialog <TFragment, TConfig>(AppCompatActivity activity, TConfig config) where TFragment : AbstractAppCompatDialogFragment <TConfig> where TConfig : class, new()
        {
            var frag = (TFragment)Activator.CreateInstance(typeof(TFragment));

            activity.RunOnUiThread(() =>
            {
                frag.Config = config;
                frag.Show(activity.SupportFragmentManager, FragmentTag);
            });
            return(new DisposableAction(() =>
                                        activity.RunOnUiThread(frag.Dismiss)
                                        ));
        }
示例#7
0
        public void OnAppOpenAttribution(IDictionary <string, string> p0)
        {
            string message = "OnAppOpenAttribution:\n";

            foreach (var kvp in p0)
            {
                message = message + kvp.Key.ToString() + " = " + kvp.Value.ToString() + "\n";
            }
            Console.WriteLine(message);
            activity.RunOnUiThread(() =>
            {
                oaoaTextView.Text = message;
            });
        }
 public void GoBack()
 {
     pageStack.Pop();
     mainActivity.RunOnUiThread(() =>
     {
         try
         {
             fragmentManager.PopBackStack();
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine($"failed to backstack {ex.Message}");
         }
     });
 }
示例#9
0
        public void AddMessage(AlertType at, string sMessage, params object[] rgo)
        {
            if (!m_fInit)
            {
                return;
            }

            if (at != AlertType.None && m_ia != null)
            {
                m_ia.DoAlert(at);
            }

            string s2;

            string s = String.Format(sMessage, rgo);

            m_act.RunOnUiThread(() =>
            {
                s2 = m_tv.Text;

                s = s + "\n" + s2;

                m_tv.Text = s;
            });
        }
示例#10
0
        void fillFabList()
        {
            Task.Run(async() => {
                SpnTest.Enabled = false;
                string url      = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/GetFabricatorsList?iStationId=" + _spl.iStationId;
                lstFabUsers     = await npcc_services.inf_CallWebServiceAsync <List <inf_userinfo>, string>(inf_method.Get, url);
            }).ContinueWith(fn => {
                if (lstFabUsers != null)
                {
                    act.RunOnUiThread(() => {
                        var items = new List <SpinnerItem>();
                        foreach (inf_userinfo fabUser in lstFabUsers)
                        {
                            items.Add(new SpinnerItem {
                                Name = fabUser.cFullName, Item = fabUser
                            });
                        }

                        SpnTest.SpinnerTitle = "Select user from the list";
                        SpnTest.SetItems(items, -1, null);
                        SpnTest.Enabled = true;
                    });
                }
            });
        }
示例#11
0
        private Task <Snackbar> CreateSnackbar(AppCompatActivity activity, string msg, bool autoHide = false)
        {
            var tcs = new TaskCompletionSource <Snackbar>();

            activity.RunOnUiThread(() =>
            {
                var view = (activity as ICommonActivity)?.View ?? activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);

                try
                {
                    var snackBar = Snackbar.Make(
                        view,
                        msg,
                        autoHide ? Snackbar.LengthShort : Snackbar.LengthLong
                        );

                    tcs.TrySetResult(snackBar);
                }
                catch
                {
                    tcs.TrySetResult(null);
                }
            });

            return(tcs.Task);
        }
示例#12
0
        void GetLocationOtherInfo(int catid, int townid, TextView LokasyonTuru, TextView UzaklikveSemt)
        {
            new System.Threading.Thread(new System.Threading.ThreadStart(delegate
            {
                WebService webService = new WebService();

                #region Uzaklik Ve Sempt
                var Donus1 = webService.OkuGetir("towns/" + townid.ToString());
                if (Donus1 != null)
                {
                    JSONObject js = new JSONObject(Donus1);
                    var TownName  = js.GetString("townName");
                    BaseActivity.RunOnUiThread(() => {
                        UzaklikveSemt.Text = TownName;
                    });
                }
                else
                {
                    BaseActivity.RunOnUiThread(() => {
                        UzaklikveSemt.Text = "";
                    });
                }
                #endregion

                #region LokasyonTuru
                var Donus2 = webService.OkuGetir("categories/ " + catid.ToString());
                if (Donus2 != null)
                {
                    JSONObject js   = new JSONObject(Donus2);
                    var KategoriAdi = js.GetString("name");
                    BaseActivity.RunOnUiThread(() => {
                        LokasyonTuru.Text = KategoriAdi;
                    });
                }
                else
                {
                    BaseActivity.RunOnUiThread(() => {
                        LokasyonTuru.Text = "";
                    });
                }
                #endregion
            })).Start();
        }
        public static async void npcc_setScaleImageView(AppCompatActivity act, View view, string url, ScaleImageView imageView)
        {
            try
            {
                var image = await ImageService.Instance
                            .LoadUrl(url)
                            .AsBitmapDrawableAsync();

                act.RunOnUiThread(() => {
                    imageView.SetImageBitmap(image.Bitmap);
                });
            }
            catch (Exception ex)
            {
                act.RunOnUiThread(() => {
                    imageView.SetImageResource(Resource.Drawable.notfound);
                });
            }
        }
        private async Task Initialize()
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                AppCompatActivity?.RunOnUiThread(() =>
                {
                    AppCompatActivity?.Window.SetStatusBarColor(
                        new Color(ContextCompat.GetColor(AppCompatActivity, Resource.Color.colorPrimaryDark)));
                });
            }

            if (weatherView == null)
            {
                if (location == null)
                {
                    location = Settings.HomeData;
                }

                var weather = await Settings.GetWeatherData(location.query);

                if (weather != null)
                {
                    weather.weather_alerts = await Settings.GetWeatherAlertData(location.query);
                }

                weatherView = new WeatherNowViewModel(weather);
            }

            if (weatherView != null)
            {
                AppCompatActivity?.RunOnUiThread(() =>
                {
                    locationHeader.Text = weatherView.Location;
                    // use this setting to improve performance if you know that changes
                    // in content do not change the layout size of the RecyclerView
                    recyclerView.HasFixedSize = true;
                    // use a linear layout manager
                    recyclerView.SetLayoutManager(new LinearLayoutManager(AppCompatActivity));
                    // specify an adapter (see also next example)
                    recyclerView.SetAdapter(new WeatherAlertPanelAdapter(weatherView.Extras?.Alerts?.ToList()));
                });
            }
        }
        protected virtual void ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            var view     = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
            var snackBar = Snackbar.Make(view, cfg.Description, (int)cfg.Duration.TotalMilliseconds);

            snackBar.View.SetBackgroundColor(cfg.BackgroundColor.ToNative());
            snackBar.View.Click += (sender, args) =>
            {
                snackBar.Dismiss();
                cfg.Action?.Invoke();
            };
            this.SetSnackbarTextView(snackBar, cfg);
            activity.RunOnUiThread(snackBar.Show);
        }
示例#16
0
 public static void HideEmplyList_abstract(AppCompatActivity activity, IBaseListView baseListView)
 {
     activity.RunOnUiThread(() => {
         baseListView.ListView.Visibility = ViewStates.Visible;
         if (baseListView.EmptyListFragmentView != null)
         {
             activity.SupportFragmentManager
             .BeginTransaction()
             .Remove(baseListView.EmptyListFragmentView)
             .Commit();
             baseListView.EmptyListFragmentView = null;
         }
     });
 }
 void GetBeforeAfterImages(BifacialView GelenView, OrnekCalismaDTO Itemm)
 {
     new System.Threading.Thread(new System.Threading.ThreadStart(delegate
     {
         var BeforeIMG = GetImageBitmapFromUrl(Itemm.beforeImagePath);
         var AfterIMG  = GetImageBitmapFromUrl(Itemm.afterImagePath);
         Drawable BeforeIMGDrawable = new BitmapDrawable(BaseActivity.Resources, BeforeIMG);
         Drawable AfterIMGDrawable  = new BitmapDrawable(BaseActivity.Resources, AfterIMG);
         BaseActivity.RunOnUiThread(delegate() {
             GelenView.SetDrawableLeft(BeforeIMGDrawable);
             GelenView.SetDrawableRight(AfterIMGDrawable);
         });
     })).Start();
 }
示例#18
0
 public static void ShowEmplyList_abstract(AppCompatActivity activity, IBaseListView baseListView)
 {
     activity.RunOnUiThread(() => {
         baseListView.ListView.Visibility = ViewStates.Gone;
         if (baseListView.EmptyListFragmentView == null)
         {
             baseListView.EmptyListFragmentView = new EmptyListFragmentView();
             activity.SupportFragmentManager
             .BeginTransaction()
             .Add(baseListView.ListViewContainer.Id, baseListView.EmptyListFragmentView)
             .Commit();
         }
     });
 }
        void refresh_listAsync()
        {
            Console.WriteLine("#####Start######");
            DBRepository dBRepository = new DBRepository();

            Task.Run(async() => {
                await dBRepository.RefreshSpoolAsync(_assignment_Type);
            }).ContinueWith(fn => {
                act.RunOnUiThread(() => {
                    lstObjs = dBRepository.GetSpools(_assignment_Type);
                    adapter = new SpoolsCardViewAdapter(act, this, lstObjs, _assignment_Type);
                    rv.SetAdapter(adapter);
                    _swipeRefresh.Refreshing = false;
                });
            });
        }
 internal static void AlertDialogShow(AppCompatActivity context, string title, string message, bool isCloseCurrentActivity)
 {
     context.RunOnUiThread(() =>
     {
         var alertDialog = new Android.App.AlertDialog.Builder(context);
         alertDialog.SetTitle(title)
         .SetMessage(message)
         .SetPositiveButton("OK", (senderAlert, args) =>
         {
             if (isCloseCurrentActivity)
             {
                 context.Finish();
             }
         })
         .Create();
         alertDialog.Show();
     });
 }
示例#21
0
        public void NavigateTo(Page page, object parameter1, object parameter2)
        {
            mainActivity.RunOnUiThread(() => {
                if (page == CurrentPage && parameter1 == null && parameter2 == null)
                {
                    return;
                }
                BeforeNavigateEvent?.Invoke(this, page);
                if (mainActivity == null)
                {
                    throw new InvalidOperationException("No MainActivity found");
                }

                lock (pagesByKey) {
                    if (!pagesByKey.ContainsKey(page))
                    {
                        throw new ArgumentException($"No such page: {page.ToString ()}. Did you forget to call NavigationService.Configure?");
                    }

                    var fragment = CreateFragment(page, parameter1, parameter2);

                    var transaction = fragmentManager
                                      .BeginTransaction()
                                      //.SetCustomAnimations (Resource.Animation.anim_slide_in_right, Resource.Animation.anim_slide_out_right)
                                      .Replace(container, fragment, page.ToString());

                    if (!pagesByKey[page].IsRoot)
                    {
                        transaction.AddToBackStack(page.ToString());
                    }
                    else if (pageStack.Count > 0)
                    {
                        pageStack.Clear();
                        fragmentManager.PopBackStackImmediate(null, FragmentManager.PopBackStackInclusive);
                    }

                    transaction.CommitAllowingStateLoss();
                    pageStack.Push(page);
                }
            });
        }
        public void OnWeatherLoaded(LocationData location, Weather weather)
        {
            AppCompatActivity?.RunOnUiThread(() =>
            {
                if (weather?.IsValid() == true)
                {
                    wm.UpdateWeather(weather);
                    weatherView.UpdateView(weather);
                    SetView(weatherView);

                    if (Settings.HomeData.Equals(location))
                    {
                        // Update widgets if they haven't been already
                        if (TimeSpan.FromTicks(DateTime.Now.Ticks - Settings.UpdateTime.Ticks).TotalMinutes > Settings.RefreshInterval)
                        {
                            WeatherWidgetService.EnqueueWork(App.Context, new Intent(App.Context, typeof(WeatherWidgetService))
                                                             .SetAction(WeatherWidgetService.ACTION_UPDATEWEATHER));
                        }

                        // Update ongoing notification if its not showing
                        if (Settings.OnGoingNotification && !Notifications.WeatherNotificationBuilder.IsShowing)
                        {
                            WeatherWidgetService.EnqueueWork(App.Context, new Intent(App.Context, typeof(WeatherWidgetService))
                                                             .SetAction(WeatherWidgetService.ACTION_REFRESHNOTIFICATION));
                        }
                    }

                    if (wm.SupportsAlerts && Settings.ShowAlerts &&
                        weather.weather_alerts != null && weather.weather_alerts.Count > 0)
                    {
                        // Alerts are posted to the user here. Set them as notified.
                        Task.Run(async() => await WeatherAlertHandler.SetasNotified(location, weather.weather_alerts));
                    }
                }

                refreshLayout.Refreshing = false;
            });
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            _container = container;
            bundle     = savedInstanceState;

            HasOptionsMenu = true;

            notifs = NotifsManager.GetSavedNotifications(micId);

            var view = inflater.Inflate(Resource.Layout.fragment_notifs, null);

            gridView = view.FindViewById <GridView>(Resource.Id.notif_grid);

            //notif_layout
            var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);

            string layoutStyle = prefs.GetString("notif_layout", "0");

            if (layoutStyle == "0" || layoutStyle == "2")
            {
                gridView.NumColumns = 1;
            }
            else if (layoutStyle == "1" || layoutStyle == "3")
            {
                gridView.NumColumns = 2;
            }


            //gridView.FastScrollEnabled = prefs.GetBoolean("notif_scrollbar_show", true);


            adapter          = new NotifAdapter(Activity, notifs);
            gridView.Adapter = adapter;

            gridView.ItemClick += GridOnItemClick;

            if (micId != "All")
            {
                if (!updatingNotifs)
                {
                    updatingNotifs = true;
                    RequestUpdateNotifs();
                }
            }

            mRegistrationBroadcastReceiver          = new Shared.BroadcastReceiver();
            mRegistrationBroadcastReceiver.Receive += (sender, e) =>
            {
                if (micId != "All")
                {
                    RequestUpdateNotifs();
                }
                else
                {
                    adapter.UpdateNotifs(NotifsManager.GetSavedNotifications(micId));

                    home.RunOnUiThread(() =>
                    {
                        adapter.NotifyDataSetChanged();
                    });

                    int index = gridView.FirstVisiblePosition;
                    gridView.SmoothScrollToPosition(index);
                    gridView.SmoothScrollBy(1, 1000);
                }
            };

            return(view);
        }
示例#24
0
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.RunOnUiThread(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);

                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Position == ToastPosition.Top)
                {
                    // watch for this to change in future support lib versions
                    var layoutParams = snackBar.View.LayoutParameters as FrameLayout.LayoutParams;
                    if (layoutParams != null)
                    {
                        layoutParams.Gravity = GravityFlags.Top;
                        layoutParams.SetMargins(0, 80, 0, 0);
                        snackBar.View.LayoutParameters = layoutParams;
                    }
                }
                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            snackBar.Dismiss();
                        }
                        catch
                        {
                            // catch and swallow
                        }
                    });
                }
            }));
        }
        void BtnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var lstFJ = _splJoint.Where((arg) => arg.cWPSCode != null).ToList();

                if (lstFJ.Any())
                {
                    int WldrFilled = lstFJ.Where(c => c.cRHWelders == null && c.cFCWelders == null).Count();
                    if (WldrFilled == 0)
                    {
                        if (txtWeldLogNo.Text.Trim() != "")
                        {
                            decimal iWeldLogNo = Convert.ToDecimal(txtWeldLogNo.Text.Trim());
                            Task.Run(async() => {
                                string url = "https://webapps.npcc.ae/ApplicationWebServices/api/paperless/FillWeldLog";
                                List <inf_SpoolJoints> lsFinal = lstFJ.Select(c => new inf_SpoolJoints {
                                    cProjType = c.cProjType, iProjYear = c.iProjYear, iProjNo = c.iProjNo, cProjSuffix = c.cProjSuffix, iDrwgSrl = c.iDrwgSrl, iSubDrwgSrl = c.iSubDrwgSrl, iJointNo = c.iJointNo, iJointSerial = c.iJointSerial, cJointSuffix = c.cJointSuffix, cCreatedFor = c.cCreatedFor, cJointType = c.cJointType, cClass = c.cClass, rDia = c.rDia, rLength = c.rLength, rJointThk = c.rJointThk, cWPSCode = c.cWPSCode, iWeldLogNo = iWeldLogNo, dWeld = c.dWeld, cRHWelders = c.cRHWelders, cFCWelders = c.cFCWelders, cJointAreaCode = c.cJointAreaCode, cMatType = c.cMatType
                                }).ToList();
                                Console.WriteLine(JsonConvert.SerializeObject(lsFinal));
                                status = await npcc_services.inf_CallWebServiceAsync <inf_ReturnStatus, List <inf_SpoolJoints> >(inf_method.Post, url, lsFinal);
                            }).ContinueWith(fn => {
                                act.RunOnUiThread(() => {
                                    if (status != null && status.status)
                                    {
                                        DBRepository dBRepository = new DBRepository();
                                        dBRepository.DeleteSpoolJoints(lstFJ);

                                        _jointsView._lsObjs.RemoveAll(c => lstFJ.Contains(c));
                                        _jointsView.NotifyDataSetChanged();

                                        if (_exportFragment != null)
                                        {
                                            _exportFragment.Dismiss();
                                        }
                                        common_functions.DisplayToast("Weld log filled successfully!!", Context);
                                    }
                                    else
                                    {
                                        if (_exportFragment != null)
                                        {
                                            _exportFragment.Dismiss();
                                        }
                                        string msg;
                                        if (status == null)
                                        {
                                            msg = "API request error, Please contact the administrator!!";
                                        }
                                        else
                                        {
                                            msg = status.msg;
                                        }

                                        common_functions.DisplayToast(msg, Context);
                                    }
                                });
                            });
                        }
                        else
                        {
                            common_functions.DisplayToast("Please fill the weld log number!!", Context);
                        }
                    }
                    else
                    {
                        if (_exportFragment != null)
                        {
                            _exportFragment.Dismiss();
                        }
                        common_functions.DisplayToast("You have to select at least one welder for each joint!!", Context);
                    }
                }
                else
                {
                    if (_exportFragment != null)
                    {
                        _exportFragment.Dismiss();
                    }
                    common_functions.DisplayToast("You have to fill at least one joint!!", Context);
                }
            }
            catch (Exception ex)
            {
                npcc_services.inf_mobile_exception_managerAsync(ex.Message);
            }
        }
示例#26
0
        public override async void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (null == data)
            {
                SelectButtonIsVisible = true;

                SavedState.PutBoolean(FILE_CHOOSER_VISIBILTY, SelectButtonIsVisible);
            }

            if (requestCode == FileRequestCode && resultCode == (int)Result.Ok)
            {
                //Before performing a new task, clean up the temp.
                PathHelper.DeleteAllTempFiles();

                //Save the filename to memory.
                PathHelper.OriginalPDFName = data.Data.GetFileNameFromURIWithoutExtension();
                await Task.Run(() =>
                {
                    try

                    {
                        context.RunOnUiThread(() =>
                        {
                            //Turn off the fileChooser
                            fileChooserCard.Visibility = ViewStates.Gone;

                            SelectButtonIsVisible = false;

                            SavedState.PutBoolean(FILE_CHOOSER_VISIBILTY, SelectButtonIsVisible);
                        });

                        //Try extract images from the supplied pdf.
                        //Create the temp folder.

                        string directory = PathHelper.GetOrCreateExtractRTempDirectory();

                        //Build the save Path.
                        string savePath = string.Empty;

                        if (!string.IsNullOrEmpty(directory))
                        {
                            savePath = System.IO.Path.Combine(directory, PathHelper.OriginalPDFName);
                        }

                        var stream = context.ContentResolver.OpenInputStream(data.Data);

                        ImageExtractor imageExtractor = new ImageExtractor(stream);

                        imageExtractor.ImageSaved += (s, e) =>
                        {
                            context.RunOnUiThread(() =>
                            {
                                //Try updating the progressbar.
                                processingProgressBar.SetProgress(e.Progress, true);
                            });
                        };

                        if (imageExtractor != null)
                        {
                            context.RunOnUiThread(() =>
                            {
                                //Show the processing group.
                                if (processingGroup.Visibility == ViewStates.Gone)
                                {
                                    processingGroup.Visibility = ViewStates.Visible;
                                }

                                //Set the text in the processing textview.
                                processingTextView.Text = $"ExtractR is scanning your document...";
                            });

                            //Extract data from the pdf.
                            var elements = imageExtractor.ExtractElementsData();

                            context.RunOnUiThread(() =>
                            {
                                if (null == elements || elements.Result.Count == 0)
                                {
                                    //No need to waste time. Break out of the function.
                                    ReportNothingFound();
                                    return;
                                }
                                //Update the text in the processing textview again to reflect the total elements found.
                                processingTextView.Text = $"Processing {elements.Result.Count} possible images...";

                                processingProgressBar.SetProgress(0, true);
                                processingProgressBar.Max = elements.Result.Count;
                            });

                            if (elements != null)
                            {
                                var savedImagePaths = imageExtractor.ProcessData(elements.Result, savePath).Result;

                                //Remove all current items.
                                ImageFileNameModels.Clear();

                                foreach (var path in savedImagePaths)
                                {
                                    System.Diagnostics.Debug.WriteLine(path);

                                    ImageFileNameModels.Add(new ImageFileNameModel
                                    {
                                        FileName = path,
                                        FullPath = System.IO.Path.Combine(PathHelper.ExtractRDirectory, path)
                                    });;
                                }
                            }

                            context.RunOnUiThread(() =>
                            {
                                processingGroup.Visibility = ViewStates.Gone;

                                var count = ImageFileNameModels.Count;
                                mainActivity.toolbar.Subtitle = count > 0 ? $"Found {count} possible images." : "No image found.";
                                ItemCountHelper.UpdateExportItemsCount(mainActivity, ImageFileNameModels);
                                _recyclerView.GetAdapter().NotifyDataSetChanged();
                            });
                        }
                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                });
            }

            base.OnActivityResult(requestCode, resultCode, data);
        }