Created
December 5, 2020 07:49
-
-
Save ns-github14/a9e74bc066ce743f8b162d20c2181ac1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private RecyclerView recyclerView; | |
RVAdapter adapter; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
base = FirebaseFirestore.getInstance().collection("Doctors"); | |
recyclerView = findViewById(R.id.rv); | |
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | |
FirestoreRecyclerOptions<Doctor_Class> options = new FirestoreRecyclerOptions.Builder<Doctor_Class>().setQuery(base, Doctor_Class.class).build(); | |
adapter = new RVAdapter(options); | |
recyclerView.setAdapter(adapter); | |
} | |
// Function to tell the app to start getting | |
// data from database on starting of the activity | |
@Override protected void onStart() | |
{ | |
super.onStart(); | |
adapter.startListening(); | |
} | |
// Function to tell the app to stop getting | |
// data from database on stoping of the activity | |
@Override protected void onStop() | |
{ | |
super.onStop(); | |
adapter.stopListening(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment