Exemple #1
0
        protected void ShowWaitDialog_Samll(string msg, bool isCanCancel = false, bool isOutSideTouch = false)
        {
            if (dialog_Show == null)
            {
                InitShowDialog();
            }
            if (dialog_Show.IsShowing)
            {
                dialog_Show.FindViewById <TextView>(Resource.Id.tv_hint).Text = msg;
            }
            else
            {
                var v = LayoutInflater.From(this).Inflate(Resource.Layout.Dialog_WaitProgress_Small, null);
                v.FindViewById <TextView>(Resource.Id.tv_hint).Text = msg;
                dialog_Show.SetContentView(v);
            }
            dialog_Show.SetCancelable(isCanCancel);
            dialog_Show.SetCanceledOnTouchOutside(isOutSideTouch);
            var window = dialog_Show.Window;

            if (window != null)
            {
                var attr = window.Attributes;
                if (attr != null)
                {
                    attr.Height       = 160;
                    attr.Width        = 160;
                    attr.Gravity      = GravityFlags.Center;
                    window.Attributes = (attr);
                }
            }
            dialog_Show.Show();
        }
        private async Task LoadRestaurantList()
        {
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                try
                {
                    var result = await restaurantRecommenderPayLoad.RestaurantList();

                    var user_result = await restaurantRecommenderPayLoad.UserList();

                    RunOnUiThread(() =>
                    {
                        progressBar.Visibility = ViewStates.Gone;
                        if (result.Count() > 0 && user_result.Count() > 0)
                        {
                            Intent intent       = new Intent(this, typeof(UserActivity));
                            var restraunt_group = result.GroupBy(x => x.RestaurantType)
                                                  .Select(group => new RestaurantSection(group.Select(x => x.RestaurantName).ToList())
                            {
                                SectionName = group.Key,
                            }).OrderBy(x => x.SectionName).ToList();
                            intent.PutExtra("User_List", JsonConvert.SerializeObject(user_result));
                            intent.PutExtra("Restaurant_List", JsonConvert.SerializeObject(restraunt_group));
                            this.StartActivity(intent);
                        }
                    });
                }
                catch (Exception ex)
                {
                    RunOnUiThread(() =>
                    {
                        AndroidX.AppCompat.App.AlertDialog.Builder dialog = new AndroidX.AppCompat.App.AlertDialog.Builder(this);
                        AndroidX.AppCompat.App.AlertDialog alert          = dialog.Create();
                        alert.SetTitle("Error");
                        alert.SetMessage(ex.Message.ToString());
                        alert.SetCancelable(true);
                        alert.Show();
                    });
                }
            }
            else
            {
                RunOnUiThread(() =>
                {
                    AndroidX.AppCompat.App.AlertDialog.Builder dialog = new AndroidX.AppCompat.App.AlertDialog.Builder(this);
                    AndroidX.AppCompat.App.AlertDialog alert          = dialog.Create();
                    alert.SetTitle("Error");
                    alert.SetMessage("Please connect to the internet");
                    alert.SetCancelable(true);
                    alert.Show();
                });
            }
        }