with Context Result
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을 반환하고 에러를 로깅합니다.
Return
The result of the block, or null if context was null.
블록의 결과, 또는 context가 null이면 null.
Parameters
T
The type of the result returned by the block.
블록이 반환하는 결과의 타입.
error Message
Custom error message to log when context is null.
context가 null일 때 로깅할 커스텀 에러 메시지.
block
The block to execute with the non-null context.
null이 아닌 context로 실행할 블록.