Skip to content

Commit

Permalink
Merge pull request JakeWharton#760 from SimonVT/issue-623
Browse files Browse the repository at this point in the history
Init the action bar during findViewById
  • Loading branch information
JakeWharton committed Dec 27, 2012
2 parents c911c0b + dfa1796 commit d5e5d5e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/src/com/actionbarsherlock/ActionBarSherlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,4 +791,9 @@ public MenuInflater getMenuInflater() {
* @see ActionMode
*/
public abstract ActionMode startActionMode(ActionMode.Callback callback);

/**
* Ensure that the action bar is attached.
*/
public void ensureActionBar() {}
}
6 changes: 6 additions & 0 deletions library/src/com/actionbarsherlock/app/SherlockActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ public void requestWindowFeature(long featureId) {
getSherlock().requestFeature((int)featureId);
}

@Override
public View findViewById(int id) {
getSherlock().ensureActionBar();
return super.findViewById(id);
}


///////////////////////////////////////////////////////////////////////////
// Progress Indication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public void requestWindowFeature(long featureId) {
getSherlock().requestFeature((int)featureId);
}

@Override
public View findViewById(int id) {
getSherlock().ensureActionBar();
return super.findViewById(id);
}


///////////////////////////////////////////////////////////////////////////
// Progress Indication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ public void requestWindowFeature(long featureId) {
getSherlock().requestFeature((int)featureId);
}

@Override
public View findViewById(int id) {
getSherlock().ensureActionBar();
return super.findViewById(id);
}


///////////////////////////////////////////////////////////////////////////
// Progress Indication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ public void requestWindowFeature(long featureId) {
getSherlock().requestFeature((int)featureId);
}

@Override
public View findViewById(int id) {
getSherlock().ensureActionBar();
return super.findViewById(id);
}


///////////////////////////////////////////////////////////////////////////
// Progress Indication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ public void requestWindowFeature(long featureId) {
getSherlock().requestFeature((int)featureId);
}

@Override
public View findViewById(int id) {
getSherlock().ensureActionBar();
return super.findViewById(id);
}


///////////////////////////////////////////////////////////////////////////
// Progress Indication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1200,4 +1200,13 @@ public void onDestroyActionMode(ActionMode mode) {
mActionMode = null;
}
}

@Override
public void ensureActionBar() {
if (DEBUG) Log.d(TAG, "[ensureActionBar]");

if (mDecor == null) {
initActionBar();
}
}
}

0 comments on commit d5e5d5e

Please sign in to comment.