Skip to content

Attempt SherlockFragmentActivity/SherlockFragment #285

Closed
JakeWharton opened this Issue Feb 18, 2012 · 2 comments

2 participants

@JakeWharton
Owner

The only thing we modify FragmentActivity, FragmentManagerImpl, and Fragment for is to change the menu dispatching imports so that we can use our compatibility menu classes. Everything else we dispatch via overrides.

Theoretically, by overriding FragmentActivity we should be able to leverage the panel's menu to wrap our custom menu classes using an extension of the native type to dispatch through the normal methods. We would then need a SherlockFragment which provided final overrides of the native types to unwrap our custom menu and then execute our callbacks.

Something like this:

SherlockFragment extends Fragment {
    final boolean onOptionsItemSelected(android.view.MenuItem item) {
        return onOptionsItemSelected(((MenuItemWrapper)item).unwrap());
    }
    boolean onOptionsItemSelected(MenuItem item) {
        //override me
    }
    //etc...
}
@daverix
daverix commented Feb 18, 2012

Does this mean we can use the support package from google instead of the modified support plugin delivered with ABS?

@JakeWharton
Owner
@JakeWharton JakeWharton added a commit that closed this issue Feb 20, 2012
@JakeWharton Change support-lib plugin to allow using binary from Google. Closes #285
.

Since its true inception (i.e., version 3), ActionBarSherlock has had one major criticism that created a reluctance for a lot of people to leverage it in their apps: its internalization and modification of the Google support library (compatibility package). This was deemed necessary since there is no reliable external way to dispatch anything to attached and visible fragments.

With this commit we introduce a new set of base classes which exist independent of the support library (and extend from it) in order to progressively add the action bar functionality.

 * `SherlockFragmentActivity` replaces `FragmentActivity` and has the job of marshalling our ABS menu classes into native wrappers which can be dispatched along the normal menu callbacks and thus into the appropriate fragments.
 * `SherlockFragment` (and `SherlockListFragment and `SherlockDialogFragment`) replace `Fragment` and unwrap the menu instances dispatched through the fragment manager so that we can use the ABS menu classes in new callbacks. The regular menu callbacks are finalized just like their activity counterparts so that only the correct ones can be overriden.
e23de78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.