com.actionbarsherlock.app.SherlockFragmentActivity Java Examples

The following examples show how to use com.actionbarsherlock.app.SherlockFragmentActivity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PullToRefreshAttacher.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return Context which should be used for inflating the header layout
 */
public Context getContextForInflater(Activity activity) {
    if (activity instanceof SherlockActivity) {
        return ((SherlockActivity) activity).getSupportActionBar().getThemedContext();
    } else if (activity instanceof SherlockListActivity) {
        return ((SherlockListActivity) activity).getSupportActionBar().getThemedContext();
    } else if (activity instanceof SherlockFragmentActivity) {
        return ((SherlockFragmentActivity) activity).getSupportActionBar()
                .getThemedContext();
    } else if (activity instanceof SherlockExpandableListActivity) {
        return ((SherlockExpandableListActivity) activity).getSupportActionBar()
                .getThemedContext();
    } else if (activity instanceof SherlockPreferenceActivity) {
        return ((SherlockPreferenceActivity) activity).getSupportActionBar()
                .getThemedContext();
    }
    return super.getContextForInflater(activity);
}
 
Example #2
Source File: ActionBarWrapper.java    From android-apps with MIT License 6 votes vote down vote up
@Override
public void onTabReselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
    if (mListener != null) {
        FragmentTransaction trans = null;
        if (mActivity instanceof SherlockFragmentActivity) {
            trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
                    .disallowAddToBackStack();
        }

        mListener.onTabReselected(this, trans);

        if (trans != null && !trans.isEmpty()) {
            trans.commit();
        }
    }
}
 
Example #3
Source File: ActionBarWrapper.java    From android-apps with MIT License 6 votes vote down vote up
@Override
public void onTabSelected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
    if (mListener != null) {

        if (mFragmentTransaction == null && mActivity instanceof SherlockFragmentActivity) {
            mFragmentTransaction = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
                    .disallowAddToBackStack();
        }

        mListener.onTabSelected(this, mFragmentTransaction);

        if (mFragmentTransaction != null) {
            if (!mFragmentTransaction.isEmpty()) {
                mFragmentTransaction.commit();
            }
            mFragmentTransaction = null;
        }
    }
}
 
Example #4
Source File: FadingActionBarHelper.java    From Favorite-Android-Client with Apache License 2.0 6 votes vote down vote up
private ActionBar getActionBar(Activity activity) {
    if (activity instanceof SherlockActivity) {
        return ((SherlockActivity) activity).getSupportActionBar();
    }
    if (activity instanceof SherlockFragmentActivity) {
        return ((SherlockFragmentActivity) activity).getSupportActionBar();
    }
    if (activity instanceof SherlockListActivity) {
        return ((SherlockListActivity) activity).getSupportActionBar();
    }
    ActionBar actionBar = getActionBarWithReflection(activity, "getSupportActionBar");
    if (actionBar == null) {
        throw new RuntimeException("Activity should derive from one of the ActionBarSherlock activities "
            + "or implement a method called getSupportActionBar");
    }
    return actionBar;
}
 
Example #5
Source File: FadingActionBarHelper.java    From FadingActionBar with Apache License 2.0 6 votes vote down vote up
private ActionBar getActionBar(Activity activity) {
    if (activity instanceof SherlockActivity) {
        return ((SherlockActivity) activity).getSupportActionBar();
    }
    if (activity instanceof SherlockFragmentActivity) {
        return ((SherlockFragmentActivity) activity).getSupportActionBar();
    }
    if (activity instanceof SherlockListActivity) {
        return ((SherlockListActivity) activity).getSupportActionBar();
    }
    ActionBar actionBar = getActionBarWithReflection(activity, "getSupportActionBar");
    if (actionBar == null) {
        throw new RuntimeException("Activity should derive from one of the ActionBarSherlock activities "
            + "or implement a method called getSupportActionBar");
    }
    return actionBar;
}
 
