Commit 522316cb authored by Chathura IT19243986's avatar Chathura IT19243986

Upload New File

parent 0856a0b7
package com.example.peopluz1.fragments;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.peopluz1.Adapters.NotificationsAdapter;
import com.example.peopluz1.R;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentSnapshot;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QuerySnapshot;
import java.util.ArrayList;
import java.util.List;
public class Notification extends Fragment {
private FirebaseFirestore db;
FirebaseAuth auth;
public RecyclerView mRecycleView;
public NotificationsAdapter mAdapter;
public RecyclerView.LayoutManager mManager;
ArrayList<Notification> list = new ArrayList<>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
db = FirebaseFirestore.getInstance();
return inflater.inflate(R.layout.fragment_notification, container, false);
}
public void getNotifications(){
db.collection("users").document(auth.getCurrentUser().getUid())
.collection("trip").get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if(!queryDocumentSnapshots.isEmpty()){
List<DocumentSnapshot> clist = queryDocumentSnapshots.getDocuments();
for(DocumentSnapshot d : clist){
Notification p = d.toObject(Notification.class);
list.add(p);
}
mAdapter.notifyDataSetChanged();
}
}
});
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment