@@ -132,6 +132,8 @@ public class ActionBarView extends AbsActionBarView {
132132 private ExpandedActionViewMenuPresenter mExpandedMenuPresenter ;
133133 View mExpandedActionView ;
134134
135+ Window .Callback mWindowCallback ;
136+
135137 private final AdapterView .OnItemSelectedListener mNavItemSelectedListener =
136138 new AdapterView .OnItemSelectedListener () {
137139 public void onItemSelected (AdapterView parent , View view , int position , long id ) {
@@ -156,11 +158,7 @@ public void onClick(View v) {
156158
157159 private final OnClickListener mUpClickListener = new OnClickListener () {
158160 public void onClick (View v ) {
159- Context context = getContext ();
160- if (context instanceof Activity ) {
161- Activity activity = (Activity ) context ;
162- activity .onMenuItemSelected (Window .FEATURE_OPTIONS_PANEL , mLogoNavItem );
163- }
161+ mWindowCallback .onMenuItemSelected (Window .FEATURE_OPTIONS_PANEL , mLogoNavItem );
164162 }
165163 };
166164
@@ -275,6 +273,14 @@ protected void onConfigurationChanged(Configuration newConfig) {
275273 }
276274 }
277275
276+ /**
277+ * Set the window callback used to invoke menu items; used for dispatching home button presses.
278+ * @param cb Window callback to dispatch to
279+ */
280+ public void setWindowCallback (Window .Callback cb ) {
281+ mWindowCallback = cb ;
282+ }
283+
278284 @ Override
279285 public void onDetachedFromWindow () {
280286 super .onDetachedFromWindow ();
0 commit comments