I have an android applucation. I want to create a payment transaction history in this app. I have create a payment transaction activity and try to retrieve transaction history in a recyclerview. Its working now.
But the issue is the recycler view show the transaction history of all users. I want to show the transaction history in to current user. That means when will I open my transaction history activity I want to see only my transaction history. Now I can see all users transaction history. How I get only my transaction history in my profile. Sorry for my bad english.
This is my code
MCC= FirebaseDatabase.getInstance().getReference().child("PAYTMWITHDRAWAL");
recyclerView = (RecyclerView) findViewById(R.id.aswam_recyclerView);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(new GridLayoutManager(this, 1));
LoadData(categoryId);
}
private void LoadData(String categoryId) {
options = new FirebaseRecyclerOptions.Builder<PayoutHistoryModel>().setQuery(MCC,PayoutHistoryModel.class).build();
adapter = new FirebaseRecyclerAdapter<PayoutHistoryModel, PayoutHistoryViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull PayoutHistoryViewHolder payoutHistoryViewHolder, int i, @NonNull PayoutHistoryModel trollModel) {
payoutHistoryViewHolder.thrillername.setText(trollModel.getPayoutStatus());
Picasso.get().load(trollModel.getImage())
.into(payoutHistoryViewHolder.thrillersimage);
}
@NonNull
@Override
public PayoutHistoryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.payout_histoy_layout, parent, false);
return new PayoutHistoryViewHolder(v);
}
};
adapter.startListening();
recyclerView.setAdapter(adapter);
If you have the UID
of the user in each transaction, you can use a query to order/filter the data.
For example, if each transaction has a ownerUID
property you could do something like this:
private void LoadData(String categoryId) {
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
Query query = MCC.orderByChild("ownerUID").equalTo(uid); // 👈
options = new FirebaseRecyclerOptions.Builder<PayoutHistoryModel>()
.setQuery(query,PayoutHistoryModel.class).build();
// 👆
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.