Skip to content
Snippets Groups Projects
Commit 01257bb9 authored by bag's avatar bag
Browse files

fix:dashboard

parent e4ef46f3
No related merge requests found
...@@ -3,19 +3,7 @@ ...@@ -3,19 +3,7 @@
<component name="deploymentTargetDropDown"> <component name="deploymentTargetDropDown">
<value> <value>
<entry key="app"> <entry key="app">
<State> <State />
<targetsSelectedWithDialog>
<Target>
<type value="QUICK_BOOT_TARGET" />
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\ASUS\.android\avd\Pixel_7_API_31.avd" />
</Key>
</deviceKey>
</Target>
</targetsSelectedWithDialog>
</State>
</entry> </entry>
</value> </value>
</component> </component>
......
package com.example.pbd_jwr.ui.dashboard package com.example.pbd_jwr.ui.dashboard
import android.content.SharedPreferences
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
...@@ -24,6 +25,7 @@ class DashboardFragment : Fragment() { ...@@ -24,6 +25,7 @@ class DashboardFragment : Fragment() {
private lateinit var pieChart: PieChart private lateinit var pieChart: PieChart
private lateinit var viewModel: TransactionViewModel private lateinit var viewModel: TransactionViewModel
private lateinit var encryptedSharedPref: SharedPreferences
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
...@@ -40,7 +42,8 @@ class DashboardFragment : Fragment() { ...@@ -40,7 +42,8 @@ class DashboardFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
viewModel.getAllTransactions().observe(viewLifecycleOwner) { transactions -> val currentUserEmail = encryptedSharedPref.getString("email", "") ?: ""
viewModel.getTransactionsByEmail(currentUserEmail).observe(viewLifecycleOwner) { transactions ->
loadPieChartData(transactions) loadPieChartData(transactions)
} }
} }
......
...@@ -75,7 +75,8 @@ class SettingsFragment : Fragment() { ...@@ -75,7 +75,8 @@ class SettingsFragment : Fragment() {
JWR App JWR App
""".trimIndent() """.trimIndent()
transactionViewModel.getAllTransactions().observe(viewLifecycleOwner) { transactions -> val currentUserEmail = encryptedSharedPref.getString("email", "") ?: ""
transactionViewModel.getTransactionsByEmail(currentUserEmail).observe(viewLifecycleOwner) { transactions ->
exportTransactionsToExcel(transactions, requireContext())?.let { uri -> exportTransactionsToExcel(transactions, requireContext())?.let { uri ->
val emailIntent = Intent(Intent.ACTION_SEND).apply { val emailIntent = Intent(Intent.ACTION_SEND).apply {
type = "vnd.android.cursor.dir/email" type = "vnd.android.cursor.dir/email"
...@@ -91,7 +92,8 @@ class SettingsFragment : Fragment() { ...@@ -91,7 +92,8 @@ class SettingsFragment : Fragment() {
} }
private fun saveTransactionsToExcel() { private fun saveTransactionsToExcel() {
transactionViewModel.getAllTransactions().observe(viewLifecycleOwner) { transactions -> val currentUserEmail = encryptedSharedPref.getString("email", "") ?: ""
transactionViewModel.getTransactionsByEmail(currentUserEmail).observe(viewLifecycleOwner) { transactions ->
exportTransactionsToExcel(transactions, requireContext()) exportTransactionsToExcel(transactions, requireContext())
} }
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment