Skip to content

Commit c22ee31

Browse files
committed
Added constructor that takes a Firebase reference
The fact that a Firebase reference is a subclass of Query is not obvious to a lot of people. To make it explicit that both types are acceptable, we now have an explicit constructor for each.
1 parent 64cb8a2 commit c22ee31

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import android.view.ViewGroup;
3434
import android.widget.BaseAdapter;
3535

36+
import com.firebase.client.Firebase;
3637
import com.firebase.client.Query;
3738

3839
/**
@@ -53,16 +54,16 @@ public abstract class FirebaseListAdapter<T> extends BaseAdapter {
5354

5455

5556
/**
56-
* @param modelClass Firebase will marshall the data at a location into an instance of a class that you provide
57-
* @param layout This is the mLayout used to represent a single list item. You will be responsible for populating an
58-
* instance of the corresponding view with the data from an instance of mModelClass.
5957
* @param activity The activity containing the ListView
60-
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location, using some
58+
* @param modelClass Firebase will marshall the data at a location into an instance of a class that you provide
59+
* @param modelLayout This is the layout used to represent a single list item. You will be responsible for populating an
60+
* instance of the corresponding view with the data from an instance of modelClass.
61+
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location, using some
6162
* combination of <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>,
6263
*/
63-
public FirebaseListAdapter(Class<T> modelClass, int layout, Activity activity, Query ref) {
64+
public FirebaseListAdapter(Activity activity, Class<T> modelClass, int modelLayout, Query ref) {
6465
mModelClass = modelClass;
65-
mLayout = layout;
66+
mLayout = modelLayout;
6667
mActivity = activity;
6768
mSnapshots = new FirebaseArray(ref);
6869
mSnapshots.setOnChangedListener(new FirebaseArray.OnChangedListener() {
@@ -72,6 +73,17 @@ public void onChanged(EventType type, int index, int oldIndex) {
7273
}
7374
});
7475
}
76+
/**
77+
* @param activity The activity containing the ListView
78+
* @param modelClass Firebase will marshall the data at a location into an instance of a class that you provide
79+
* @param modelLayout This is the layout used to represent a single list item. You will be responsible for populating an
80+
* instance of the corresponding view with the data from an instance of modelClass.
81+
* @param ref The Firebase location to watch for data changes. Can also be a slice of a location, using some
82+
* combination of <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>,
83+
*/
84+
public FirebaseListAdapter(Activity activity, Class<T> modelClass, int modelLayout, Firebase ref) {
85+
this(activity, modelClass, modelLayout, (Query)ref);
86+
}
7587

7688
public void cleanup() {
7789
// We're being destroyed, let go of our mListener and forget about all of the mModels

0 commit comments

Comments
 (0)