本文整理匯總了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;
}
示例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;
}
示例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());
}
示例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);
}
示例5: onNewLikeAddedListener
import com.google.firebase.database.DatabaseReference; //導入方法依賴的package包/類
public void onNewLikeAddedListener(ChildEventListener childEventListener) {
DatabaseReference mLikesReference = database.getReference().child("post-likes");
mLikesReference.addChildEventListener(childEventListener);
}