本文整理汇总了Java中com.firebase.ui.database.FirebaseRecyclerOptions类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseRecyclerOptions类的具体用法?Java FirebaseRecyclerOptions怎么用?Java FirebaseRecyclerOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseRecyclerOptions类属于com.firebase.ui.database包,在下文中一共展示了FirebaseRecyclerOptions类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: newAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的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
示例2: newAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的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
示例3: onCreateView
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_folder_list, container, false);
ButterKnife.bind(this, root);
FirebaseRecyclerOptions<Folder> options =
new FirebaseRecyclerOptions.Builder<Folder>()
.setQuery(mFirebaseDatabaseHelper.fetchFolders(mUserId)
.orderByChild("description"),
Folder.class)
.build();
mAdapter = new FolderListAdapter(options,mListener, getContext());
RecyclerView recyclerView = root.findViewById(R.id.folder_list_recycleview);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(mAdapter);
mBtnAddFolder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mListener.onClickAddFolderListInteraction();
}
});
return root;
}
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:30,代码来源:FolderListFragment.java
示例4: refresh
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
public void refresh(){
String sort = getResources()
.getStringArray(R.array.default_sorts_codes)[PrefUtils.getSortMode(getContext())];
FirebaseRecyclerOptions<Book> options =
new FirebaseRecyclerOptions.Builder<Book>()
.setQuery(FirebaseDatabaseHelper.getInstance()
.fetchBooksFromFolder(mUserId,mFolderId,sort),
Book.class)
.build();
setAdapterWithSort(options);
}
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:15,代码来源:BookGridFragment.java
示例5: BookGridAdapterFirebase
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
public BookGridAdapterFirebase(FirebaseRecyclerOptions<Book> options,
ILoading iLoading,
BookGridFragment.OnGridFragmentInteractionListener listener,
String folderId,
Integer menuId,
Context context) {
super(options);
mContext = context;
mLoading = iLoading;
mListener = listener;
mFolderId = folderId;
mMenuId = menuId;
}
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:15,代码来源:BookGridAdapterFirebase.java
示例6: FolderListAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
public FolderListAdapter(FirebaseRecyclerOptions<Folder> options,
OnListFragmentInteractionListener listener,
Context context) {
super(options);
mListener = listener;
mContext = context;
}
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:8,代码来源:FolderListAdapter.java
示例7: DeckRecyclerViewAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
/**
* Default constructor.
*
* @param user current user.
* @param activity activity that manages this RecyclerView.
* @param onDeckAction handler on recyclerview clicks.
*/
public DeckRecyclerViewAdapter(final User user, final LifecycleOwner activity,
final OnDeckAction onDeckAction) {
super(new FirebaseRecyclerOptions.Builder<Deck>()
.setQuery(user.getChildReference(Deck.class),
new FirebaseSnapshotParser<>(Deck.class, user))
.setLifecycleOwner(activity).build());
mOnDeckAction = onDeckAction;
}
开发者ID:dasfoo,项目名称:delern,代码行数:16,代码来源:DeckRecyclerViewAdapter.java
示例8: UserDeckAccessRecyclerViewAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
/**
* Constructor for Adapter. Adapter places information about users, that can
* use a deck.
*
* @param activity Activity that manages this RecyclerView.
* @param presenter presenter for performing operations.
*/
public UserDeckAccessRecyclerViewAdapter(final LifecycleOwner activity,
final ShareDeckActivityPresenter presenter) {
super(new FirebaseRecyclerOptions.Builder<DeckAccess>()
.setQuery(presenter.getReference(),
new FirebaseSnapshotParser<>(DeckAccess.class, presenter.getDeck()))
.setLifecycleOwner(activity).build());
this.mPresenter = presenter;
}
开发者ID:dasfoo,项目名称:delern,代码行数:16,代码来源:UserDeckAccessRecyclerViewAdapter.java
示例9: newAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
@Override
protected FirebaseRecyclerAdapter<Chat, ChatHolder> newAdapter() {
mChatIndicesRef = FirebaseDatabase.getInstance()
.getReference()
.child("chatIndices")
.child(FirebaseAuth.getInstance().getCurrentUser().getUid());
FirebaseRecyclerOptions<Chat> options =
new FirebaseRecyclerOptions.Builder<Chat>()
.setIndexedQuery(
mChatIndicesRef.limitToFirst(50), sChatQuery.getRef(), 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,代码行数:34,代码来源:RealtimeDbChatIndexActivity.java
示例10: onActivityCreated
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Set up Layout Manager, reverse layout
mManager = new LinearLayoutManager(getActivity());
mManager.setReverseLayout(true);
mManager.setStackFromEnd(true);
mRecycler.setLayoutManager(mManager);
// Set up FirebaseRecyclerAdapter with the Query
Query postsQuery = getQuery(mDatabase);
FirebaseRecyclerOptions options = new FirebaseRecyclerOptions.Builder<Post>()
.setQuery(postsQuery, Post.class)
.build();
mAdapter = new FirebaseRecyclerAdapter<Post, PostViewHolder>(options) {
@Override
public PostViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
return new PostViewHolder(inflater.inflate(R.layout.item_post, viewGroup, false));
}
@Override
protected void onBindViewHolder(PostViewHolder viewHolder, int position, final Post model) {
final DatabaseReference postRef = getRef(position);
// Set click listener for the whole post view
final String postKey = postRef.getKey();
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Launch PostDetailActivity
Intent intent = new Intent(getActivity(), PostDetailActivity.class);
intent.putExtra(PostDetailActivity.EXTRA_POST_KEY, postKey);
startActivity(intent);
}
});
// Determine if the current user has liked this post and set UI accordingly
if (model.stars.containsKey(getUid())) {
viewHolder.starView.setImageResource(R.drawable.ic_toggle_star_24);
} else {
viewHolder.starView.setImageResource(R.drawable.ic_toggle_star_outline_24);
}
// Bind Post to ViewHolder, setting OnClickListener for the star button
viewHolder.bindToPost(model, new View.OnClickListener() {
@Override
public void onClick(View starView) {
// Need to write to both places the post is stored
DatabaseReference globalPostRef = mDatabase.child("posts").child(postRef.getKey());
DatabaseReference userPostRef = mDatabase.child("user-posts").child(model.uid).child(postRef.getKey());
// Run two transactions
onStarClicked(globalPostRef);
onStarClicked(userPostRef);
}
});
}
};
mRecycler.setAdapter(mAdapter);
}
开发者ID:firebase,项目名称:quickstart-android,代码行数:66,代码来源:PostListFragment.java
示例11: setAdapterWithSort
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
private void setAdapterWithSort(FirebaseRecyclerOptions<Book> options){
mAdapter = new BookGridAdapterFirebase(options,this,mListener,mFolderId,mMenuId,getContext());
mRecyclerView.setAdapter(mAdapter);
int columnCount = getResources().getInteger(R.integer.list_column_count);
GridLayoutManager gridLayoutManager =
new GridLayoutManager(getContext(), columnCount);
mRecyclerView.setLayoutManager(gridLayoutManager);
mRecyclerView.setHasFixedSize(true);
mAdapter.startListening();
}
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:16,代码来源:BookGridFragment.java
示例12: CardRecyclerViewAdapter
import com.firebase.ui.database.FirebaseRecyclerOptions; //导入依赖的package包/类
/**
* Create a new FirebaseRecyclerAdapter.
*
* @param deck deck which cards to show.
* @param query reference to FB to cards of deck.
* @param listener listener to handle clicks on card.
*/
public CardRecyclerViewAdapter(final Deck deck, final Query query,
final OnCardViewHolderClick listener) {
super(new FirebaseRecyclerOptions.Builder<Card>()
.setQuery(query, new FirebaseSnapshotParser<>(Card.class, deck)).build());
this.mOnCardViewHolderClick = listener;
}
开发者ID:dasfoo,项目名称:delern,代码行数:14,代码来源:CardRecyclerViewAdapter.java
注:本文中的com.firebase.ui.database.FirebaseRecyclerOptions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论