当前位置: 首页>>代码示例>>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;未经允许,请勿转载。