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


Java FirebaseRecyclerAdapter類代碼示例

本文整理匯總了Java中com.firebase.ui.database.FirebaseRecyclerAdapter的典型用法代碼示例。如果您正苦於以下問題:Java FirebaseRecyclerAdapter類的具體用法?Java FirebaseRecyclerAdapter怎麽用?Java FirebaseRecyclerAdapter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: newAdapter

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
protected RecyclerView.Adapter newAdapter() {
    FirebaseRecyclerOptions<Chat> options =
            new FirebaseRecyclerOptions.Builder<Chat>()
                    .setQuery(sChatQuery, Chat.class)
                    .setLifecycleOwner(this)
                    .build();

    return new FirebaseRecyclerAdapter<Chat, ChatHolder>(options) {
        @Override
        public ChatHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new ChatHolder(LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.message, parent, false));
        }

        @Override
        protected void onBindViewHolder(@NonNull ChatHolder holder, int position, @NonNull Chat model) {
            holder.bind(model);
        }

        @Override
        public void onDataChanged() {
            // If there are no chat messages, show a view that invites the user to add a message.
            mEmptyListMessage.setVisibility(getItemCount() == 0 ? View.VISIBLE : View.GONE);
        }
    };
}
 
開發者ID:firebase,項目名稱:FirebaseUI-Android,代碼行數:27,代碼來源:RealtimeDbChatActivity.java

示例2: newAdapter

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
protected RecyclerView.Adapter newAdapter() {
    FirebaseRecyclerOptions<Team> options =
            new FirebaseRecyclerOptions.Builder<Team>()
                    .setQuery(teamQuery, Team.class)
                    .setLifecycleOwner(this)
                    .build();

    return new FirebaseRecyclerAdapter<Team, TeamHolder>(options) {
        @Override
        public TeamHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new TeamHolder(LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.team_card_view, parent, false));
        }

        @Override
        protected void onBindViewHolder(TeamHolder holder, int position, Team model) {
            teamItems.add(model);
            holder.bind(model);
        }

        @Override
        public void onDataChanged() {
        }
    };
}
 
開發者ID:panzerama,項目名稱:Dispatch,代碼行數:26,代碼來源:DispatchTeamActivity.java

示例3: onStart

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
@Override
protected void onStart() {
    super.onStart();

    FirebaseRecyclerAdapter<Users, UsersViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Users, UsersViewHolder>(

            Users.class,
            R.layout.users_single_layout,
            UsersViewHolder.class,
            mUsersDatabase

    ) {
        @Override
        protected void populateViewHolder(UsersViewHolder usersViewHolder, Users users, int position) {

            usersViewHolder.setDisplayName(users.getName());
            usersViewHolder.setUserStatus(users.getStatus());
            usersViewHolder.setUserImage(users.getThumb_image(), getApplicationContext());

            final String user_id = getRef(position).getKey();

            usersViewHolder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    Intent profileIntent = new Intent(UsersActivity.this, ProfileActivity.class);
                    profileIntent.putExtra("user_id", user_id);
                    startActivity(profileIntent);

                }
            });

        }
    };


    mUsersList.setAdapter(firebaseRecyclerAdapter);

}
 
開發者ID:roy09,項目名稱:AyyMate-Android-RealtimeChat,代碼行數:40,代碼來源:UsersActivity.java

示例4: getFirebaseRecyclerAdapter

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
private FirebaseRecyclerAdapter<Post, PostViewHolder> getFirebaseRecyclerAdapter(Query query) {
        return new FirebaseRecyclerAdapter<Post, PostViewHolder>(
                Post.class, R.layout.post_item, PostViewHolder.class, query) {
            @Override
            public void populateViewHolder(final PostViewHolder postViewHolder,
                                           final Post post, final int position) {
                setupPost(postViewHolder, post, position, null);
            }

            @Override
            public void onViewRecycled(PostViewHolder holder) {
                super.onViewRecycled(holder);
//                FirebaseUtil.getLikesRef().child(holder.mPostKey).removeEventListener(holder.mLikeListener);
            }
        };
    }
 
開發者ID:firebase,項目名稱:friendlypix-android,代碼行數:17,代碼來源:PostsFragment.java

示例5: onDestroy

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
@Override
public void onDestroy() {
    super.onDestroy();
    if (mAdapter != null && mAdapter instanceof FirebaseRecyclerAdapter) {
        ((FirebaseRecyclerAdapter) mAdapter).cleanup();
    }
}
 
開發者ID:firebase,項目名稱:friendlypix-android,代碼行數:8,代碼來源:PostsFragment.java

