Skip to content

Commit edd3fe5

Browse files
SUPERCILEXsamtstern
authored andcommitted
Fix small mistakes in FirebaseIndexArray (#412)
* Fix small mistakes * Add @LayoutRes
1 parent 42fa51c commit edd3fe5

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

database/src/main/java/com/firebase/ui/database/FirebaseIndexArray.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ private int getIndexForKey(String key) {
6767
String superKey = super.getItem(keyIndex).getKey();
6868
if (key.equals(superKey)) {
6969
break;
70-
} else if (getItem(index).getKey().equals(superKey)) {
70+
} else if (mDataSnapshots.get(index).getKey().equals(superKey)) {
7171
index++;
7272
}
7373
}
7474
return index;
7575
}
7676

7777
private boolean isMatch(int index, String key) {
78-
return index >= 0 && index < getCount() && getItem(index).getKey().equals(key);
78+
return index >= 0 && index < getCount() && mDataSnapshots.get(index).getKey().equals(key);
7979
}
8080

8181
@Override
@@ -155,10 +155,11 @@ public void onDataChange(DataSnapshot snapshot) {
155155
notifyChangedListeners(OnChangedListener.EventType.CHANGED, index);
156156
}
157157
} else {
158-
Log.w(TAG, "Key not found at ref: " + snapshot.getRef());
159158
if (isMatch(index, key)) {
160159
mDataSnapshots.remove(index);
161160
notifyChangedListeners(OnChangedListener.EventType.REMOVED, index);
161+
} else {
162+
Log.w(TAG, "Key not found at ref: " + snapshot.getRef());
162163
}
163164
}
164165
}

database/src/main/java/com/firebase/ui/database/FirebaseIndexListAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.firebase.ui.database;
22

33
import android.app.Activity;
4+
import android.support.annotation.LayoutRes;
45

56
import com.google.firebase.database.Query;
67

@@ -41,7 +42,7 @@ public abstract class FirebaseIndexListAdapter<T> extends FirebaseListAdapter<T>
4142
*/
4243
public FirebaseIndexListAdapter(Activity activity,
4344
Class<T> modelClass,
44-
int modelLayout,
45+
@LayoutRes int modelLayout,
4546
Query keyRef,
4647
Query dataRef) {
4748
super(activity, modelClass, modelLayout, new FirebaseIndexArray(keyRef, dataRef));

database/src/main/java/com/firebase/ui/database/FirebaseIndexRecyclerAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.firebase.ui.database;
1616

17+
import android.support.annotation.LayoutRes;
1718
import android.support.v7.widget.RecyclerView;
1819

1920
import com.google.firebase.database.Query;
@@ -70,7 +71,7 @@ public abstract class FirebaseIndexRecyclerAdapter<T, VH extends RecyclerView.Vi
7071
* Each key key found at {@code keyRef}'s location represents a list item in the {@code RecyclerView}.
7172
*/
7273
public FirebaseIndexRecyclerAdapter(Class<T> modelClass,
73-
int modelLayout,
74+
@LayoutRes int modelLayout,
7475
Class<VH> viewHolderClass,
7576
Query keyRef,
7677
Query dataRef) {

database/src/main/java/com/firebase/ui/database/FirebaseListAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.firebase.ui.database;
1616

1717
import android.app.Activity;
18+
import android.support.annotation.LayoutRes;
1819
import android.util.Log;
1920
import android.view.View;
2021
import android.view.ViewGroup;
@@ -57,7 +58,7 @@ public abstract class FirebaseListAdapter<T> extends BaseAdapter {
5758

5859
FirebaseListAdapter(Activity activity,
5960
Class<T> modelClass,
60-
int modelLayout,
61+
@LayoutRes int modelLayout,
6162
FirebaseArray snapshots) {
6263
mModelClass = modelClass;
6364
mLayout = modelLayout;

database/src/main/java/com/firebase/ui/database/FirebaseRecyclerAdapter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.firebase.ui.database;
1616

17+
import android.support.annotation.LayoutRes;
1718
import android.support.v7.widget.RecyclerView;
1819
import android.util.Log;
1920
import android.view.LayoutInflater;
@@ -76,7 +77,7 @@ public abstract class FirebaseRecyclerAdapter<T, VH extends RecyclerView.ViewHol
7677
FirebaseArray mSnapshots;
7778

7879
FirebaseRecyclerAdapter(Class<T> modelClass,
79-
int modelLayout,
80+
@LayoutRes int modelLayout,
8081
Class<VH> viewHolderClass,
8182
FirebaseArray snapshots) {
8283
mModelClass = modelClass;

0 commit comments

Comments
 (0)