public static FragmentManager GetFragmentManager(this Activity activity) { Should.NotBeNull(activity, "activity"); #if API8SUPPORT Should.BeOfType <FragmentActivity>(activity, "activity"); return(((FragmentActivity)activity).SupportFragmentManager); #else return(activity.FragmentManager); #endif }
public static ActionMode StartActionMode(this ActionBar actionBar, ActionMode.ICallback mode) { #if API8SUPPORT Should.BeOfType <ActionBarActivity>(actionBar.ThemedContext, "Activity"); var activity = (ActionBarActivity)actionBar.ThemedContext; return(activity.StartSupportActionMode(mode)); #else Should.BeOfType <Activity>(actionBar.ThemedContext, "Activity"); var activity = (Activity)actionBar.ThemedContext; return(activity.StartActionMode(mode)); #endif }
public static void SetContentView([NotNull] this ViewGroup frameLayout, object content) { Should.NotBeNull(frameLayout, "frameLayout"); if (content == null) { frameLayout.RemoveAllViews(); return; } Should.BeOfType <View>(content, "content"); if (frameLayout.ChildCount == 1 && frameLayout.GetChildAt(0) == content) { return; } frameLayout.RemoveAllViews(); frameLayout.AddView((View)content); }
public static ActionBar GetActionBar(this Activity activity, bool throwOnError = true) { Should.NotBeNull(activity, "activity"); #if API8SUPPORT if (throwOnError) { Should.BeOfType <ActionBarActivity>(activity, "activity"); return(((ActionBarActivity)activity).SupportActionBar); } var actionBarActivity = activity as ActionBarActivity; if (actionBarActivity == null) { return(null); } return(actionBarActivity.SupportActionBar); #else return(activity.ActionBar); #endif }