package com.nilhcem.hostseditor.ui;

import android.app.Activity;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockFragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.nilhcem.hostseditor.HostsEditorApplication;
import com.squareup.otto.Bus;

import javax.inject.Inject;

/**
 * All fragments should extend this for dependency injection.
 */
public class BaseFragment extends SherlockFragment {

    @Inject protected Bus mBus;

    protected SherlockFragmentActivity mActivity;
    protected HostsEditorApplication mApp;

    @Override
    public void onAttach(Activity activity) {
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new UnsupportedOperationException("Activity must be a SherlockFragmentActivity");
        }

        super.onAttach(activity);
        mActivity = (SherlockFragmentActivity) activity;
        mApp = (HostsEditorApplication) activity.getApplication();
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mApp = null;
        mActivity = null;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRetainInstance(true);
        HostsEditorApplication.get(mActivity).inject(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        mBus.register(this);
    }

    @Override
    public void onPause() {
        super.onPause();
        mBus.unregister(this);
    }
}

@@ -901,17 +901,16 @@
  mApp = 
-(
 HostsEdi
@@ -927,158 +927,22 @@
 tion
-) activity.getApplication();%0A    %7D%0A%0A    @Override%0A    public void onDetach() %7B%0A        super.onDetach();%0A        mApp = null;%0A        mActivity = null
+.get(activity)
 ;%0A  
@@ -1301,24 +1301,55 @@
 onPause() %7B%0A
+        mBus.unregister(this);%0A
         supe
@@ -1369,32 +1369,124 @@
     
+%7D%0A%0A
     
-mBus.unregister(this
+@Override%0A    public void onDetach() %7B%0A        mApp = null;%0A        mActivity = null;%0A        super.onDetach(
 );%0A 

Clean BaseFragment code