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