private async void GetAndOpenActivity(string code) { ProgressDialog dialog = new ProgressDialog(this); dialog.SetMessage(Resources.GetString(Resource.String.PleaseWait)); dialog.Show(); ServerResponse <LearningActivity> result = await ServerUtils.Get <LearningActivity>("/api/LearningActivities/GetWithCode?code=" + code).ConfigureAwait(false); RunOnUiThread(() => { dialog.Dismiss(); dialog.Dispose(); }); if (result == null) { var suppress = AndroidUtils.ReturnToSignIn(this); RunOnUiThread(() => Toast.MakeText(this, Resource.String.ForceSignOut, ToastLength.Long).Show()); return; } if (result.Success) { await AndroidUtils.LaunchActivity(result.Data, this).ConfigureAwait(false); } else { // if token invalid, return to signin if (ServerUtils.CheckNeedsLogin(result.StatusCode)) { var suppress = AndroidUtils.ReturnToSignIn(this); return; } if (result.Message.StartsWith("404")) { RunOnUiThread(() => Toast.MakeText(this, Resource.String.searchFail, ToastLength.Long).Show()); } else { RunOnUiThread(() => Toast.MakeText(this, Resource.String.ConnectionError, ToastLength.Long).Show()); } } }
private async void Adapter_OpenItemClick(object sender, int pos) { LearningActivity act = adapter.Collection.Activities[pos - 1]; await AndroidUtils.LaunchActivity(act, this, fromCollection : true).ConfigureAwait(false); }