本文整理汇总了Java中com.firebase.client.DataSnapshot.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java DataSnapshot.getKey方法的具体用法?Java DataSnapshot.getKey怎么用?Java DataSnapshot.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.client.DataSnapshot
的用法示例。
在下文中一共展示了DataSnapshot.getKey方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onChildAdded
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
final String placeId=dataSnapshot.getKey();
if(placeId!=null)
{
Places.GeoDataApi
.getPlaceById(mGoogleApiClient,placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(@NonNull PlaceBuffer places) {
LatLng location=places.get(0).getLatLng();
//CharSequence userName=places.get(1).getName();
//Toast.makeText(getApplicationContext(),"reached onChildAdded",Toast.LENGTH_SHORT).show();
addPointToView(location);
mMap.addMarker(new MarkerOptions()
.position(location));
//Toast.makeText(getApplicationContext(),"place added",Toast.LENGTH_SHORT).show();
places.release();
}
});
}
}
示例2: onChildAdded
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) {
String key = dataSnapshot.getKey();
if (!mKeys.contains(key)) {
T item = dataSnapshot.getValue(FirebaseRecyclerAdapter.this.mItemClass);
int insertedPosition;
if (previousChildName == null) {
mItems.add(0, item);
mKeys.add(0, key);
insertedPosition = 0;
} else {
int previousIndex = mKeys.indexOf(previousChildName);
int nextIndex = previousIndex + 1;
if (nextIndex == mItems.size()) {
mItems.add(item);
mKeys.add(key);
} else {
mItems.add(nextIndex, item);
mKeys.add(nextIndex, key);
}
insertedPosition = nextIndex;
}
notifyItemInserted(insertedPosition);
itemAdded(item, key, insertedPosition);
}
}
示例3: onChildChanged
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
String key = dataSnapshot.getKey();
if (mKeys.contains(key)) {
int index = mKeys.indexOf(key);
T oldItem = mItems.get(index);
T newItem = dataSnapshot.getValue(FirebaseRecyclerAdapter.this.mItemClass);
mItems.set(index, newItem);
notifyItemChanged(index);
itemChanged(oldItem, newItem, key, index);
}
}
示例4: onChildRemoved
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
String key = dataSnapshot.getKey();
if (mKeys.contains(key)) {
int index = mKeys.indexOf(key);
T item = mItems.get(index);
mKeys.remove(index);
mItems.remove(index);
notifyItemRemoved(index);
itemRemoved(item, key, index);
}
}
示例5: onChildMoved
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) {
String key = dataSnapshot.getKey();
int index = mKeys.indexOf(key);
T item = dataSnapshot.getValue(FirebaseRecyclerAdapter.this.mItemClass);
mItems.remove(index);
mKeys.remove(index);
int newPosition;
if (previousChildName == null) {
mItems.add(0, item);
mKeys.add(0, key);
newPosition = 0;
} else {
int previousIndex = mKeys.indexOf(previousChildName);
int nextIndex = previousIndex + 1;
if (nextIndex == mItems.size()) {
mItems.add(item);
mKeys.add(key);
} else {
mItems.add(nextIndex, item);
mKeys.add(nextIndex, key);
}
newPosition = nextIndex;
}
notifyItemMoved(index, newPosition);
itemMoved(item, key, index, newPosition);
}
示例6: onChildAdded
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override public void onChildAdded(DataSnapshot dataSnapshot, String s) {
// Start Video download
Video video = dataSnapshot.getValue(Video.class);
String key = dataSnapshot.getKey();
if (!videoStorage.hasVideo(key)) {
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(video.getUrl()));
request.setVisibleInDownloadsUi(true);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
request.setDestinationInExternalFilesDir(context, null, dataSnapshot.getKey());
keyToDownloadIdMap.put(downloadManager.enqueue(request), key);
}
}
示例7: onChildChanged
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
String changedKey = dataSnapshot.getKey();
int changedIndex = keysArray.indexOf(changedKey);
String keyAndValue = "Name: " +dataSnapshot.getKey().toString() + "\t Email: " + dataSnapshot.getValue().toString();
displayArray.set(changedIndex,keyAndValue);
updateListView();
}
示例8: onChildRemoved
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
String deletedKey = dataSnapshot.getKey();
// int removedIndex = keysArray.indexOf(deletedKey);
// keysArray.remove(removedIndex);
// displayArray.remove(removedIndex);
// updateListView();
}