-
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
mnb27
committed
Apr 27, 2021
1 parent
9ade734
commit 2247176
Showing
15 changed files
with
384 additions
and
32 deletions.
There are no files selected for viewing
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
78 changes: 78 additions & 0 deletions
78
app/src/main/java/com/example/pgidoctor/AssignedDoctors.kt
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,78 @@ | ||
package com.example.pgidoctor | ||
|
||
import android.R.attr.button | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.text.TextUtils | ||
import android.view.Menu | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.widget.* | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.google.firebase.auth.FirebaseAuth | ||
import com.google.firebase.firestore.FirebaseFirestore | ||
import kotlinx.android.synthetic.main.activity_search_by_name.* | ||
|
||
|
||
class AssignedDoctors : AppCompatActivity() { | ||
lateinit var recyclerView: RecyclerView | ||
lateinit var assignedDoctorsAdapter: AssignedDoctorsAdapter | ||
var list: MutableList<User> = mutableListOf() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_assigned_doctors) | ||
val fireStore = FirebaseFirestore.getInstance() | ||
val auth = FirebaseAuth.getInstance() | ||
val goback: ImageView = findViewById(R.id.backB) | ||
|
||
goback.setOnClickListener { | ||
val intent = Intent(this, PatientPortalActivity::class.java) | ||
startActivity(intent) | ||
} | ||
|
||
|
||
recyclerView = findViewById(R.id.recyclerView) | ||
assignedDoctorsAdapter = AssignedDoctorsAdapter(this,list) | ||
|
||
|
||
recyclerView.adapter = assignedDoctorsAdapter | ||
|
||
recyclerView.layoutManager = LinearLayoutManager(this) | ||
|
||
var unit = "" | ||
var hospital = "" | ||
|
||
auth.currentUser?.uid?.let { | ||
fireStore.collection("Users").document(it).get() | ||
.addOnSuccessListener { it -> | ||
if(it.exists()){ | ||
hospital = it.getString("hospital").toString() | ||
unit = it.getString("unit").toString() | ||
|
||
fireStore.collection("Users").whereEqualTo("type","Doctor").whereEqualTo("hospital",hospital).whereEqualTo("unit",unit).get() | ||
.addOnSuccessListener { documents-> | ||
for(document in documents) { | ||
list.add(document.toObject(User::class.java)) | ||
} | ||
list.sortBy { det->det.name } | ||
(recyclerView.adapter as AssignedDoctorsAdapter).notifyDataSetChanged() | ||
if(list.isEmpty()) { | ||
Toast.makeText(this,"No Doctor records",Toast.LENGTH_LONG).show() | ||
val intent = Intent(this, MainActivity::class.java) | ||
startActivity(intent) | ||
} | ||
} | ||
.addOnFailureListener{ | ||
Toast.makeText(this,"Error",Toast.LENGTH_LONG).show() | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/example/pgidoctor/AssignedDoctorsAdapter.kt
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,56 @@ | ||
package com.example.pgidoctor | ||
|
||
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.TextView | ||
import androidx.core.content.ContextCompat.startActivity | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
|
||
class AssignedDoctorsAdapter(var context: Context, var detailsList: MutableList<User>): | ||
RecyclerView.Adapter<AssignedDoctorsAdapter.DetailsViewHolder>() { | ||
|
||
class DetailsViewHolder(itemView: View): RecyclerView.ViewHolder(itemView) { | ||
var nameText: TextView = itemView.findViewById(R.id.nameOfTask) | ||
var hospital: TextView = itemView.findViewById(R.id.hospital) | ||
var unit: TextView = itemView.findViewById(R.id.unit) | ||
var whatsapp: Button = itemView.findViewById(R.id.whatsapp) | ||
} | ||
override fun onBindViewHolder(holder: AssignedDoctorsAdapter.DetailsViewHolder, position: Int) { | ||
var details = detailsList[position] | ||
holder.nameText.text = "Name: " + details.name | ||
holder.hospital.text = details.email | ||
holder.unit.text = "Hospital: " + details.hospital + " , Unit: " + details.unit | ||
|
||
var number = "+91"+details.mobile | ||
|
||
holder.whatsapp.setOnClickListener { | ||
val url = "https://api.whatsapp.com/send?phone=$number" | ||
val i = Intent(Intent.ACTION_VIEW) | ||
i.data = Uri.parse(url) | ||
context.startActivity(i) | ||
} | ||
} | ||
|
||
override fun onCreateViewHolder( | ||
parent: ViewGroup, | ||
viewType: Int | ||
): AssignedDoctorsAdapter.DetailsViewHolder { | ||
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.activity_assigned_doctors_adapter,parent,false) | ||
return DetailsViewHolder(itemView) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return detailsList.size | ||
} | ||
|
||
fun setList(list: MutableList<User>){ | ||
detailsList = list | ||
notifyDataSetChanged() | ||
} | ||
} |
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
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
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
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="58dp" | ||
android:height="58dp" | ||
android:viewportWidth="58" | ||
android:viewportHeight="58"> | ||
|
||
<path | ||
android:fillColor="#2CB742" | ||
android:pathData="M0,58l4.988-14.963C2.457,38.78,1,33.812,1,28.5C1,12.76,13.76,0,29.5,0S58,12.76,58,28.5 S45.24,57,29.5,57c-4.789,0-9.299-1.187-13.26-3.273L0,58z" /> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:pathData="M47.683,37.985c-1.316-2.487-6.169-5.331-6.169-5.331c-1.098-0.626-2.423-0.696-3.049,0.42 c0,0-1.577,1.891-1.978,2.163c-1.832,1.241-3.529,1.193-5.242-0.52l-3.981-3.981l-3.981-3.981c-1.713-1.713-1.761-3.41-0.52-5.242 c0.272-0.401,2.163-1.978,2.163-1.978c1.116-0.627,1.046-1.951,0.42-3.049c0,0-2.844-4.853-5.331-6.169 c-1.058-0.56-2.357-0.364-3.203,0.482l-1.758,1.758c-5.577,5.577-2.831,11.873,2.746,17.45l5.097,5.097l5.097,5.097 c5.577,5.577,11.873,8.323,17.45,2.746l1.758-1.758C48.048,40.341,48.243,39.042,47.683,37.985z" /> | ||
</vector> |
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,57 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#FFFFFF" | ||
tools:context=".AssignedDoctors"> | ||
|
||
<LinearLayout | ||
android:id="@+id/layout0" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
tools:ignore="MissingConstraints"> | ||
|
||
<ImageButton | ||
android:id="@+id/backB" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="16dp" | ||
android:background="#3192F4" | ||
android:padding="8dp" | ||
android:src="@drawable/ic_back" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="20dp" | ||
android:layout_marginStart="80dp" | ||
android:layout_marginTop="24dp" | ||
android:text="DOCTOR LIST" | ||
android:textColor="#3192F4" | ||
android:textStyle="bold" | ||
android:textSize="24sp" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
</LinearLayout> | ||
|
||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/recyclerView" | ||
android:layout_width="414dp" | ||
android:layout_height="683dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.