Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 카메라 가로모드 오류 #520

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.PersistableBundle
import android.text.Editable
import android.text.TextUtils
import android.text.TextWatcher
Expand Down Expand Up @@ -326,6 +327,19 @@ class PostEditorActivity : BaseActivity<ActivityPostEditorBinding, PostEditorVie
binding.etPostPrice.addTextChangedListener(textWatcher)
}

override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(KEY_CAMERA_URI, cameraUri)
}

override fun onRestoreInstanceState(
savedInstanceState: Bundle?,
persistentState: PersistableBundle?,
) {
super.onRestoreInstanceState(savedInstanceState, persistentState)
cameraUri = savedInstanceState?.getParcelableExtraCompat(KEY_CAMERA_URI) as Uri?
}

override fun onDestroy() {
super.onDestroy()
if (!isChangingConfigurations) {
Expand All @@ -340,6 +354,7 @@ class PostEditorActivity : BaseActivity<ActivityPostEditorBinding, PostEditorVie
private const val MAX_IMAGES_COUNT = 10
private const val KEY_POST_EDITOR_CHECK = "key_post_editor_check"
private const val KEY_POST_EDITOR_POST = "key_post_editor_post"
private const val KEY_CAMERA_URI = "cameraUri"
const val POST_CODE = 2000
const val UPDATE_CODE = 3000
const val RESULT_RELOAD_CODE = 1001
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@ package com.app.edonymyeon.presentation.util

import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.os.Parcelable

@Suppress("DEPRECATION")
inline fun <reified T : Parcelable> Bundle.getParcelableExtraCompat(key: String): T? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getParcelable(key, T::class.java)
} else {
getParcelable(key) as? T
}
}

@Suppress("DEPRECATION")
inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String): T? {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true