Skip to content

Fix small mistakes in FirebaseIndexArray #412

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

Merged
merged 2 commits into from
Nov 21, 2016
Merged

Fix small mistakes in FirebaseIndexArray #412

merged 2 commits into from
Nov 21, 2016

Conversation

SUPERCILEX
Copy link
Collaborator

Hi @samtstern, while working on #411, I noticed a few things that slipped past me so this is a super small PR to fix them.

index++;
}
}
return index;
}

private boolean isMatch(int index, String key) {
return index >= 0 && index < getCount() && getItem(index).getKey().equals(key);
return index >= 0 && index < getCount() && mDataSnapshots.get(index).getKey().equals(key);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have never used getItem() here because it's public api and anyone overriding that method will break our implementation.

if (isMatch(index, key)) {
mDataSnapshots.remove(index);
notifyChangedListeners(OnChangedListener.EventType.REMOVED, index);
} else {
Log.w(TAG, "Key not found at ref: " + snapshot.getRef());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only log the warning if the data wasn't in our list. Example: if people delete the data ref before the index ref, the warning would have been shown which is kinda pointless.

@@ -41,7 +42,7 @@
*/
public FirebaseIndexListAdapter(Activity activity,
Class<T> modelClass,
int modelLayout,
@LayoutRes int modelLayout,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also just noticed that we never had an @Res annotation on our layouts so I added that too.

@samtstern
Copy link
Contributor

This LGTM, thanks!

@samtstern samtstern merged commit edd3fe5 into firebase:master Nov 21, 2016
@samtstern samtstern added this to the 1.1.0 milestone Nov 21, 2016
@SUPERCILEX SUPERCILEX deleted the patch-1 branch November 21, 2016 17:52
@SUPERCILEX
Copy link
Collaborator Author

Awesome!

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

Successfully merging this pull request may close these issues.

2 participants