void Volume(TwoLineListItem item) { var p = (Api.Responses.Processes.Process)item.Tag; var view = LayoutInflater .From(this) .Inflate(Resource.Layout.VolumeDialog, null); var builder = new AlertDialog.Builder(this) .SetView(view); var volumeSeek = view.FindViewById <SeekBar>(Resource.Id.VolumeSeek); volumeSeek.Max = 1000; volumeSeek.Progress = volumeSeek.Max / 2; builder .SetCancelable(true) .SetPositiveButton("OK", (sender, e) => { try { var volume = Rebase(volumeSeek.Progress, 0, volumeSeek.Max, 0, 1); HandleAsyncTask( Api.Call <Api.Responses.SetAppVolume>( new Api.Requests.SetAppVolume($"/{p.pid}", volume, null), Canceller.Token), "Volume", null, $"Failed to set volume for {p.imageName} on {Name}" ); } catch (Exception er) { Log.Error(TAG, $"Failed to set volume for {p.imageName} on {Name} with error {er}"); Toast.MakeText(this, $"Failed to set volume for {p.imageName} on {Name}.", ToastLength.Short).Show(); } }) .SetNegativeButton("Cancel", (sender, e) => { }) .Create(). Show(); }
void KillProcess(TwoLineListItem item) { var p = (Api.Responses.Processes.Process)item.Tag; ShowAlert($"Close {p.imageName}?", () => { Api .Call <Api.Responses.KillProcess>(new Api.Requests.KillProcess(p.pid), Canceller.Token) .ContinueWith(t => { if (t.IsCanceled) { return; } bool success = true; if (t.IsFaulted) { success = false; Log.Error(TAG, $"Failed to kill process with pid {p.pid}."); } if (!t.Result.result) { success = false; Log.Error(TAG, $"Failed to kill process with pid {p.pid}, error {t.Result.error}."); } RunOnUiThread(() => { if (!success) { Toast.MakeText(this, $"Failed to close {p.imageName}.", ToastLength.Short).Show(); } }); }); }); }