Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ -17,9 +17,9 @@ import android.view.ViewGroup
- import androidx.activity.result.contract.ActivityResultContracts
- import androidx.appcompat.app.AppCompatActivity
- import androidx.core.content.ContextCompat
- import androidx.fragment.app.DialogFragment
- import androidx.lifecycle.lifecycleScope
- import androidx.recyclerview.widget.LinearLayoutManager
- import com.bm.fasty.dashboard.BaseDialogFragment
- import com.bm.fasty.dashboard.R
- import com.bm.fasty.dashboard.databinding.FragmentInvoiceDialogBinding
- import com.bm.fasty.dashboard.model.BusinessLocation
- @ -46,7 +46,7 @@ import kotlinx.coroutines.launch
- import org.koin.androidx.viewmodel.ext.android.sharedViewModel
- import java.text.ParseException
- class DialogLaporanDetailTransaksi : DialogFragment() {
- class DialogLaporanDetailTransaksi : BaseDialogFragment() {
- private lateinit var binding: FragmentInvoiceDialogBinding
- private lateinit var firebaseAnalytics: FirebaseAnalytics
- @ -228,7 +228,45 @@ class DialogLaporanDetailTransaksi : DialogFragment() {
- binding.btnCetakStruk?.visibility = if (btnCetakStruk) View.VISIBLE else View.GONE
- binding.btnCetakStruk?.setOnClickListener {
- checkBluetoothPermission()
- context?.let { ctx ->
- val bluetoothAdapter = baseCheckBluetoothPermission(ctx, bluetoothStatus = {
- if (it != null) {
- globalViewModel.isBluetoothGranted = it
- }
- }, requestPermissionBelow31 = { bluetoothAdapter ->
- val enableBtIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
- requestBluetooth.launch(enableBtIntent)
- }, requestPermissionAbove31 = {
- requestMultiplePermissions.launch(
- arrayOf(
- Manifest.permission.BLUETOOTH_SCAN,
- Manifest.permission.BLUETOOTH_CONNECT,
- Manifest.permission.BLUETOOTH_ADVERTISE
- )
- )
- })
- if (bluetoothAdapter != null) {
- val pairedDevices = bluetoothAdapter.bondedDevices
- if (pairedDevices.size > 0) {
- for (device in pairedDevices) {
- if (isConnected(device)) {
- globalViewModel.isBluetoothGranted = true
- break
- } else {
- globalViewModel.isBluetoothGranted = false
- }
- }
- } else {
- globalViewModel.isBluetoothGranted = false
- }
- }
- }
- //checkBluetoothPermission()
- if (globalViewModel.isBluetoothGranted) {
- showToast(requireContext(), "Sedang mencetak struk")
- dataSales.contact =
- @ -316,7 +354,18 @@ class DialogLaporanDetailTransaksi : DialogFragment() {
- if (!data.value) {
- // Permission denied, handle accordingly
- // You might want to show a message to the user or take an alternative action
- checkBluetoothPermission()
- //checkBluetoothPermission()
- context?.let { ctx ->
- baseCheckBluetoothPermission(
- ctx,
- bluetoothStatus = {
- if (it != null) {
- globalViewModel.isBluetoothGranted = it
- }
- },
- requestPermissionAbove31 = {},
- requestPermissionBelow31 = {})
- }
- } else {
- // Permission granted, proceed with Bluetooth activation
- val enableBtIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement