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


Java DataSnapshot.getKey方法代码示例

本文整理汇总了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();
                    }
                });
    }

}
 
开发者ID:agarwal-akash,项目名称:BonAppetit_Android-Project,代码行数:25,代码来源:MapsActivity.java

示例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);
    }
}
 
开发者ID:benslamajihed,项目名称:GalleryPictureFirebaseAndroid,代码行数:28,代码来源:FirebaseRecyclerAdapter.java

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

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

示例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);
}
 
开发者ID:benslamajihed,项目名称:GalleryPictureFirebaseAndroid,代码行数:29,代码来源:FirebaseRecyclerAdapter.java

示例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);
  }
}
 
开发者ID:Eric-Gonzalez,项目名称:marclay,代码行数:14,代码来源:MediaDispatcher.java

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

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


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