Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class AppointmentDetailPFragment : Fragment() {
}

try {
startActivity(openIntent)
startActivity(Intent.createChooser(openIntent, "Open PDF"))
} catch (e: ActivityNotFoundException) {
Toast.makeText(requireContext(), "No PDF viewer installed", Toast.LENGTH_SHORT).show()
}
Expand Down Expand Up @@ -347,7 +347,7 @@ class AppointmentDetailPFragment : Fragment() {

override fun onDestroyView() {
super.onDestroyView()
_binding = null // 🔥 prevents memory leak
_binding = null //
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.mk.medtrust.patient.ui.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.navigation.fragment.findNavController
import com.mk.medtrust.R
import com.mk.medtrust.databinding.FragmentDiseasePredictionBinding
import com.mk.medtrust.util.UtilObject.DISEASE_P_WEB_URL


class DiseasePredictionFragment : Fragment() {

private var _binding : FragmentDiseasePredictionBinding? = null
private val binding get() = _binding!!

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = FragmentDiseasePredictionBinding.inflate(inflater,container,false)
return binding.root
}


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

//
setUpWebView()

binding.backBtn.setOnClickListener {
findNavController().popBackStack()
}
}

private fun setUpWebView(){
val webView = binding.webView

// js required dynamic website
webView.settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
allowFileAccess = false
allowContentAccess = false
}

// restriction navigation and does not allow unknown url to be clicked from the webview
webView.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView?,
request: WebResourceRequest?
): Boolean {
val url = request?.url.toString()
return !url.startsWith("https://yourdomain.com")
}
}
webView.loadUrl(DISEASE_P_WEB_URL)
}


override fun onDestroyView() {
super.onDestroyView()
_binding = null
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class HomeFragmentP : Fragment() {
if (!isAppointmentFetched) return@setOnClickListener
findNavController().navigate(R.id.homeFragment_to_historyListPFragment)
}
binding.cardDisease.setOnClickListener {
findNavController().navigate(R.id.homeFragment_to_diseasePredictionFragment)
}

}

private fun checkForOngoingAppointments(){
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/mk/medtrust/util/UtilObject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ object UtilObject {
// measure & layout view
// since i am using the inflated view not rendered one

if (view.width <=0 || view.height <=0){
return Uri.EMPTY
}
// if (view.width <=0 || view.height <=0){
// return Uri.EMPTY
// }
Log.d("PDF_DEBUG", "Width: ${view.measuredWidth}, Height: ${view.measuredHeight}")


val widthSpec = View.MeasureSpec.makeMeasureSpec(
Resources.getSystem().displayMetrics.widthPixels,
Expand Down Expand Up @@ -191,5 +193,6 @@ object UtilObject {
)
}

const val DISEASE_P_WEB_URL = "https://disease-prediction-tay1.onrender.com"

}
49 changes: 49 additions & 0 deletions app/src/main/res/layout/fragment_disease_prediction.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:fitsSystemWindows="true"
tools:context=".patient.ui.fragment.DiseasePredictionFragment">

<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="16dp"
android:layout_gravity="top|center_horizontal"
android:padding="3sp">

<ImageView android:id="@+id/backBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:contentDescription="@null"
android:src="@drawable/outline_arrow_back_24"
app:tint="@color/lightGreen" />

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="@font/roboto"
android:gravity="center"
android:text="Disease Prediction"
android:textColor="@color/lightGreen"
android:textSize="18sp"
android:textStyle="bold" />

<View
android:layout_width="24dp"
android:layout_height="24dp"/>

</LinearLayout>


</FrameLayout>
12 changes: 12 additions & 0 deletions app/src/main/res/navigation/nav_graph_patient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
android:id="@+id/homeFragment_to_historyListPFragment"
app:destination="@+id/historyListPFragment"
/>
<action
android:id="@+id/homeFragment_to_diseasePredictionFragment"
app:destination="@+id/diseasePredictionFragment"
/>
</fragment>

<fragment
Expand Down Expand Up @@ -103,5 +107,13 @@
</fragment>


<fragment
android:id="@+id/diseasePredictionFragment"
android:name="com.mk.medtrust.patient.ui.fragment.DiseasePredictionFragment"
tools:layout="@layout/fragment_disease_prediction">

</fragment>



</navigation>
Loading