Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/java/com/ensias/healthcareapp/DoctorHomeActivity.java
#	app/src/main/java/com/ensias/healthcareapp/EditProfileDoctorActivity.java
#	app/src/main/java/com/ensias/healthcareapp/HomeActivity.java
  • Loading branch information
ilyasstrh committed Jun 3, 2020
2 parents 2c27d4c + 460320b commit a62a990
Show file tree
Hide file tree
Showing 26 changed files with 623 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Common {
public static final String KEY_CONFIRM_BOOKING = "CONFIRM_BOOKING" ;
public static String CurrentUserid ;
public static String CurrentUserName;

public static String CurrentUserType = "patient";
public static int step = 0;
public static String CurreentDoctor = "[email protected]";
public static String Currentaappointementatype;
Expand Down
181 changes: 181 additions & 0 deletions app/src/main/java/com/ensias/healthcareapp/DoctorAdapterFiltred.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
package com.ensias.healthcareapp;

import android.content.ClipData;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;

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

import com.ensias.healthcareapp.Common.Common;
import com.ensias.healthcareapp.model.Doctor;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.CollectionReference;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DoctorAdapterFiltred extends RecyclerView.Adapter<DoctorAdapterFiltred.DoctoreHolder2> implements Filterable {
public static boolean specialiteSearch = false;
static String doc;
static FirebaseFirestore db = FirebaseFirestore.getInstance();
static CollectionReference addRequest = db.collection("Request");
private List<Doctor> mTubeList;
private List<Doctor> mTubeListFiltered;
StorageReference pathReference ;


public DoctorAdapterFiltred(List<Doctor> tubeList){
mTubeList = tubeList;
mTubeListFiltered = tubeList;
}

@NonNull
@Override
public DoctoreHolder2 onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.doctor_item,
parent, false);
return new DoctoreHolder2(v);
}

@Override
public void onBindViewHolder(@NonNull DoctoreHolder2 doctoreHolder, int i) {
final Doctor doctor = mTubeListFiltered.get(i);
final TextView t = doctoreHolder.title ;
doctoreHolder.title.setText(doctor.getName());
/// ajouter l'image

String imageId = doctor.getEmail()+".jpg";
pathReference = FirebaseStorage.getInstance().getReference().child("DoctorProfile/"+ imageId);
pathReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Picasso.with(doctoreHolder.image.getContext())
.load(uri)
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(doctoreHolder.image);//hna fin kayn Image view

// profileImage.setImageURI(uri);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});
doctoreHolder.specialite.setText("Specialite : "+doctor.getSpecialite());
final String idPat = FirebaseAuth.getInstance().getCurrentUser().getEmail().toString();
final String idDoc = doctor.getEmail();
// doctoreHolder.image.setImageURI(Uri.parse("drawable-v24/ic_launcher_foreground.xml"));
doctoreHolder.addDoc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Map<String, Object> note = new HashMap<>();
note.put("id_patient", idPat);
note.put("id_doctor", idDoc);
addRequest.document().set(note)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(t, "Demande envoyée", Snackbar.LENGTH_SHORT).show();
}
});
doctoreHolder.addDoc.setVisibility(View.INVISIBLE);
}
});
doctoreHolder.appointemenBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
doc= doctor.getEmail();
Common.CurreentDoctor = doctor.getEmail();
openPage(v.getContext());

}
});

}

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

@Override
public Filter getFilter() {
return new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
String pattern = constraint.toString().toLowerCase();
if(pattern.isEmpty()){
mTubeListFiltered = mTubeList;
} else {
List<Doctor> filteredList = new ArrayList<>();
for(Doctor tube: mTubeList){
if(specialiteSearch == false) {
if (tube.getName().toLowerCase().contains(pattern) || tube.getName().toLowerCase().contains(pattern)) {
filteredList.add(tube);
}
}
else{
if (tube.getSpecialite().toLowerCase().contains(pattern) || tube.getSpecialite().toLowerCase().contains(pattern)) {
filteredList.add(tube);
}
}
}
mTubeListFiltered = filteredList;
}

FilterResults filterResults = new FilterResults();
filterResults.values = mTubeListFiltered;
return filterResults;
}

@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
mTubeListFiltered = (ArrayList<Doctor>) results.values;
notifyDataSetChanged();
}
};
}
class DoctoreHolder2 extends RecyclerView.ViewHolder {

Button appointemenBtn;
TextView title;
TextView specialite;
ImageView image;
Button addDoc;
Button load;
public DoctoreHolder2(@NonNull View itemView) {
super(itemView);
addDoc = itemView.findViewById(R.id.addDocBtn);
title= itemView.findViewById(R.id.doctor_view_title);
specialite=itemView.findViewById(R.id.text_view_description);
image=itemView.findViewById(R.id.doctor_item_image);
appointemenBtn=itemView.findViewById(R.id.appointemenBtn);
}
}
private void openPage(Context wf){
Intent i = new Intent(wf, TestActivity.class);
wf.startActivity(i);
}
}
18 changes: 7 additions & 11 deletions app/src/main/java/com/ensias/healthcareapp/DoctorHomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public class DoctorHomeActivity extends AppCompatActivity implements DatePickerD
Button BtnRequst;
Button listPatients;
Button appointementBtn;
Button profile;

@OnClick(R.id.profile)
void profileBtnClick(){
Intent k = new Intent(DoctorHomeActivity.this, ProfileDoctorActivity.class);
startActivity(k);
}
Unbinder unbinder;

@OnClick(R.id.myCalendarBtn)
Expand All @@ -46,11 +49,11 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_doctor_home); //ici layout de page d'acceuil MEDECIN
unbinder = ButterKnife.bind(this,this);
Common.CurreentDoctor = FirebaseAuth.getInstance().getCurrentUser().getEmail().toString();
Common.CurrentUserType = "doctor";
listPatients = findViewById(R.id.listPatients);
BtnRequst=findViewById(R.id.btnRequst);
SignOutBtn2=findViewById(R.id.signOutBtn);
appointementBtn = findViewById(R.id.appointement);
profile = findViewById(R.id.profile);
SignOutBtn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -63,7 +66,7 @@ public void onClick(View v) {
BtnRequst.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent k = new Intent(DoctorHomeActivity.this, ConfirmedAppointmensActivity.class);
Intent k = new Intent(DoctorHomeActivity.this, PatientRequestPage.class);
startActivity(k);
}
});
Expand All @@ -83,13 +86,6 @@ public void onClick(View v) {
startActivity(k);
}
});
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent k = new Intent(DoctorHomeActivity.this, ProfileDoctorActivity.class);
startActivity(k);
}
});

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onCreate(Bundle savedInstanceState) {
updateProfile = findViewById(R.id.update);
doctorName = findViewById(R.id.nameText);
doctorPhone = findViewById(R.id.phoneText);
///doctorEmail = findViewById(R.id.emailText);
//doctorEmail = findViewById(R.id.emailText);
doctorAddress = findViewById(R.id.addressText);

pStorageRef = FirebaseStorage.getInstance().getReference("DoctorProfile");
Expand Down Expand Up @@ -142,7 +142,6 @@ public void onClick(View view) {
});
}


/* Update the doctor info in the database */
private void updateDoctorInfos(String name, String address, String phone) {
DocumentReference documentReference = doctorRef.collection("Doctor").document("" + doctorID + "");
Expand Down
21 changes: 5 additions & 16 deletions app/src/main/java/com/ensias/healthcareapp/HomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ public class HomeActivity extends AppCompatActivity {
Button searchPatBtn;
Button myDoctors;
Button BtnRequst;
Button profile;
Button appointement2;
Button profilebtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_home);
searchPatBtn = (Button)findViewById(R.id.searchBtn);
searchPatBtn.setOnClickListener(new View.OnClickListener() {
Expand Down Expand Up @@ -63,21 +61,12 @@ public void onClick(View v) {
}
});

profile = findViewById(R.id.profile);
profile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent k = new Intent(HomeActivity.this, ProfilePatientActivity.class);
startActivity(k);
}
});

appointement2 = findViewById(R.id.appointement2);
appointement2.setOnClickListener(new View.OnClickListener() {
profilebtn = findViewById(R.id.profile);
profilebtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent k = new Intent(HomeActivity.this, PatientAppointementsActivity.class);
startActivity(k);
//Intent k = new Intent(HomeActivity.this, .class);
//startActivity(k);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.AlertDialog;
import android.os.Binder;
import android.os.Bundle;
import android.widget.Toast;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.ensias.healthcareapp;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.ensias.healthcareapp.model.Doctor;
import com.firebase.ui.firestore.FirestoreRecyclerOptions;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.material.textview.MaterialTextView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.CollectionReference;
Expand All @@ -19,11 +24,16 @@
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.FirebaseFirestoreException;
import com.google.firebase.firestore.Query;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.squareup.picasso.Picasso;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import dmax.dialog.SpotsDialog;

public class ProfileDoctorActivity extends AppCompatActivity {
private MaterialTextView doctorName;
Expand All @@ -32,6 +42,8 @@ public class ProfileDoctorActivity extends AppCompatActivity {
private MaterialTextView doctorEmail;
private MaterialTextView doctorAddress;
private MaterialTextView doctorAbout;
private ImageView doctorImage;
StorageReference pathReference ;
final String doctorID = FirebaseAuth.getInstance().getCurrentUser().getEmail().toString();
FirebaseFirestore db = FirebaseFirestore.getInstance();
DocumentReference docRef = db.collection("Doctor").document("" + doctorID + "");
Expand All @@ -42,12 +54,38 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile_doctor);

doctorImage = findViewById(R.id.imageView3);
doctorName = findViewById(R.id.doctor_name);
doctorSpe = findViewById(R.id.doctor_specialite);
doctorPhone = findViewById(R.id.doctor_phone);
doctorEmail = findViewById(R.id.doctor_email);
doctorAddress = findViewById(R.id.doctor_address);
doctorAbout = findViewById(R.id.doctor_about);
AlertDialog dialog = new SpotsDialog.Builder().setContext(this).setCancelable(true).build();
dialog.show();


//display profile image
String imageId = FirebaseAuth.getInstance().getCurrentUser().getEmail().toString();
pathReference = FirebaseStorage.getInstance().getReference().child("DoctorProfile/"+ imageId+".jpg");
pathReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Picasso.with(ProfileDoctorActivity.this)
.load(uri)
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(doctorImage);//hna fin kayn Image view
dialog.dismiss();
// profileImage.setImageURI(uri);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle any errors
}
});

docRef.addSnapshotListener(this, new EventListener<DocumentSnapshot>() {
@Override
Expand Down
Loading

0 comments on commit a62a990

Please sign in to comment.