-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
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); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
This LGTM, thanks! |
Awesome! |
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.