Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- Design Pattern
- 추상팩토리패턴
- 안드로이드 디자인시스템
- define
- 디자인패턴
- 팩토리 메소드
- factory method
- 옵저버 패턴
- 코틀린
- designPattern
- ㅓ
- PrototypePattern
- 디자인패턴 #
- 프로토타입 패턴
- Abstract Factory
- 싱글톤
- 추상 팩토리
- android designsystem
- Coroutines
- 빌터패턴
- Observer Pattern
- compose
- Singleton
- ㅋㅁ
- Kotlin
- builderPattern
- material3
- Functional Programming
- 코루틴
- 함수형프로그래밍
Archives
- Today
- Total
오늘도 더 나은 코드를 작성하였습니까?
사용자가 정의한 LifecycleOwner 구현하기 본문
만약 LifecycleOwner를 직접 구현하려면 LifecycleRegistry 클래스를 사 용수 있다.
다음 코드 예에서와 같이 LifecycleRegistry 클래스에 이벤트를 전달해야 합니다.
public class MyActivity extends Activity implements LifecycleOwner {
private LifecycleRegistry lifecycleRegistry;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
lifecycleRegistry = new LifecycleRegistry(this);
lifecycleRegistry.markState(Lifecycle.State.CREATED); // 이벤트 전달.
}
@Override
public void onStart() {
super.onStart();
lifecycleRegistry.markState(Lifecycle.State.STARTED); // 이벤트 전달.
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return lifecycleRegistry; // 이벤트 전달.
}
}
'Android Jetpack Architecture > LifeCycle' 카테고리의 다른 글
| 생명주기 인식 구성요소의 권장사항 및 예시 (0) | 2020.08.13 |
|---|---|
| Lifecycle - aware 컴포넌트 (0) | 2020.08.13 |
