當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。