public void OnClick(View view) { string url = mEditText.Text; bool success; switch (view.Id) { case Resource.Id.connect_button: BindCustomTabsService(); break; case Resource.Id.warmup_button: success = false; if (mClient != null) { success = mClient.Warmup(0); } mWarmupButton.Enabled &= success; break; case Resource.Id.may_launch_button: CustomTabsSession session = GetSession(); success = false; if (mClient != null) { success = session.MayLaunchUrl(Uri.Parse(url), null, null); } mMayLaunchButton.Enabled &= success; break; case Resource.Id.launch_button: var builder = new CustomTabsIntent.Builder(GetSession()); builder.SetToolbarColor(Color.ParseColor(TOOLBAR_COLOR)).SetShowTitle(true); PrepareMenuItems(builder); PrepareActionButton(builder); PrepareBottombar(builder); builder.SetStartAnimations(this, Resource.Animation.slide_in_right, Resource.Animation.slide_out_left); builder.SetExitAnimations(this, Resource.Animation.slide_in_left, Resource.Animation.slide_out_right); builder.SetCloseButtonIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_arrow_back)); CustomTabsIntent customTabsIntent = builder.Build(); CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent); customTabsIntent.LaunchUrl(this, Uri.Parse(url)); break; } }
public void OnClick(View view) { Uri uri = Uri.Parse(mUrlEditText.Text); switch (view.Id) { case Resource.Id.button_may_launch_url: customTabActivityHelper.MayLaunchUrl(uri, null, null); break; case Resource.Id.start_custom_tab: CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(customTabActivityHelper.GetSession()).Build(); CustomTabsHelper.AddKeepAliveExtra(this, customTabsIntent.Intent); CustomTabActivityHelper.OpenCustomTab(this, customTabsIntent, uri, new WebviewFallback()); break; default: throw new Exception("Unkown View Clicked"); } }