BaseFragment

abstract class BaseFragment : RootFragment

A basic Fragment that automatically handles layout inflation without ViewBinding or DataBinding.
Directly extends RootFragment to inherit only permission management features.

ViewBinding이나 DataBinding 없이 레이아웃 인플레이션을 자동으로 처리하는 기본 Fragment입니다.
권한 관리 기능만 상속받기 위해 RootFragment를 직접 확장합니다.

Design decisions / 설계 결정 이유:

  • Directly extends RootFragment (not ParentsBindingFragment) to avoid unnecessary binding infrastructure.

  • Uses constructor parameter for layout resource ID to enable simple single-line class declaration.

  • Automatically sets rootView to null in onDestroyView() to prevent memory leaks.

  • 불필요한 바인딩 인프라를 피하기 위해 RootFragment를 직접 상속합니다 (ParentsBindingFragment 상속 안 함).

  • 간단한 한 줄 클래스 선언을 위해 생성자 파라미터로 레이아웃 리소스 ID를 사용합니다.

  • 메모리 누수를 방지하기 위해 onDestroyView()에서 자동으로 rootView를 null로 설정합니다.

Usage example:

class HomeFragment : BaseFragment(R.layout.fragment_home) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
getRootView().findViewById<TextView>(R.id.tvTitle).text = "Home"
}
}

Parameters

layoutRes

The layout resource ID for the fragment.

Fragment의 레이아웃 리소스 ID.

isAttachToParent

Whether to attach the inflated view to the parent container.

인플레이션된 뷰를 부모 컨테이너에 첨부할지 여부.
Fragment에서는 특별한 경우가 아니라면 기본값 false 사용을 권장합니다.
반환된 root view는 Fragment framework가 다시 처리하므로 true 사용 시 parent 중복 attach 예외가 발생할 수 있습니다.

See also

For the parent class with permission management.

권한 관리 기능이 있는 부모 클래스.

BaseViewBindingFragment

For ViewBinding-enabled Fragment.

ViewBinding을 사용하는 Fragment.

BaseDataBindingFragment

For DataBinding-enabled Fragment.

DataBinding을 사용하는 Fragment.

Constructors

Link copied to clipboard
constructor(layoutRes: Int)
constructor(layoutRes: Int, isAttachToParent: Boolean)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val context: Context?
Link copied to clipboard
Link copied to clipboard
open var exitTransition: Any?
Link copied to clipboard
Link copied to clipboard
val host: Any?
Link copied to clipboard
val id: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val tag: String?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val view: View?
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun consumeOrphanedDeniedResults(): List<OrphanedDeniedRequestResult>

Returns and clears denied results that lost their callbacks after process restore.
Call this in onCreate to handle results from requests that were interrupted by process kill.

프로세스 복원 후 콜백을 잃은 거부 결과를 반환하고 비웁니다.
프로세스 킬로 중단된 요청의 결과를 처리하려면 onCreate에서 호출하세요.

Link copied to clipboard
open fun dump(@NonNull prefix: String, @Nullable fd: FileDescriptor?, @NonNull writer: PrintWriter, @Nullable args: Array<out String?>??)
Link copied to clipboard
fun getString(@StringRes resId: Int, @Nullable vararg formatArgs: Any?): String
Link copied to clipboard
Link copied to clipboard
open fun onActivityCreated(@Nullable savedInstanceState: Bundle?)
Link copied to clipboard
open fun onActivityResult(requestCode: Int, resultCode: Int, @Nullable data: Intent?)
Link copied to clipboard
Link copied to clipboard
open fun onAttachFragment(@NonNull childFragment: Fragment)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onCreate(savedInstanceState: Bundle?)
Link copied to clipboard
open fun onCreateAnimation(transit: Int, enter: Boolean, nextAnim: Int): Animation?
Link copied to clipboard
open fun onCreateAnimator(transit: Int, enter: Boolean, nextAnim: Int): Animator?
Link copied to clipboard
Link copied to clipboard
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View?

Inflates the layout and returns the root view.

레이아웃을 인플레이션하고 루트 뷰를 반환합니다.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun onDestroyView()
Link copied to clipboard
Link copied to clipboard
open fun onGetLayoutInflater(@Nullable savedInstanceState: Bundle?): LayoutInflater
Link copied to clipboard
Link copied to clipboard
open fun onInflate(@NonNull activity: Activity, @NonNull attrs: AttributeSet, @Nullable savedInstanceState: Bundle?)
open fun onInflate(@NonNull context: Context, @NonNull attrs: AttributeSet, @Nullable savedInstanceState: Bundle?)
Link copied to clipboard
Link copied to clipboard
open fun onMultiWindowModeChanged(isInMultiWindowMode: Boolean)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)
Link copied to clipboard
Link copied to clipboard
open fun onPrimaryNavigationFragmentChanged(isPrimaryNavigationFragment: Boolean)
Link copied to clipboard
open fun onRequestPermissionsResult(requestCode: Int, @NonNull permissions: Array<out String?>, @NonNull grantResults: IntArray)
Link copied to clipboard
Link copied to clipboard
open override fun onSaveInstanceState(outState: Bundle)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onViewCreated(@NonNull view: View, @Nullable savedInstanceState: Bundle?)
Link copied to clipboard
open fun onViewStateRestored(@Nullable savedInstanceState: Bundle?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun requestPermissions(@NonNull permissions: Array<out String?>, requestCode: Int)

override fun requestPermissions(permissions: List<String>, onDeniedResult: (List<PermissionDeniedItem>) -> Unit)
override fun requestPermissions(permissions: List<String>, onDeniedResult: (List<PermissionDeniedItem>) -> Unit, onRationaleNeeded: (PermissionRationaleRequest) -> Unit?, onNavigateToSettings: (PermissionSettingsRequest) -> Unit?)

Requests permissions using the delegate.
Call only after the Fragment is attached (isAdded == true).

델리게이트를 사용하여 권한을 요청합니다.
Fragment가 attach된 이후(isAdded == true)에만 호출하세요.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun setHasOptionsMenu(hasMenu: Boolean)
Link copied to clipboard
Link copied to clipboard
open fun setMenuVisibility(menuVisible: Boolean)
Link copied to clipboard
open fun setTargetFragment(@Nullable fragment: Fragment?, requestCode: Int)
Link copied to clipboard
fun Fragment.snackBarShowIndefinite(msg: CharSequence, snackBarOption: SnackBarOption? = null)

Creates and shows an indefinite duration Snackbar from a Fragment.
Logs an error if the Fragment's view is null.

Fragment에서 무제한 시간 Snackbar를 생성하고 표시합니다.
Fragment의 view가 null이면 에러를 로깅합니다.

Link copied to clipboard
fun Fragment.snackBarShowLong(msg: CharSequence, snackBarOption: SnackBarOption? = null)

Creates and shows a long duration Snackbar from a Fragment.
Logs an error if the Fragment's view is null.

Fragment에서 긴 시간 Snackbar를 생성하고 표시합니다.
Fragment의 view가 null이면 에러를 로깅합니다.

Link copied to clipboard
fun Fragment.snackBarShowShort(msg: CharSequence, snackBarOption: SnackBarOption? = null)

Creates and shows a short duration Snackbar from a Fragment.
Logs an error if the Fragment's view is null.

Fragment에서 짧은 시간 Snackbar를 생성하고 표시합니다.
Fragment의 view가 null이면 에러를 로깅합니다.

Link copied to clipboard
open fun startActivity(intent: Intent?)
open fun startActivity(intent: Intent?, @Nullable options: Bundle?)
Link copied to clipboard
open fun startActivityForResult(intent: Intent?, requestCode: Int)
open fun startActivityForResult(intent: Intent?, requestCode: Int, @Nullable options: Bundle?)
Link copied to clipboard
open fun startIntentSenderForResult(intent: IntentSender?, requestCode: Int, @Nullable fillInIntent: Intent?, flagsMask: Int, flagsValues: Int, extraFlags: Int, @Nullable options: Bundle?)
Link copied to clipboard
Link copied to clipboard

Creates and shows a long duration Toast message from a Fragment.
Logs an error if the Fragment's context is null.

Fragment에서 긴 시간 Toast 메시지를 생성하고 표시합니다.
Fragment의 context가 null이면 에러를 로깅합니다.

Link copied to clipboard

Creates and shows a short duration Toast message from a Fragment.
Logs an error if the Fragment's context is null.

Fragment에서 짧은 시간 Toast 메시지를 생성하고 표시합니다.
Fragment의 context가 null이면 에러를 로깅합니다.

Link copied to clipboard
Link copied to clipboard
inline fun Fragment.withContext(errorMessage: String = "Fragment context is null", block: (Context) -> Unit): Boolean

Executes the given block if the Fragment's context is not null.
Logs an error if the context is null.

Fragment의 context가 null이 아닌 경우 주어진 블록을 실행합니다.
context가 null이면 에러를 로깅합니다.

Link copied to clipboard
inline fun <T> Fragment.withContextResult(errorMessage: String = "Fragment context is null", block: (Context) -> T): T?

Executes the given block and returns a result if the Fragment's context is not null.
Returns null and logs an error if the context is null.

Fragment의 context가 null이 아닌 경우 주어진 블록을 실행하고 결과를 반환합니다.
context가 null이면 null을 반환하고 에러를 로깅합니다.

Link copied to clipboard
inline fun Fragment.withView(errorMessage: String = "Fragment view is null", block: (View) -> Unit): Boolean

Executes the given block if the Fragment's view is not null.
Logs an error if the view is null.

Fragment의 view가 null이 아닌 경우 주어진 블록을 실행합니다.
view가 null이면 에러를 로깅합니다.

Link copied to clipboard
inline fun <T> Fragment.withViewResult(errorMessage: String = "Fragment view is null", block: (View) -> T): T?

Executes the given block and returns a result if the Fragment's view is not null.
Returns null and logs an error if the view is null.

Fragment의 view가 null이 아닌 경우 주어진 블록을 실행하고 결과를 반환합니다.
view가 null이면 null을 반환하고 에러를 로깅합니다.