com.actionbarsherlock.app.SherlockActivity Java Examples

The following examples show how to use com.actionbarsherlock.app.SherlockActivity. 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: 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 #3
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 #4
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
public static void setIcon(final SherlockActivity 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 #5
Source File: ActionbarUtil.java    From buddycloud-android with Apache License 2.0 5 votes vote down vote up
public static void setLogo(final SherlockActivity 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 #6
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 SherlockActivity 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 #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 SherlockActivity 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 4 votes vote down vote up
public static void setTitle(final SherlockActivity activity, final String title) {
	if (activity == null || title == null) return;
	
	activity.getSupportActionBar().setTitle(title);
	activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
}