當前位置: 首頁>>代碼示例>>Java>>正文


Java DatabaseReference.addChildEventListener方法代碼示例

本文整理匯總了Java中com.google.firebase.database.DatabaseReference.addChildEventListener方法的典型用法代碼示例。如果您正苦於以下問題:Java DatabaseReference.addChildEventListener方法的具體用法?Java DatabaseReference.addChildEventListener怎麽用?Java DatabaseReference.addChildEventListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.firebase.database.DatabaseReference的用法示例。


在下文中一共展示了DatabaseReference.addChildEventListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateView

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);

    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        if (mColumnCount <= 1) {
            recyclerView.setLayoutManager(new LinearLayoutManager(context));
        } else {
            recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
        }
        adapter = new JournalAdapter(allTrips, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:26,代碼來源:JournalFragment.java

示例2: onCreateView

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_journal_list, container, false);
    Bundle data = getArguments();
    int cellLayout = data.getInt(ARG_LAYOUT);
    // Set the adapter
    if (view instanceof RecyclerView) {
        FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
        FirebaseAuth auth = FirebaseAuth.getInstance();
        FirebaseUser user = auth.getCurrentUser();
        DatabaseReference userRef = dbRef.getReference(user.getUid());
        userRef.addChildEventListener (chEvListener);
        userRef.addValueEventListener(valEvListener);
        Context context = view.getContext();
        RecyclerView recyclerView = (RecyclerView) view;
        recyclerView.setLayoutManager(new LinearLayoutManager(context));
        adapter = new JournalAdapter(selectedTrips, cellLayout, mListener);
        recyclerView.setAdapter(adapter);
    }
    return view;
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:23,代碼來源:JournalFragment.java

示例3: threadUsersAddedOn

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public void threadUsersAddedOn(String threadId){
    // Check if handled.
    if (handledAddedUsersToThreadIDs.contains(threadId))
        return;

    handledAddedUsersToThreadIDs.add(threadId);

    // Also listen to the thread users
    // This will allow us to update the users in the database
    DatabaseReference threadUsers = FirebasePaths.threadRef(threadId).child(BFirebaseDefines.Path.BUsersPath);

    UserAddedListener userAddedToThreadListener= UserAddedListener.getNewInstance(observedUserEntityID, threadId, handlerUserAdded);

    FirebaseEventCombo combo = getCombo(USER_PREFIX + threadId, threadUsers.toString(), userAddedToThreadListener);

    threadUsers.addChildEventListener(combo.getListener());
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:18,代碼來源:FirebaseEventsManager.java

示例4: attachFetchFolders

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public void attachFetchFolders(String userId, ChildEventListener listener) {
    DatabaseReference ref = mDatabaseReference.child(userId).child(REF_FOLDERS);
    ref.addChildEventListener(listener);
}
 
開發者ID:victoraldir,項目名稱:BuddyBook,代碼行數:5,代碼來源:FirebaseDatabaseHelper.java

示例5: onNewLikeAddedListener

import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public void onNewLikeAddedListener(ChildEventListener childEventListener) {
    DatabaseReference mLikesReference = database.getReference().child("post-likes");
    mLikesReference.addChildEventListener(childEventListener);
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:5,代碼來源:DatabaseHelper.java


注:本文中的com.google.firebase.database.DatabaseReference.addChildEventListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。