File tree Expand file tree Collapse file tree
CameraXBasic/app/src/main/java/com/android/example/cameraxbasic/fragments Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ class CameraFragment : Fragment() {
287287 Log .d(TAG , " Screen metrics: ${metrics.width()} x ${metrics.height()} " )
288288
289289 val screenAspectRatio = aspectRatio(metrics.width(), metrics.height())
290- Log .d(TAG , " Preview aspect ratio: $screenAspectRatio " )
290+ Log .d(TAG , " Preview aspect ratio: $screenAspectRatio " )
291291
292292 val rotation = viewFinder.display.rotation
293293
@@ -597,6 +597,7 @@ class CameraFragment : Fragment() {
597597 private val targetResolution = Size (2448 , 3264 )
598598
599599
600+
600601 /* * Helper function used to create a timestamped file */
601602 private fun createFile (baseFolder : File , format : String , extension : String ) =
602603 File (
Original file line number Diff line number Diff line change 1717package com.android.example.cameraxbasic.fragments
1818
1919import android.annotation.SuppressLint
20+ import android.graphics.Bitmap
21+ import android.graphics.BitmapFactory
2022import android.os.Bundle
2123import android.view.LayoutInflater
2224import android.view.ScaleGestureDetector
@@ -43,8 +45,14 @@ class PhotoFragment internal constructor() : Fragment() {
4345 override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
4446 super .onViewCreated(view, savedInstanceState)
4547 val args = arguments ? : return
46- val resource = args.getString(FILE_NAME_KEY )?.let { File (it) } ? : R .drawable.ic_photo
47- Glide .with (view).load(resource).into(view as PhotoView )
48+ // val resource = args.getString(FILE_NAME_KEY)?.let { File(it) } ?: R.drawable.ic_photo
49+ // Glide.with(view).load(resource).into(view as PhotoView)
50+ if (args.getString(FILE_NAME_KEY ) != null ){
51+ val imageBitmap = BitmapFactory .decodeFile(args.getString(FILE_NAME_KEY ))
52+ (view as PhotoView ).setImageBitmap(imageBitmap)
53+ } else {
54+ (view as PhotoView ).setImageResource(R .drawable.ic_photo)
55+ }
4856
4957 }
5058
You can’t perform that action at this time.
0 commit comments