Example #6
Source File: IssueDetailsActivity.java    From magpi-android with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.menu = menu;
    getSupportMenuInflater().inflate(R.menu.issue, menu);
    this.inflater = (LayoutInflater) ((SherlockFragmentActivity) this).getSupportActionBar().getThemedContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return true;
}
 
Example #7
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
/**
 * Show the actionbar with backstack icon
 * 
 * @param activity
 * @param title
 */
public static void showActionBarwithBack(final SherlockFragmentActivity activity, 
		final String title) {
	if (activity == null) return;
	
	setTitle(activity, title);
	makeOverflowMenuShow(activity.getApplicationContext());
	setActionBar(activity.getActionBar(), activity.getSupportActionBar(), R.drawable.ic_ab_up_compat);
}
 
Example #8
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
/**
 * Show the actionbar with given attributes
 * 
 * @param activity
 * @param title
 * @param isShowDrawerMenu
 */
public static void showActionBar(final SherlockFragmentActivity activity, 
		final String title, final boolean isShowDrawerMenu) {
	if (activity == null) return;
	
	setTitle(activity, title);
	if (isShowDrawerMenu) {
		setActionBar(activity.getActionBar(), activity.getSupportActionBar(), R.drawable.ic_drawer);
	}
	makeOverflowMenuShow(activity.getApplicationContext());
}
 
Example #9
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
public static void setLogo(final SherlockFragmentActivity activity, final int logoResc) {
	if (activity == null) return;
	
	activity.getSupportActionBar().setLogo(logoResc);
	activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
	activity.getSupportActionBar().setDisplayUseLogoEnabled(true);
	activity.getSupportActionBar().setHomeButtonEnabled(true);
}
 
Example #10
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
public static void setIcon(final SherlockFragmentActivity activity, final int iconResc) {
	if (activity == null) return;
	
	activity.getSupportActionBar().setIcon(iconResc);
	activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
	activity.getSupportActionBar().setDisplayUseLogoEnabled(true);
	activity.getSupportActionBar().setHomeButtonEnabled(true);
}
 
Example #11
Source File: BaseFragment.java    From hosts-editor-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    if (BuildConfig.DEBUG && !(activity instanceof SherlockFragmentActivity)) {
        throw new UnsupportedOperationException("Activity must be a SherlockFragmentActivity");
    }

    super.onAttach(activity);
    mApp = HostsEditorApplication.get(activity);
    mActivity = (SherlockFragmentActivity) activity;
}
 
Example #12
Source File: MagpiMainActivity.java    From magpi-android with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    this.menu = menu;
    getSupportMenuInflater().inflate(R.menu.activity_magpi, menu);
    this.inflater = (LayoutInflater) ((SherlockFragmentActivity) this).getSupportActionBar().getThemedContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return true;
}
 
Example #13
Source File: ActionBarWrapper.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void onTabUnselected(android.app.ActionBar.Tab tab, android.app.FragmentTransaction ft) {
    if (mListener != null) {
        FragmentTransaction trans = null;
        if (mActivity instanceof SherlockFragmentActivity) {
            trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
                    .disallowAddToBackStack();
            mFragmentTransaction = trans;
        }

        mListener.onTabUnselected(this, trans);
    }
}
 
Example #14
Source File: ActionBarImpl.java    From android-apps with MIT License 5 votes vote down vote up
@Override
public void selectTab(Tab tab) {
    if (getNavigationMode() != NAVIGATION_MODE_TABS) {
        mSavedTabPosition = tab != null ? tab.getPosition() : INVALID_POSITION;
        return;
    }

    FragmentTransaction trans = null;
    if (mActivity instanceof SherlockFragmentActivity) {
        trans = ((SherlockFragmentActivity)mActivity).getSupportFragmentManager().beginTransaction()
                .disallowAddToBackStack();
    }

    if (mSelectedTab == tab) {
        if (mSelectedTab != null) {
            mSelectedTab.getCallback().onTabReselected(mSelectedTab, trans);
            mTabScrollView.animateToTab(tab.getPosition());
        }
    } else {
        mTabScrollView.setTabSelected(tab != null ? tab.getPosition() : Tab.INVALID_POSITION);
        if (mSelectedTab != null) {
            mSelectedTab.getCallback().onTabUnselected(mSelectedTab, trans);
        }
        mSelectedTab = (TabImpl) tab;
        if (mSelectedTab != null) {
            mSelectedTab.getCallback().onTabSelected(mSelectedTab, trans);
        }
    }

    if (trans != null && !trans.isEmpty()) {
        trans.commit();
    }
}
 
