[Android] container linkage through comparison

When the intermediate container changes, the title bar should also change

Design comparison basis:

Abstract methods are defined in the abstract class baseview. Each inherited view must be implemented. A unique int constant is defined for its own interface as the comparison basis

Reduce coupling between containers:

The intermediate container does the work of other containers and has a high degree of coupling. The intermediate container should only "notify" other containers

Use the observer mode to add monitoring for intermediate container changes to solve the problem of multiple associated containers

Observer mode:

Observed object = = = = = > intermediate container

Observer ============= > Title container

MainActivity.java

MiddleManager.java

TitleManager.java

IndexView.java

ConstantValue.java

1. The intermediate container becomes the observed object and inherits observable

2. The title container becomes an observer and implements the observer interface

3. Establish the relationship between the observer and the observed, and the title is added to the array of intermediate containers

4. Once the intermediate container changes, modify the Boolean value and notify all observers. Update()

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>