Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash: removal of the actions from actionbar #49

Open
hashfold opened this issue Jan 7, 2012 · 2 comments
Open

crash: removal of the actions from actionbar #49

hashfold opened this issue Jan 7, 2012 · 2 comments

Comments

@hashfold
Copy link

hashfold commented Jan 7, 2012

I used "Remove Action" button to remove all the actions one by one.
it crashes when I tried to remove further, its because there are no more actions to be removed.
in this case the actionIndex = -1 and number of child nodes in actionView is 0.

below is the fix works great:

/**
* Remove a action from the action bar.
* @param index position of action to remove
* HashFold: no-op in case of removal of non-existent Action.
*/
public void removeActionAt(int index) {

    int childCount = mActionsView.getChildCount();
    //no-op in case of removal of non-existent Action.
    if(index < 0 || childCount < 1)
        return;

    mActionsView.removeViewAt(index);
}

I'm the first timer on github and so don't know the exact process to put the fix.

could you analyze the above fix and see whether it qualifies as a minor fix?

@ohhorob
Copy link
Contributor

ohhorob commented Jan 7, 2012

@hashfold firstly, good on you for wanting to provide a fix for a problem you're having. That's a great start.

GitHub is collaborative in the way it allows you to take a "fork" of the code you're using, make changes, and then ask the original developer to "pull" your changes into the original codebase that everybody uses.

To contribute your fix, start with a fork. Be sure to fork from the branch & commit of android-actionbar that you have made the fix for. Refer to that "Fork A Repo" guide for how to push your changes up to your GitHub fork.

Now you're ready to make a Pull Request, and that will ask @johannilsson to please incorporate your changes for the benefit of everyone that uses android-actionbar. Here's an example pull request for changes that I made in my fork: Layout adjustments

Your pull request might not automatically be accepted! There might be differences of opinion regarding anything from commenting, error handling, code style or even if the fix was made in the correct place. i.e. just because it works for you, doesn't mean it's in everybody's best interest. Work with the developer to reach a point where they're happy to merge the changes. If they don't it's not personal, and all is not lost!

Even if your pull request is not performed, you can still maintain your fork of the code by keeping it up to date the with original code base. Just keep merging in the original repo when you'd like to include the fixes and updates that are happening there.

Hope that helps & good luck :)

@johannilsson
Copy link
Owner

Great introduction for contributing to an open source project @ohhorob, thank you. I'm of course highly great full for all things contributed even if it's not from a pull request but it's the preferred way.

On the issue, I'm not sure we should fix this here. I think it's a good idea that an exception is thrown here to indicate that the operation could not be performed as intended. Instead I think the example project should be updated to show how this should be handle. Which should be possible by using the method getActionCount.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants