From 0a94cb517c9105641e1c3033ad8685489a62006f Mon Sep 17 00:00:00 2001 From: raphael Date: Mon, 3 Jan 2022 13:07:19 +0100 Subject: [PATCH] fixes movement from camera fragment --- .../main/java/com/maenle/bump/ui/CameraFragment.kt | 11 +++++++---- .../main/java/com/maenle/bump/ui/FirstFragment.kt | 5 ++++- app/src/main/res/layout/fragment_camera.xml | 4 ++-- app/src/main/res/navigation/nav_graph.xml | 14 ++------------ 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/maenle/bump/ui/CameraFragment.kt b/app/src/main/java/com/maenle/bump/ui/CameraFragment.kt index f1b1bb2..9275f1f 100644 --- a/app/src/main/java/com/maenle/bump/ui/CameraFragment.kt +++ b/app/src/main/java/com/maenle/bump/ui/CameraFragment.kt @@ -17,7 +17,6 @@ import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider -import com.maenle.bump.databinding.FragmentSecondBinding import com.google.mlkit.vision.barcode.Barcode import com.google.mlkit.vision.barcode.BarcodeScanner import com.google.mlkit.vision.barcode.BarcodeScannerOptions @@ -31,6 +30,9 @@ import kotlin.math.min import android.view.WindowInsets import android.graphics.Insets +import androidx.navigation.fragment.findNavController +import com.maenle.bump.R +import com.maenle.bump.databinding.FragmentCameraBinding import com.maenle.bump.util.BumpProcessor import com.maenle.bump.util.CameraXViewModel @@ -44,7 +46,7 @@ class CameraFragment: Fragment() { private var previewUseCase: Preview? = null private var analysisUseCase: ImageAnalysis? = null - private var _binding: FragmentSecondBinding? = null + private var _binding: FragmentCameraBinding? = null private val binding get() = _binding!! private val screenAspectRatio: Int @@ -67,7 +69,7 @@ class CameraFragment: Fragment() { savednstanceState: Bundle? ): View { - _binding = FragmentSecondBinding.inflate(inflater, container, false) + _binding = FragmentCameraBinding.inflate(inflater, container, false) setupCamera() return binding.root } @@ -183,7 +185,8 @@ class CameraFragment: Fragment() { Log.d(TAG, it.rawValue!!) val bump = BumpProcessor.getInstance(requireContext()) bump.addSecret(requireContext(), it.rawValue!!) - fragmentManager?.popBackStack() + findNavController().navigateUp() + } } .addOnFailureListener { diff --git a/app/src/main/java/com/maenle/bump/ui/FirstFragment.kt b/app/src/main/java/com/maenle/bump/ui/FirstFragment.kt index 1737f05..0f491c4 100644 --- a/app/src/main/java/com/maenle/bump/ui/FirstFragment.kt +++ b/app/src/main/java/com/maenle/bump/ui/FirstFragment.kt @@ -17,6 +17,7 @@ import com.maenle.bump.util.RestSingleton import com.maenle.bump.util.sendNotification import com.maenle.bump.R import com.maenle.bump.databinding.FragmentFirstBinding +import com.maenle.bump.util.LocalData import org.json.JSONArray /** @@ -65,8 +66,10 @@ class FirstFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.buttonFirst.setOnClickListener { - findNavController().navigate(R.id.action_FirstFragment_to_SecondFragment) + findNavController().navigate(R.id.action_FirstFragment_to_CameraFragment) } + val local = LocalData(requireContext()) + local.code?.let { binding.textviewFirst.text = it} } private fun createChannel(channelId: String, channelName: String) { diff --git a/app/src/main/res/layout/fragment_camera.xml b/app/src/main/res/layout/fragment_camera.xml index cb17097..80c7c42 100644 --- a/app/src/main/res/layout/fragment_camera.xml +++ b/app/src/main/res/layout/fragment_camera.xml @@ -6,9 +6,9 @@ android:layout_height="match_parent" tools:context="com.maenle.bump.ui.SecondFragment"> - + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 0a5338d..5bc0e10 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -12,19 +12,9 @@ tools:layout="@layout/fragment_first"> - - - - \ No newline at end of file