Example #15
Source File: PluginFragment.java    From geoar-app with Apache License 2.0 5 votes vote down vote up
private void addStepsToIntro() {
	IntroController.addViewToStep(3, mTabHost.getTabWidget()
			.getChildTabViewAt(1));
	IntroController.addViewToStep(4, null);
	IntroController.addViewToStep(5, mTabHost.getTabWidget()
			.getChildTabViewAt(0));
	IntroController.addViewToStep(6, null);
	View view = ((SherlockFragmentActivity) getActivity())
			.findViewById(R.id.item_map);
	if (view != null)
		IntroController.addViewToStep(7, view);
}
 
Example #16
Source File: CallLogListFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onVisibilityChanged(boolean visible) {
    if (mShowOptionsMenu != visible) {
        mShowOptionsMenu = visible;
        // Invalidate the options menu since we are changing the list of
        // options shown in it.
        SherlockFragmentActivity activity = getSherlockActivity();
        if (activity != null) {
            activity.invalidateOptionsMenu();
        }
    }
    

    if(visible) {
        attachAdapter();
        // Start loading
        if(!alreadyLoaded) {
            getLoaderManager().initLoader(0, null, this);
            alreadyLoaded = true;
        }
    }
    
    
    if (visible && isResumed()) {
        //getLoaderManager().restartLoader(0, null, this);
        ListView lv = getListView();
        if (lv != null && mAdapter != null) {
            final int checkedPos = lv.getCheckedItemPosition();
            if (checkedPos >= 0) {
                // TODO post instead
                Thread t = new Thread() {
                    public void run() {
                        final long[] selectedIds = mAdapter.getCallIdsAtPosition(checkedPos);
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                viewDetails(checkedPos, selectedIds);  
                            }
                        });
                    };
                };
                t.start();
            }
        }
    }
    
    
    if(!visible && mMode != null) {
        mMode.finish();
    }
}
 
Example #17
Source File: SubscribedChannelsFragment.java    From buddycloud-android with Apache License 2.0 4 votes vote down vote up
@Override
public void attached(Activity activity) {
	SherlockFragmentActivity sherlockActivity = (SherlockFragmentActivity) activity;
	sherlockActivity.getSupportActionBar().setTitle(R.string.app_name);
}
 
Example #18
Source File: ChannelStreamFragment.java    From buddycloud-android with Apache License 2.0 4 votes vote down vote up
private void showProgress(View container) {
	SherlockFragmentActivity activity = (SherlockFragmentActivity) getActivity();
    activity.setProgressBarIndeterminateVisibility(true);
}
 
Example #19
Source File: ChannelStreamFragment.java    From buddycloud-android with Apache License 2.0 4 votes vote down vote up
private void hideProgress(View container) {
	SherlockFragmentActivity activity = (SherlockFragmentActivity) getActivity();
    activity.setProgressBarIndeterminateVisibility(false);
}
 
Example #20
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 4 votes vote down vote up
public static void setTitle(final SherlockFragmentActivity activity, final String title) {
	if (activity == null || title == null) return;
	
	activity.getSupportActionBar().setTitle(title);
	activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
}
 
Example #21
Source File: NewsFragment.java    From magpi-android with MIT License 4 votes vote down vote up
@Override
public void onStart() {
    super.onStart();
    ((SherlockFragmentActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
}