示例6: loadMenu

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
private void loadMenu() {

        adapter=new FirebaseRecyclerAdapter<Category, MenuViewHolder>(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {
            @Override
            protected void populateViewHolder(MenuViewHolder viewHolder, Category model, int position) {
            viewHolder.txtMenuName.setText(model.getName());
                Picasso.with(getBaseContext()).load(model.getImage())
                        .into(viewHolder.imageView);
              final  Category clickItem =model;
                viewHolder.setItemClickListener(new ItemClickListener() {
                    @Override
                    public void onClick(View view, int position, boolean isLongClick) {
                        //Get CategoryId and send to new Activity
                        Intent foodList = new Intent(Home.this,FoodList.class);
                        //Because CategoryId is key, so we just get key of this item
                        foodList.putExtra("CategoryId",adapter.getRef(position).getKey());
                        startActivity(foodList);
                    }
                });
            }
        };
        recycler_menu.setAdapter(adapter);
    }
 
開發者ID:8155220,項目名稱:eatit,代碼行數:24,代碼來源:Home.java

示例7: get

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
public void get()
{
    databaseReference3.keepSynced(true);
    firebaseRecyclerAdapter3 = new FirebaseRecyclerAdapter<publish, BlogViewHolder>(
            publish.class,
            R.layout.framework,
            BlogViewHolder.class,
            databaseReference3
    ) {


        @Override
        protected void populateViewHolder(BlogViewHolder viewHolder, final publish model, int position) {
            viewHolder.setTitle(model.getTitle());
            viewHolder.setdesc(model.getDesc());
            viewHolder.setimg(getActivity().getApplicationContext(),model.getImage());
            viewHolder.setDate(model.getDate());
            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    startActivity(new Intent(getActivity(),activepost.class).putExtra("publish", model));

                }
            });

        }
    };
}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:30,代碼來源:Drishti.java

示例8: get

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
public void get() {
    databaseReference3.keepSynced(true);
    firebaseRecyclerAdapter3 = new FirebaseRecyclerAdapter<publish, BlogViewHolder>(
            publish.class,
            R.layout.framework,
            BlogViewHolder.class,
            databaseReference3
    ) {


        @Override
        protected void populateViewHolder(BlogViewHolder viewHolder, final publish model, int position) {

                    viewHolder.setTitle(model.getTitle());
                    viewHolder.setdesc(model.getDesc());
                    viewHolder.setimg(getActivity().getApplicationContext(), model.getImage());
                    viewHolder.setDate(model.getDate());

                    viewHolder.view.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {

                            startActivity(new Intent(getActivity(), activepost.class).putExtra("publish", model));

                        }
                    });


        }
    };
}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:32,代碼來源:Announcements.java

示例9: get

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
public void get()
{
    databaseReference3.keepSynced(true);
    firebaseRecyclerAdapter3 = new FirebaseRecyclerAdapter<publish, BlogViewHolder>(
            publish.class,
            R.layout.framework,
            BlogViewHolder.class,
            databaseReference3
    ) {


        @Override
        protected void populateViewHolder(BlogViewHolder viewHolder, final publish model, int position) {


            viewHolder.setTitle(model.getTitle());
            viewHolder.setdesc(model.getDesc());
            viewHolder.setimg(getActivity().getApplicationContext(),model.getImage());
            viewHolder.setDate(model.getDate());
            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    startActivity(new Intent(getActivity(),activepost.class).putExtra("publish", model));

                }
            });

        }
    };
}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:32,代碼來源:ACM.java

示例10: get

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
public void get()
{
    databaseReference3.keepSynced(true);
    firebaseRecyclerAdapter3 = new FirebaseRecyclerAdapter<publish, BlogViewHolder>(
            publish.class,
            R.layout.framework,
            BlogViewHolder.class,
            databaseReference3
    ) {


        @Override
        protected void populateViewHolder(BlogViewHolder viewHolder, final publish model, int position) {
            viewHolder.setTitle(model.getTitle());
            viewHolder.setdesc(model.getDesc());
            viewHolder.setimg(getActivity().getApplicationContext(),model.getImage());
            viewHolder.setDate(model.getDate());

            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    startActivity(new Intent(getActivity(),activepost.class).putExtra("publish", model));

                }
            });

        }
    };
}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:31,代碼來源:SAE.java

示例11: get

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
public void get()
{
    databaseReference42.keepSynced(true);
    firebaseRecyclerAdapter4 = new FirebaseRecyclerAdapter<publish, Announcements.BlogViewHolder>(
            publish.class,
            R.layout.framework,
            Announcements.BlogViewHolder.class,
            databaseReference42
    ) {


        @Override
        protected void populateViewHolder(Announcements.BlogViewHolder viewHolder, final publish model, int position) {

            viewHolder.setTitle(model.getTitle());
            viewHolder.setdesc(model.getDesc());
            viewHolder.setimg(getApplicationContext(), model.getImage());
            viewHolder.setDate(model.getDate());

            viewHolder.view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    startActivity(new Intent(Announcement.this, activepost.class).putExtra("publish", model));

                }
            });


        }
    };
}
 
