X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=android-libraries%2FActionBarSherlock%2Fsrc%2Fcom%2Factionbarsherlock%2Fapp%2FSherlockFragment.java;fp=android-libraries%2FActionBarSherlock%2Fsrc%2Fcom%2Factionbarsherlock%2Fapp%2FSherlockFragment.java;h=10d673f9faf7ad7208a620c3ef160ac0cd53d603;hb=b86a2c09c261df4b94a260ed2cb2eb6af8267b8b;hp=0000000000000000000000000000000000000000;hpb=908cef0a8ca2f13ec37af90cefd23bbc73b1a0eb;p=debian%2Fopenrocket diff --git a/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java new file mode 100644 index 00000000..10d673f9 --- /dev/null +++ b/android-libraries/ActionBarSherlock/src/com/actionbarsherlock/app/SherlockFragment.java @@ -0,0 +1,76 @@ +package com.actionbarsherlock.app; + +import static com.actionbarsherlock.app.SherlockFragmentActivity.DEBUG; +import android.app.Activity; +import android.support.v4.app.Fragment; +import android.util.Log; +import com.actionbarsherlock.internal.view.menu.MenuItemMule; +import com.actionbarsherlock.internal.view.menu.MenuMule; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; + +public class SherlockFragment extends Fragment { + private static final String TAG = "SherlockFragment"; + + private SherlockFragmentActivity mActivity; + + public SherlockFragmentActivity getSherlockActivity() { + return mActivity; + } + + @Override + public void onAttach(Activity activity) { + if (!(activity instanceof SherlockFragmentActivity)) { + throw new IllegalStateException(TAG + " must be attached to a SherlockFragmentActivity."); + } + mActivity = (SherlockFragmentActivity)activity; + + super.onAttach(activity); + } + + @Override + public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) { + if (DEBUG) Log.d(TAG, "[onCreateOptionsMenu] menu: " + menu + ", inflater: " + inflater); + + if (menu instanceof MenuMule) { + MenuMule mule = (MenuMule)menu; + mule.mDispatchShow = true; + onCreateOptionsMenu(mule.unwrap(), mActivity.getSupportMenuInflater()); + } + } + + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + //Nothing to see here. + } + + @Override + public final void onPrepareOptionsMenu(android.view.Menu menu) { + if (DEBUG) Log.d(TAG, "[onPrepareOptionsMenu] menu: " + menu); + + if (menu instanceof MenuMule) { + MenuMule mule = (MenuMule)menu; + mule.mDispatchShow = true; + onPrepareOptionsMenu(mule.unwrap()); + } + } + + public void onPrepareOptionsMenu(Menu menu) { + //Nothing to see here. + } + + @Override + public final boolean onOptionsItemSelected(android.view.MenuItem item) { + if (DEBUG) Log.d(TAG, "[onOptionsItemSelected] item: " + item); + + if (item instanceof MenuItemMule) { + return onOptionsItemSelected(((MenuItemMule)item).unwrap()); + } + return false; + } + + public boolean onOptionsItemSelected(MenuItem item) { + //Nothing to see here. + return false; + } +}