Skip to content

Commit

Permalink
Initial Commit 02
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhenkar-KC committed Jun 13, 2021
1 parent 4614265 commit f8864ab
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 111 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

7 changes: 2 additions & 5 deletions app/src/main/java/com/example/pando/DetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -42,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
date_of_birth_Button = findViewById(R.id.Dateofbirth);
blood_pressure_Button = findViewById(R.id.blood_pressure);
database = FirebaseDatabase.getInstance();
myRef = database.getReference("UserHealthInfo");
myRef = database.getReference().child("UserHealthInfo");
userHealthInfoList = new ArrayList<>();


Expand Down Expand Up @@ -82,7 +79,7 @@ private void addUserHealthInfo() {
UserMap.put("BloodPressure", blood_pressure_string);
UserMap.put("DateOfBirth", date_of_birth_string);

myRef.child("UserHealthInfo").child("UserHealthInfo").updateChildren(UserMap).addOnSuccessListener(new OnSuccessListener() {
myRef.push().setValue(UserMap).addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Object o) {
//getting a unique id using push().getKey() method
Expand Down
53 changes: 44 additions & 9 deletions app/src/main/java/com/example/pando/InformationActivity.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,62 @@
package com.example.pando;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.database.annotations.NotNull;

import java.util.List;
import java.util.ArrayList;

public class InformationActivity extends AppCompatActivity {

private RecyclerView recyclerView;
FirebaseDatabase database;
DatabaseReference myRef;
private UserHealthInfoAdapter userHealthInfoAdapter;
private ArrayList<UserHealthInfo> UserHealthInfoList;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_information);


recyclerView = (RecyclerView) findViewById(R.id.recycledview);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));

UserHealthInfoList = new ArrayList<>();
userHealthInfoAdapter = new UserHealthInfoAdapter(this ,UserHealthInfoList );
recyclerView.setAdapter(userHealthInfoAdapter);



database = FirebaseDatabase.getInstance();
myRef = database.getReference().child("UserHealthInfo");
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NotNull DataSnapshot snapshot) {

for (DataSnapshot dataSnapshot : snapshot.getChildren()){
UserHealthInfo userHealthInfo = dataSnapshot.getValue(UserHealthInfo.class);
UserHealthInfoList.add(userHealthInfo);
}
userHealthInfoAdapter.notifyDataSetChanged();
}

@Override
public void onCancelled(@NotNull DatabaseError error) {

}
});
}
}
}
4 changes: 0 additions & 4 deletions app/src/main/java/com/example/pando/SignInActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ protected void onCreate(Bundle savedInstanceState) {

//Get Firebase auth instance
auth = FirebaseAuth.getInstance();




email_TV = (EditText) findViewById(R.id.emailTextView);
password_TV = (EditText) findViewById(R.id.passwordTextView);
register_button = (Button) findViewById(R.id.register_details);
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/com/example/pando/UserHealthInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ public class UserHealthInfo {
private String blood_pressure;


public UserHealthInfo(String username, String date_of_birth, String height, String weight, String last_period_date, String heart_rate, String blood_pressure) {
this.username = username;
this.blood_pressure = blood_pressure;
this.last_period_date = last_period_date;
this.date_of_birth = date_of_birth;
this.height = height;
this.heart_rate = heart_rate;
this.weight = weight;
public UserHealthInfo() {
}

public String getUsername() {
Expand Down
69 changes: 69 additions & 0 deletions app/src/main/java/com/example/pando/UserHealthInfoAdaptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.example.pando;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

class UserHealthInfoAdapter extends RecyclerView.Adapter<UserHealthInfoAdapter .UserHealthInfoViewHolder> {

ArrayList<UserHealthInfo> UserHealthInfoList;
Context context;

public UserHealthInfoAdapter (Context context , ArrayList<UserHealthInfo> UserHealthInfoList){

this.UserHealthInfoList = UserHealthInfoList;
this.context = context;
}

@NonNull
@Override
public UserHealthInfoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(context).inflate(R.layout.item , parent ,false);
return new UserHealthInfoViewHolder(v);

}

@Override
public void onBindViewHolder(@NonNull UserHealthInfoViewHolder holder, int position) {
UserHealthInfo userHealthInfo = UserHealthInfoList.get(position);
holder.Name.setText(userHealthInfo.getUsername());
holder.Age.setText(userHealthInfo.getDate_of_birth());
holder.LastPeriodDate.setText(userHealthInfo.getLast_period_date());
holder.Weight.setText(userHealthInfo.getWeight());
holder.Height.setText(userHealthInfo.getUsername());
holder.BloodPressure.setText(userHealthInfo.getBlood_pressure());
holder.HeartRate.setText(userHealthInfo.getHeart_rate());
holder.WarningPeriodDate.setText(userHealthInfo.getLast_period_date());
holder.UpcomingPeriodDate.setText(userHealthInfo.getLast_period_date());
}

@Override
public int getItemCount() {
return UserHealthInfoList.size();
}

public static class UserHealthInfoViewHolder extends RecyclerView.ViewHolder{

TextView Name,LastPeriodDate,UpcomingPeriodDate,WarningPeriodDate,Height,Weight,BloodPressure,HeartRate,Age;

public UserHealthInfoViewHolder(@NonNull View itemView) {
super(itemView);

Name = itemView.findViewById(R.id.usernameCardView);
LastPeriodDate = itemView.findViewById(R.id.last_period_dateCardView);
UpcomingPeriodDate = itemView.findViewById(R.id.upcomingPeriodDateCardView);
WarningPeriodDate = itemView.findViewById(R.id.warningPeriodDateCardView);
Height = itemView.findViewById(R.id.heightCardView);
Weight = itemView.findViewById(R.id.weightCardView);
BloodPressure = itemView.findViewById(R.id.blood_pressureCardView);
HeartRate = itemView.findViewById(R.id.heart_rateCardView);
Age = itemView.findViewById(R.id.ageCardView);
}
}
}
93 changes: 8 additions & 85 deletions app/src/main/res/layout/activity_main_information.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,92 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF53E0"
tools:context=".SignInActivity">
tools:context=".RegisterActivity">


<TextView
android:id="@+id/weight_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="24dp"
android:hint="Height"
android:selectAllOnFocus="true"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycledview"
android:layout_width="409dp"
android:layout_height="729dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/age_info" />

<TextView
android:id="@+id/warning_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:hint="Warning Period Date"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/upcoming_period_info" />

<TextView
android:id="@+id/name_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="316dp"
android:layout_marginEnd="24dp"
android:hint="Name"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/age_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="24dp"
android:hint="Age"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/name_info" />

<TextView
android:id="@+id/upcoming_period_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="24dp"
android:hint="Upcoming Period Date"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/last_period_date_info" />

<TextView
android:id="@+id/last_period_date_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:hint="Last Period Date"
android:selectAllOnFocus="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/weight_info" />


</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit f8864ab

Please sign in to comment.