Example #1
0
 public void ItemAdd(IResultItem item)
 {
     if (item is Problem)
     {
         bad = true;
     }
     Items.Add(item);
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Resource.Layout.SubmittedFragment, container, false);

            View header = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedHeader, null);

            exportList = view.FindViewById<ListView>(Resource.Id.submitted_list);
            exportList.AddHeaderView(header, null, false);
            LoadData();
            exportList.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
            {
                // The list's header borks indexing
                res = results[args.Position - 1];

                View alertView = Activity.LayoutInflater.Inflate(Resource.Layout.SubmittedAlert, null);

                Button feedbackBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_feedbackBtn);
                feedbackBtn.Click += feedbackBtn_Click;

                Button permissionsBtn = alertView.FindViewById<Button>(Resource.Id.submittedAlert_permission);
                permissionsBtn.Click += permissionsBtn_Click;

                Android.Support.V7.App.AlertDialog alert = new Android.Support.V7.App.AlertDialog.Builder(Activity)
                .SetTitle("What would you like to do with this submission?")
                .SetView(alertView)
                .SetCancelable(true)
                .SetNegativeButton("Delete", (EventHandler<DialogClickEventArgs>)null)
                .SetNeutralButton("Close", (s, a) => { })
                .Create();

                alert.Show();

                // A second alert dialogue, confirming the decision to delete
                Button deleteBtn = alert.GetButton((int)DialogButtonType.Negative);
                deleteBtn.Click += delegate(object s, EventArgs e)
                {
                    Android.Support.V7.App.AlertDialog.Builder confirm = new Android.Support.V7.App.AlertDialog.Builder(Activity);
                    confirm.SetTitle("Are you sure?");
                    confirm.SetMessage("The recorded data will be deleted from the server and irrecoverably lost. Continue?");
                    confirm.SetPositiveButton("Delete", (senderAlert, confArgs) =>
                    {
                        ServerData.PushResultDeletion(res);

                        exportList.Adapter = null;
                        LoadData();

                        alert.Dismiss();
                    });
                    confirm.SetNegativeButton("Cancel", (senderAlert, confArgs) => { });
                    confirm.Show();
                };     
            };

            return view;
        }
Example #3
0
        /// <summary>
        /// Removes the result object from the toUpload list and deletes the files on disk (local deletion only)
        /// </summary>
        /// <param name="result">The item to delete</param>
        public async void DeleteResult(IResultItem result, bool save = true)
        {
            ResultsToUpload.Remove(result);

            if(await AppData.Exports.CheckExistsAsync(Path.GetFileName(result.ResourceUrl)) == ExistenceCheckResult.FileExists)
            {
                IFile toDel = await AppData.Exports.GetFileAsync(Path.GetFileName(result.ResourceUrl));

                await toDel.DeleteAsync();
            }

            if (save) AppData.SaveCurrentData();
        }
Example #4
0
 /// <summary>
 /// 添加当前页的结果条目
 /// </summary>
 /// <param name="item"></param>
 public void AddItem(IResultItem item)
 {
     this.m_items.Add(item);
     this.PageCount++;
 }