withContext

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이면 에러를 로깅합니다.

Return

true if the block was executed, false if context was null.

블록이 실행되었으면 true, context가 null이면 false.

Parameters

errorMessage

Custom error message to log when context is null.

context가 null일 때 로깅할 커스텀 에러 메시지.

block

The block to execute with the non-null context.

null이 아닌 context로 실행할 블록.