当前位置: 首页>>代码示例>>Java>>正文


Java DataSnapshot.getKey方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:17,代码来源:FirebaseIndexArray.java

示例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());
        }
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:23,代码来源:FirebaseIndexArray.java

示例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);
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:8,代码来源:BMessageWrapper.java

示例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"));
   }
}
 
开发者ID:DVT,项目名称:showcase-android,代码行数:14,代码来源:DataSnapshotMapper.java

示例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;
        }
    }
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:12,代码来源:JournalLoaderFragment.java

示例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();
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:13,代码来源:JournalFragment.java

示例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);
    }
}
 
开发者ID:rumaan,项目名称:AcademApp,代码行数:16,代码来源:FirebaseIndexArray.java

示例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;
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:28,代码来源:InterestStringBuilder.java

示例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;
}
 
开发者ID:david-szabo97,项目名称:Android-Open-Shopping-List,代码行数:7,代码来源:ShoppingListItem.java

示例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);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:7,代码来源:JournalFragment.java

示例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;
        }
    }
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:66,代码来源:CurrentUser.java


注:本文中的com.google.firebase.database.DataSnapshot.getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。