fixes movement from camera fragment

This commit is contained in:
Raphael Maenle 2022-01-03 13:07:19 +01:00
parent 14e583c164
commit 0a94cb517c
4 changed files with 15 additions and 19 deletions

View File

@ -17,7 +17,6 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import com.maenle.bump.databinding.FragmentSecondBinding
import com.google.mlkit.vision.barcode.Barcode import com.google.mlkit.vision.barcode.Barcode
import com.google.mlkit.vision.barcode.BarcodeScanner import com.google.mlkit.vision.barcode.BarcodeScanner
import com.google.mlkit.vision.barcode.BarcodeScannerOptions import com.google.mlkit.vision.barcode.BarcodeScannerOptions
@ -31,6 +30,9 @@ import kotlin.math.min
import android.view.WindowInsets import android.view.WindowInsets
import android.graphics.Insets 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.BumpProcessor
import com.maenle.bump.util.CameraXViewModel import com.maenle.bump.util.CameraXViewModel
@ -44,7 +46,7 @@ class CameraFragment: Fragment() {
private var previewUseCase: Preview? = null private var previewUseCase: Preview? = null
private var analysisUseCase: ImageAnalysis? = null private var analysisUseCase: ImageAnalysis? = null
private var _binding: FragmentSecondBinding? = null private var _binding: FragmentCameraBinding? = null
private val binding get() = _binding!! private val binding get() = _binding!!
private val screenAspectRatio: Int private val screenAspectRatio: Int
@ -67,7 +69,7 @@ class CameraFragment: Fragment() {
savednstanceState: Bundle? savednstanceState: Bundle?
): View { ): View {
_binding = FragmentSecondBinding.inflate(inflater, container, false) _binding = FragmentCameraBinding.inflate(inflater, container, false)
setupCamera() setupCamera()
return binding.root return binding.root
} }
@ -183,7 +185,8 @@ class CameraFragment: Fragment() {
Log.d(TAG, it.rawValue!!) Log.d(TAG, it.rawValue!!)
val bump = BumpProcessor.getInstance(requireContext()) val bump = BumpProcessor.getInstance(requireContext())
bump.addSecret(requireContext(), it.rawValue!!) bump.addSecret(requireContext(), it.rawValue!!)
fragmentManager?.popBackStack() findNavController().navigateUp()
} }
} }
.addOnFailureListener { .addOnFailureListener {

View File

@ -17,6 +17,7 @@ import com.maenle.bump.util.RestSingleton
import com.maenle.bump.util.sendNotification import com.maenle.bump.util.sendNotification
import com.maenle.bump.R import com.maenle.bump.R
import com.maenle.bump.databinding.FragmentFirstBinding import com.maenle.bump.databinding.FragmentFirstBinding
import com.maenle.bump.util.LocalData
import org.json.JSONArray import org.json.JSONArray
/** /**
@ -65,8 +66,10 @@ class FirstFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
binding.buttonFirst.setOnClickListener { 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) { private fun createChannel(channelId: String, channelName: String) {

View File

@ -6,9 +6,9 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="com.maenle.bump.ui.SecondFragment"> tools:context="com.maenle.bump.ui.SecondFragment">
<!--androidx.camera.view.PreviewView <androidx.camera.view.PreviewView
android:id="@+id/viewFinder" android:id="@+id/viewFinder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /--> android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -12,19 +12,9 @@
tools:layout="@layout/fragment_first"> tools:layout="@layout/fragment_first">
<action <action
android:id="@+id/action_FirstFragment_to_SecondFragment" android:id="@+id/action_FirstFragment_to_CameraFragment"
app:destination="@id/CameraFragment" /> app:destination="@id/CameraFragment" />
</fragment> </fragment>
<fragment
android:id="@+id/SecondFragment"
android:name="com.maenle.bump.ui.SecondFragment"
android:label="@string/second_fragment_label"
tools:layout="@layout/fragment_second">
<action
android:id="@+id/action_SecondFragment_to_FirstFragment"
app:destination="@id/FirstFragment" />
</fragment>
<fragment <fragment
android:id="@+id/CameraFragment" android:id="@+id/CameraFragment"
android:name="com.maenle.bump.ui.CameraFragment" android:name="com.maenle.bump.ui.CameraFragment"
@ -32,7 +22,7 @@
tools:layout="@layout/fragment_camera"> tools:layout="@layout/fragment_camera">
<action <action
android:id="@+id/action_SecondFragment_to_FirstFragment" android:id="@+id/action_CameraFragment_to_FirstFragment"
app:destination="@id/FirstFragment" /> app:destination="@id/FirstFragment" />
</fragment> </fragment>
</navigation> </navigation>