-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4614265
commit f8864ab
Showing
8 changed files
with
333 additions
and
111 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
53 changes: 44 additions & 9 deletions
53
app/src/main/java/com/example/pando/InformationActivity.java
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
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) { | ||
|
||
} | ||
}); | ||
} | ||
} | ||
} |
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
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
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/example/pando/UserHealthInfoAdaptor.java
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
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); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.