開發者ID:khokharnikunj8,項目名稱:SVNITChapters,代碼行數:33,代碼來源:Announcement.java

示例12: onStart

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
@Override
    protected void onStart() {
        super.onStart();

        FirebaseRecyclerAdapter<Users, UsersViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Users, UsersViewHolder>(

                Users.class,
                R.layout.users_single_layout,
                UsersViewHolder.class,
                mUsersDatabase

        ) {
            @Override
            protected void populateViewHolder(UsersViewHolder usersViewHolder, Users users, int position) {

                usersViewHolder.setDisplayName(users.getName());
                usersViewHolder.setUserStatus(users.getStatus());
                usersViewHolder.setUserImage(users.getThumb_image(), getApplicationContext());

                final String user_id = getRef(position).getKey();

                usersViewHolder.mView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
//getSupportFragmentManager().beginTransaction().replace(R.id.users_appBar,new ProfileActivity()).commit();
                        Intent profileIntent = new Intent(UsersActivity.this, ProfileActivity.class);
                        profileIntent.putExtra("user_id", user_id);
                        startActivity(profileIntent);

                    }
                });

            }
        };


        mUsersList.setAdapter(firebaseRecyclerAdapter);

    }
 
開發者ID:IOSD,項目名稱:YFHR_Android_App,代碼行數:40,代碼來源:UsersActivity.java

示例13: onStart

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
@Override
public void onStart() {
	super.onStart();
	mAdapter = new FirebaseRecyclerAdapter<FirebaseBotsDataModel, Bot_VH>(
			FirebaseBotsDataModel.class, R.layout.view_bot_item, Bot_VH.class, databaseReference) {
		@Override
		protected void populateViewHolder(Bot_VH viewHolder, final FirebaseBotsDataModel model, int position) {
			viewHolder.setValues(model, getContext());
			viewHolder.setContentDescription(model, getContext());
			viewHolder.setClickListeners(model, FragmentBotList.this);
		}

		@Override
		protected void onDataChanged() {
			mEmptyView.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
		}

	};
	mRecyclerView.setAdapter(mAdapter);
}
 
開發者ID:arunrajora,項目名稱:Chit-Chat,代碼行數:21,代碼來源:FragmentBotList.java

示例14: onActivityCreated

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);


    mRecyclerview.setLayoutManager(mLayoutManager);
    mFireAdapter = new FirebaseRecyclerAdapter<Poll, PollHolder>(Poll.class, R.layout.latest_item, PollHolder.class, mPollsRef) {
        @Override
        protected void populateViewHolder(PollHolder viewHolder, Poll model, int position) {
            viewHolder.mPollQuestion.setText(model.getQuestion());
            //Picasso.with(getActivity().getApplicationContext())
            //        .load(model.getImage_URL())
            //        .fit()
            //        .into(viewHolder.mPollImage);
            Log.v("QUESTION", model.getQuestion());
            //Log.v("IMAGE", model.getImage_URL());
        }
    };
    mRecyclerview.setAdapter(mFireAdapter);

    mPollsRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot x : dataSnapshot.getChildren()){
                mFireAdapter.notifyItemInserted(0);
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });





}
 
開發者ID:eurosecom,項目名稱:Attendance,代碼行數:40,代碼來源:ContactFragment.java

示例15: createRestaurantRecyclerAdapter

import com.firebase.ui.database.FirebaseRecyclerAdapter; //導入依賴的package包/類
/**
 * Create Restaurant recycler adapter.
 * @param restaurantQuery
 */
private void createRestaurantRecyclerAdapter(final Query restaurantQuery)
{
    showProgressDialog();
    mAdapter = new FirebaseRecyclerAdapter<Restaurant, RestaurantViewHolder>(Restaurant.class, R.layout.item_restaurant,
            RestaurantViewHolder.class, restaurantQuery) {
        @Override
        protected void populateViewHolder(final RestaurantViewHolder viewHolder, final Restaurant model, final int position) {
            final DatabaseReference restaurantRef = getRef(position);

            // Set click listener for the whole post view
            final String restaurantKey = restaurantRef.getKey();
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    launchRestaurantDetailActivity(restaurantKey, model.getName());
                }
            });

            // Bind Post to ViewHolder, setting OnClickListener for the star button
            viewHolder.bindToRestaurant(MainActivity.this, model, getString(R.string.added_by), getString(R.string.none));
            String uri = model.getPhotoUri();
            setRestaurantItemPicture(viewHolder, uri);
        }
    };
    mRecycler.setAdapter(mAdapter);
}
 
開發者ID:JonathanBlood,項目名稱:Restaurant-Android-Application,代碼行數:31,代碼來源:MainActivity.java


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