Base View Binding Activity
A base Activity class for Activities that use ViewBinding.
Extends ParentsBindingActivity to provide common binding functionality.
ViewBinding을 사용하는 Activity를 위한 기본 Activity 클래스입니다.
ParentsBindingActivity를 상속받아 공통 바인딩 기능을 제공합니다.
Why this class exists / 이 클래스가 필요한 이유:
Android's ViewBinding requires manual inflate() calls and setContentView() setup for each Activity.
This class eliminates boilerplate by accepting an inflate function reference and automatically setting up the binding.
Provides type-safe view access without findViewById() or synthetic imports.
Android의 ViewBinding은 각 Activity마다 수동으로 inflate() 호출 및 setContentView() 설정이 필요합니다.
이 클래스는 inflate 함수 참조를 받아 자동으로 바인딩을 설정하여 보일러플레이트를 제거합니다.
findViewById()나 synthetic import 없이 타입 안전한 뷰 접근을 제공합니다.
Design decisions / 설계 결정 이유:
Uses constructor parameter for inflate function reference to enable compile-time type safety.
Implements final createBinding() to prevent subclasses from breaking the binding initialization contract.
Automatically calls setContentView() in createBinding() to ensure views are ready in onCreate().
컴파일 타임 타입 안전성을 위해 생성자 파라미터로 inflate 함수 참조를 사용합니다.
final createBinding()을 구현하여 하위 클래스가 바인딩 초기화 계약을 깨는 것을 방지합니다.
createBinding()에서 자동으로 setContentView()를 호출하여 onCreate()에서 뷰가 준비되도록 보장합니다.
Usage / 사용법:
Extend this class with your Activity and pass the ViewBinding inflate function reference.
Access views through the
getBinding()method in onCreate() or later lifecycle methods.Override onCreate(binding, savedInstanceState) to perform initial view setup after binding is ready.
Activity에서 이 클래스를 상속받고 ViewBinding inflate 함수 참조를 전달하세요.
onCreate() 또는 이후 생명주기 메서드에서
getBinding()메서드를 통해 뷰에 접근하세요.바인딩이 준비된 후 초기 뷰 설정을 수행하려면 onCreate(binding, savedInstanceState)를 오버라이드하세요.
Usage example:
class MainActivity : BaseViewBindingActivity<ActivityMainBinding>(ActivityMainBinding::inflate) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Binding is already initialized and set as content view
getBinding().textView.text = "Hello"
}
}Parameters
The type of ViewBinding class.
ViewBinding 클래스의 타입.
The inflate function reference for the ViewBinding class (e.g., ActivityMainBinding::inflate).
ViewBinding 클래스의 inflate 함수 참조 (예: ActivityMainBinding::inflate).
See also
For the parent class providing binding lifecycle.
바인딩 생명주기를 제공하는 부모 클래스는 ParentsBindingActivity를 참조하세요.
For DataBinding-enabled Activity.
DataBinding을 사용하는 Activity는 BaseDataBindingActivity를 참조하세요.
Properties
Functions
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에서 호출하세요.
Gets a color using ContextCompat for backward compatibility.
역호환성을 위해 ContextCompat을 사용하여 색상을 가져옵니다.
Gets dimension pixel offset for the given dimension resource.
주어진 dimension 리소스의 픽셀 오프셋을 가져옵니다.
Gets dimension pixel size for the given dimension resource.
주어진 dimension 리소스의 픽셀 크기를 가져옵니다.
Gets a drawable using ContextCompat for backward compatibility.
역호환성을 위해 ContextCompat을 사용하여 drawable을 가져옵니다.
Safely gets a drawable, returning null if resource is not found or invalid.
리소스를 찾을 수 없거나 유효하지 않은 경우 null을 반환하여 안전하게 drawable을 가져옵니다.
Gets integer value from resources.
리소스에서 정수 값을 가져옵니다.
Safely gets a string, returning empty string if resource is not found or invalid.
리소스를 찾을 수 없거나 유효하지 않은 경우 빈 문자열을 반환하여 안전하게 문자열을 가져옵니다.
Checks if the context is destroyed or finishing.
컨텍스트가 파괴되었거나 종료 중인지 확인합니다.
Called when the binding is initialized in onCreate().
Implement setup logic that requires binding here.
onCreate에서 바인딩이 초기화된 후 호출됩니다.
바인딩이 필요한 초기화 로직을 여기서 수행하세요.
Collect ViewModel events here.
Use repeatOnLifecycle(Lifecycle.State.STARTED) to avoid duplicate collectors.
ViewModel 이벤트를 수집하는 훅입니다.
중복 수집 방지를 위해 repeatOnLifecycle(Lifecycle.State.STARTED)를 사용하세요.
Requests runtime permissions and returns denied results via callback.
Delegates to PermissionRequester for actual permission handling.
런타임 권한을 요청하고 콜백을 통해 거부 결과를 반환합니다.
실제 권한 처리는 PermissionRequester에 위임합니다.
Creates a long duration Toast without showing it.
Allows further customization before displaying.
표시하지 않고 긴 시간 Toast를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates a short duration Toast without showing it.
Allows further customization before displaying.
표시하지 않고 짧은 시간 Toast를 생성합니다.
표시하기 전에 추가 커스터마이징이 가능합니다.
Creates and shows a long duration Toast message.
긴 시간 Toast 메시지를 생성하고 표시합니다.
Creates and shows a short duration Toast message.
짧은 시간 Toast 메시지를 생성하고 표시합니다.