Skip to content

Instantly share code, notes, and snippets.

@martijn00
Created April 27, 2015 21:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martijn00/fde1c018453bedf096bf to your computer and use it in GitHub Desktop.
Save martijn00/fde1c018453bedf096bf to your computer and use it in GitHub Desktop.
MvxCachingFragmentActivityCompat
public class MvxCachingFragmentActivityCompat : MvxCachingFragmentActivity
{
private AppCompatDelegate _compatDelegate;
private AppCompatDelegate CompatDelegate
{
get {
if(_compatDelegate == null)
_compatDelegate = AppCompatDelegate.Create (this, null);
return _compatDelegate;
}
}
protected override void OnCreate (Bundle savedInstanceState)
{
CompatDelegate.InstallViewFactory();
CompatDelegate.OnCreate(savedInstanceState);
base.OnCreate (savedInstanceState);
}
protected override void OnPostCreate (Bundle savedInstanceState)
{
base.OnPostCreate (savedInstanceState);
CompatDelegate.OnPostCreate(savedInstanceState);
}
public ActionBar SupportActionBar
{
get {
return CompatDelegate.SupportActionBar;
}
}
public void SetSupportActionBar(Toolbar toolbar) {
CompatDelegate.SetSupportActionBar(toolbar);
}
public override MenuInflater MenuInflater {
get {
return CompatDelegate.MenuInflater;
}
}
public override void SetContentView (int layoutResID)
{
CompatDelegate.SetContentView(layoutResID);
}
public override void SetContentView (View view)
{
CompatDelegate.SetContentView(view);
}
public override void SetContentView (View view, ViewGroup.LayoutParams @params)
{
CompatDelegate.SetContentView(view, @params);
}
public override void AddContentView (View view, ViewGroup.LayoutParams @params)
{
CompatDelegate.AddContentView(view, @params);
}
protected override void OnPostResume ()
{
base.OnPostResume ();
CompatDelegate.OnPostResume();
}
protected override void OnTitleChanged (ICharSequence title, Color color)
{
base.OnTitleChanged (title, color);
CompatDelegate.SetTitle(title);
}
public override void OnConfigurationChanged (Configuration newConfig)
{
base.OnConfigurationChanged (newConfig);
CompatDelegate.OnConfigurationChanged(newConfig);
}
protected override void OnStop ()
{
base.OnStop ();
CompatDelegate.OnStop();
}
protected override void OnDestroy ()
{
base.OnDestroy ();
CompatDelegate.OnDestroy();
}
public void InvalidateOptionsMenu() {
CompatDelegate.InvalidateOptionsMenu();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment