Base Fragment
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
The layout resource ID for the fragment.
Fragment의 레이아웃 리소스 ID.
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.
권한 관리 기능이 있는 부모 클래스.
For ViewBinding-enabled Fragment.
ViewBinding을 사용하는 Fragment.
For DataBinding-enabled Fragment.
DataBinding을 사용하는 Fragment.
Properties
Functions
Inflates the layout and returns the root view.
레이아웃을 인플레이션하고 루트 뷰를 반환합니다.
Requests permissions using the delegate.
Call only after the Fragment is attached (isAdded == true).
델리게이트를 사용하여 권한을 요청합니다.
Fragment가 attach된 이후(isAdded == true)에만 호출하세요.
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이면 에러를 로깅합니다.
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이면 에러를 로깅합니다.
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이면 에러를 로깅합니다.
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이면 에러를 로깅합니다.
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이면 에러를 로깅합니다.
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을 반환하고 에러를 로깅합니다.
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을 반환하고 에러를 로깅합니다.