Skip to content

Database style cleanup #336

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
Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
class FirebaseArray implements ChildEventListener {
public interface OnChangedListener {
enum EventType { Added, Changed, Removed, Moved }
enum EventType {ADDED, CHANGED, REMOVED, MOVED}
void onChanged(EventType type, int index, int oldIndex);
void onCancelled(DatabaseError databaseError);
}
Expand Down Expand Up @@ -72,27 +72,27 @@ public void onChildAdded(DataSnapshot snapshot, String previousChildKey) {
index = getIndexForKey(previousChildKey) + 1;
}
mSnapshots.add(index, snapshot);
notifyChangedListeners(OnChangedListener.EventType.Added, index);
notifyChangedListeners(OnChangedListener.EventType.ADDED, index);
}

public void onChildChanged(DataSnapshot snapshot, String previousChildKey) {
int index = getIndexForKey(snapshot.getKey());
mSnapshots.set(index, snapshot);
notifyChangedListeners(OnChangedListener.EventType.Changed, index);
notifyChangedListeners(OnChangedListener.EventType.CHANGED, index);
}

public void onChildRemoved(DataSnapshot snapshot) {
int index = getIndexForKey(snapshot.getKey());
mSnapshots.remove(index);
notifyChangedListeners(OnChangedListener.EventType.Removed, index);
notifyChangedListeners(OnChangedListener.EventType.REMOVED, index);
}

public void onChildMoved(DataSnapshot snapshot, String previousChildKey) {
int oldIndex = getIndexForKey(snapshot.getKey());
mSnapshots.remove(oldIndex);
int newIndex = previousChildKey == null ? 0 : (getIndexForKey(previousChildKey) + 1);
mSnapshots.add(newIndex, snapshot);
notifyChangedListeners(OnChangedListener.EventType.Moved, newIndex, oldIndex);
notifyChangedListeners(OnChangedListener.EventType.MOVED, newIndex, oldIndex);
}

public void onCancelled(DatabaseError databaseError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ public FirebaseRecyclerAdapter(Class<T> modelClass, int modelLayout, Class<VH> v
@Override
public void onChanged(EventType type, int index, int oldIndex) {
switch (type) {
case Added:
case ADDED:
notifyItemInserted(index);
break;
case Changed:
case CHANGED:
notifyItemChanged(index);
break;
case Removed:
case REMOVED:
notifyItemRemoved(index);
break;
case Moved:
case MOVED:
notifyItemMoved(oldIndex, index);
break;
default:
Expand Down