Skip to content

comments added with description #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

19 changes: 13 additions & 6 deletions app/src/main/java/com/harpreet/notes_app/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public class HomeActivity extends AppCompatActivity {
private FloatingActionButton fab;
private RecyclerView recyclerView;

private FirebaseRecyclerAdapter<Data,Myviewholder> adapter;
private FirebaseRecyclerAdapter<Data,Myviewholder> adapter; //These lines declare various variables used within the HomeActivity class, including references to UI
// elements (toolbar, floating action button, and recycler view), an adapter for
// the recycler view, instances of Firebase-related classes (FirebaseAuth and DatabaseReference),
// and other variables to store data.
private FirebaseAuth mauth;
private DatabaseReference mDatabase;

Expand Down Expand Up @@ -80,7 +83,7 @@ public void onClick(View v) {


}
private void addData()
private void addData() //This method is responsible for displaying an AlertDialog that allows the user to input data (name and description) for a new note.
{
AlertDialog.Builder mydialog = new AlertDialog.Builder(this);
LayoutInflater inflater = LayoutInflater.from(this);
Expand Down Expand Up @@ -134,7 +137,7 @@ public void onClick(View v) {


@Override
protected void onStart() {
protected void onStart() { //It sets up the FirebaseRecyclerAdapter for displaying the notes in the RecyclerView and starts listening for changes in the data.
super.onStart();

Query query = FirebaseDatabase.getInstance().getReference().child("All data").child(mauth.getUid());
Expand Down Expand Up @@ -181,13 +184,15 @@ public void onClick(View v) {
}

@Override
protected void onStop() {
protected void onStop() { //This method is called when the activity is stopped. It stops the FirebaseRecyclerAdapter from listening to changes in the data.
super.onStop();
adapter.stopListening();

}

public static class Myviewholder extends RecyclerView.ViewHolder{
public static class Myviewholder extends RecyclerView.ViewHolder{ //This is a static inner class that defines a
// custom RecyclerView.ViewHolder for the notes. It holds references
// to the UI elements within each item of the RecyclerView.

View mView;

Expand All @@ -213,7 +218,9 @@ public void setDate(String date)

}

public void updateData()
public void updateData() //
// The updateData() method is responsible for displaying an AlertDialog that allows the user to update the
// selected note's data or delete the note. Here's a breakdown of what the method does:

{

Expand Down
7 changes: 6 additions & 1 deletion app/src/main/java/com/harpreet/notes_app/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize views
email = findViewById(R.id.email);
password = findViewById(R.id.password);
btnsignin = findViewById(R.id.signin);
btnsignup = findViewById(R.id.signup);
// Initialize FirebaseAuth instance
mAuth = FirebaseAuth.getInstance();
// Initialize ProgressDialog
progressd = new ProgressDialog(MainActivity.this);

// Check if the user is already signed in, if yes, redirect to HomeActivity
if (mAuth.getCurrentUser()!=null)
{
startActivity(new Intent(getApplicationContext(),HomeActivity.class));
Expand All @@ -58,6 +62,7 @@ public void onClick(View v) {

progressd.setMessage("Processing");
progressd.show();
// Sign in with email and password using FirebaseAuth
mAuth.signInWithEmailAndPassword(mEmail,mPass).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Expand All @@ -76,7 +81,7 @@ public void onComplete(@NonNull Task<AuthResult> task) {

}
});

// Set click listener for sign-up button
btnsignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void onClick(View v) {
}
});
*/
// Set click listener for sign-up button
signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -61,6 +62,8 @@ public void onClick(View v) {
pass.setError("RequiredField..");
return;
}
// Show progress dialog while processing sign-up request

pddia.setMessage("Processing");
pddia.show();
mAuth.createUserWithEmailAndPassword(mEmail,mPass).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
Expand Down