production errors
This commit is contained in:
@@ -5,6 +5,8 @@ import android.content.Context
|
|||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.google.android.datatransport.runtime.dagger.Provides
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@@ -15,5 +17,14 @@ import javax.inject.Singleton
|
|||||||
class HPOSTestingApplication: Application() {
|
class HPOSTestingApplication: Application() {
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
||||||
|
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val firestore = FirebaseFirestore.getInstance()
|
||||||
|
firestore.firestoreSettings = firestoreSettings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import android.content.Intent
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
@@ -12,6 +13,8 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
@@ -52,10 +55,36 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
moveToNext()
|
moveToNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (checkHemoCubeKitData()) {
|
||||||
|
// DataHolder.selectedTest!!.kitSerial =
|
||||||
|
// sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
|
// moveToNext()
|
||||||
|
// } else {
|
||||||
|
// with(sharedPreference.edit()) {
|
||||||
|
// putString(Constants.KIT_NUMBER, "")
|
||||||
|
// putInt(Constants.KIT_COUNT, 0)
|
||||||
|
// putString(Constants.BUFFER_VALUE_1, "")
|
||||||
|
// putString(Constants.BUFFER_VALUE_2, "")
|
||||||
|
// apply()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (checkHemoCubeKitData()) {
|
if (checkHemoCubeKitData()) {
|
||||||
DataHolder.selectedTest!!.kitSerial =
|
try {
|
||||||
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
DataHolder.selectedTest!!.kitSerial =
|
||||||
moveToNext()
|
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
|
moveToNext()
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
// Handle the NullPointerException here
|
||||||
|
e.printStackTrace() // You can log the exception for debugging
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
val errorMessage = "An error occurred: ${e.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
|
// Optionally, show a user-friendly error message to the user
|
||||||
|
// Toast.makeText(applicationContext, "An error occurred", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.KIT_NUMBER, "")
|
putString(Constants.KIT_NUMBER, "")
|
||||||
@@ -66,6 +95,7 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.nameEditText.setText("SMI/SC/")
|
binding.nameEditText.setText("SMI/SC/")
|
||||||
|
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.google.android.gms.location.*
|
import com.google.android.gms.location.*
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
||||||
@@ -234,6 +236,20 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||||
|
// location?.let {
|
||||||
|
// DataHolder.selectedTest!!.location =
|
||||||
|
// UserData.Location(location.latitude, location.longitude)
|
||||||
|
// DataHolder.location =
|
||||||
|
// UserData.Location(location.latitude, location.longitude)
|
||||||
|
// } ?: run {
|
||||||
|
// requestLocationUpdates()
|
||||||
|
// }
|
||||||
|
// }.addOnFailureListener { exception: Exception ->
|
||||||
|
// exception.printStackTrace()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||||
location?.let {
|
location?.let {
|
||||||
DataHolder.selectedTest!!.location =
|
DataHolder.selectedTest!!.location =
|
||||||
@@ -244,8 +260,17 @@ class MainActivity : AppCompatActivity() {
|
|||||||
requestLocationUpdates()
|
requestLocationUpdates()
|
||||||
}
|
}
|
||||||
}.addOnFailureListener { exception: Exception ->
|
}.addOnFailureListener { exception: Exception ->
|
||||||
|
// Handle the exception here
|
||||||
exception.printStackTrace()
|
exception.printStackTrace()
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(exception)
|
||||||
|
// Display an error message to the user using a Snackbar
|
||||||
|
val errorMessage = "An error occurred: ${exception.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun requestLocationUpdates() {
|
private fun requestLocationUpdates() {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class GalleryFragment : Fragment() {
|
|||||||
// val galleryViewModel =
|
// val galleryViewModel =
|
||||||
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
||||||
|
|
||||||
// _binding = FragmentGalleryBinding.inflate(inflater, container, false)
|
_binding = FragmentGalleryBinding.inflate(inflater, container, false)
|
||||||
val root: View = binding.root
|
val root: View = binding.root
|
||||||
|
|
||||||
// val textView: TextView = binding.textGallery
|
// val textView: TextView = binding.textGallery
|
||||||
|
|||||||
@@ -38,8 +38,16 @@ class HomeFragment : Fragment() {
|
|||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View? {
|
||||||
_binding = FragmentHomeBinding.inflate(inflater, container, false)
|
_binding = FragmentHomeBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
// Check if _binding is null
|
||||||
|
if (_binding == null) {
|
||||||
|
// Handle the case where binding could not be initialized
|
||||||
|
// You may want to log an error or return a default view in this case
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
DataHolder.selectedTest = null
|
DataHolder.selectedTest = null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user