本文整理汇总了Java中com.google.firebase.database.DataSnapshot.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java DataSnapshot.getKey方法的具体用法?Java DataSnapshot.getKey怎么用?Java DataSnapshot.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.database.DataSnapshot
的用法示例。
在下文中一共展示了DataSnapshot.getKey方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChildMoved
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildMoved(DataSnapshot keySnapshot, String previousChildKey) {
String key = keySnapshot.getKey();
int oldIndex = getIndexForKey(key);
super.setOnChangedListener(null);
super.onChildMoved(keySnapshot, previousChildKey);
super.setOnChangedListener(mListener);
if (isKeyAtIndex(key, oldIndex)) {
DataSnapshot snapshot = mDataSnapshots.remove(oldIndex);
int newIndex = getIndexForKey(key);
mDataSnapshots.add(newIndex, snapshot);
notifyChangedListeners(ChangeEventListener.EventType.MOVED, newIndex, oldIndex);
}
}
示例2: onDataChange
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onDataChange(DataSnapshot snapshot) {
String key = snapshot.getKey();
int index = getIndexForKey(key);
if (snapshot.getValue() != null) {
if (!isKeyAtIndex(key, index)) {
mDataSnapshots.add(index, snapshot);
notifyChangedListeners(ChangeEventListener.EventType.ADDED, index);
} else {
mDataSnapshots.set(index, snapshot);
notifyChangedListeners(ChangeEventListener.EventType.CHANGED, index);
}
} else {
if (isKeyAtIndex(key, index)) {
mDataSnapshots.remove(index);
notifyChangedListeners(ChangeEventListener.EventType.REMOVED, index);
} else {
Log.w(TAG, "Key not found at ref: " + snapshot.getRef());
}
}
}
示例3: BMessageWrapper
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
public BMessageWrapper(BThread thread, DataSnapshot snapshot){
this.model = DaoCore.fetchOrCreateEntityWithEntityID(BMessage.class, snapshot.getKey());
this.getModel().setThread(thread);
this.entityId = snapshot.getKey();
deserialize(snapshot);
}
示例4: apply
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public RxFirebaseChildEvent<U> apply(final RxFirebaseChildEvent<DataSnapshot> rxFirebaseChildEvent) {
DataSnapshot dataSnapshot = rxFirebaseChildEvent.getValue();
if (dataSnapshot.exists()) {
return new RxFirebaseChildEvent<U>(
dataSnapshot.getKey(),
getDataSnapshotTypedValue(dataSnapshot, clazz),
rxFirebaseChildEvent.getPreviousChildName(),
rxFirebaseChildEvent.getEventType());
} else {
throw Exceptions.propagate(new RuntimeException("child dataSnapshot doesn't exist"));
}
}
示例5: onChildChanged
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String
prevKey) {
String key = dataSnapshot.getKey();
for (int k = 0; k < allTrips.size(); k++) {
if (allTrips.get(k).getKey().equals(key)) {
allTrips.set(k, dataSnapshot.getValue(Trip.class));
break;
}
}
}
示例6: onChildChanged
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String
prevKey) {
String key = dataSnapshot.getKey();
for (int k = 0; k < allTrips.size(); k++) {
if (allTrips.get(k).getKey().equals(key)) {
allTrips.set(k, dataSnapshot.getValue(Trip.class));
break;
}
}
adapter.notifyDataSetChanged();
}
示例7: onChildRemoved
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildRemoved(DataSnapshot keySnapshot) {
String key = keySnapshot.getKey();
int index = getIndexForKey(key);
mQuery.getRef().child(key).removeEventListener(mRefs.remove(mQuery.getRef().child(key)));
super.setOnChangedListener(null);
super.onChildRemoved(keySnapshot);
super.setOnChangedListener(mListener);
if (isKeyAtIndex(key, index)) {
mDataSnapshots.remove(index);
notifyChangedListeners(ChangeEventListener.EventType.REMOVED, index);
}
}
示例8: getInterestString
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
public String getInterestString(DataSnapshot dataSnapshot) {
String interests = "";
// Format the user's interests
for ( DataSnapshot child : dataSnapshot.getChildren() ) {
String interest = child.getKey();
interests += interest;
interests += "\n\n";
for ( DataSnapshot subchild : child.getChildren() ) {
String subcategory = subchild.getKey();
String preference = (String) subchild.getValue();
int newLinePos = 22;
//interests += "◇ ";
interests += " ";
interests += addStrAtPos( subcategory, "\n ", newLinePos );
interests += " - ";
interests += addStrAtPos( preference, "\n ", newLinePos );
interests += "\n";
}
interests += "\n";
}
return interests;
}
示例9: fromSnapshot
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
public static ShoppingListItem fromSnapshot(DataSnapshot snapshot) {
ShoppingListItem item = snapshot.getValue(ShoppingListItem.class);
item.key = snapshot.getKey();
return item;
}
示例10: onChildAdded
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Trip entry = (Trip) dataSnapshot.getValue(Trip.class);
entry._key = dataSnapshot.getKey();
allTrips.add(entry);
}
示例11: initializeFromDataSnapshot
import com.google.firebase.database.DataSnapshot; //导入方法依赖的package包/类
/**
* Parses the DataSnapshot and initializes the CurrentUser from those fields
* @param dataSnapshot snapshot of data to initialize CurrentUser from
*/
public void initializeFromDataSnapshot(DataSnapshot dataSnapshot) {
for ( DataSnapshot field : dataSnapshot.getChildren() ) {
switch (field.getKey()) {
case "email":
setEmail((String) field.getValue());
break;
case "uid":
setUid((String) field.getValue());
break;
case "firstName":
setFirstName((String) field.getValue());
break;
case "middleName":
setFirstName((String) field.getValue());
break;
case "lastName":
setFirstName((String) field.getValue());
break;
case "dob":
setDob((String) field.getValue());
break;
case "gender":
setGender((String) field.getValue());
break;
case "city":
setFirstName((String) field.getValue());
break;
case "state":
setFirstName((String) field.getValue());
break;
case "country":
setFirstName((String) field.getValue());
break;
case "bio":
setBio((String) field.getValue());
break;
case "latitude":
long num = (long) field.getValue();
setLatitude(0.0);
if (field.getValue() != null) {
setLatitude((double) num);
}
break;
case "longitude":
num = (long) field.getValue();
setLatitude(0.0);
if (field.getValue() != null) {
setLongitude((double) num);
}
break;
case "locked":
setLocked((boolean) field.getValue());
break;
case "suspended":
setSuspended((boolean) field.getValue());
break;
default:
break;
}
}
}