johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.31k stars 564 forks source link

crash: removal of the actions from actionbar #49

Open hashfold opened 12 years ago

hashfold commented 12 years ago

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 commented 12 years ago

@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 commented 12 years ago

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?