Skip to content

Commit 5f53a32

Browse files
Dev_WangDev_Wang
authored andcommitted
略作修改
1 parent 7aa3dc9 commit 5f53a32

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PureMVC_AppFacade_Android
22

3-
#####<font color="#272727" size = "3px">这是库是一个轻量级MVC为Android软件从头开始架构的,特点是轻、解耦、模块化,业务分离,简单实用</font>
3+
#####<font color="#272727" size = "3px">这库是一个轻量级MVC为Android软件从头开始架构的,特点是轻、解耦、模块化,业务分离,简单实用</font>
44

55
#####<font color="#4590a3" size = "3px">This library is a lightweight MVC architecture for Android software from the ground up, featuring light, decoupling, modular, business separation, simple and practical.</font>
66

puremvc_appfacade/src/main/java/com/example/puremvc_appfacade/Runs/core/View.java

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,6 @@ public void notifyObservers(INotification notification) {
3737
}
3838
}
3939

40-
@Override
41-
public void registerObserver(IObserver observer, String notificationName) {
42-
ArrayList<IObserver> observers = iObserverMap.get(notificationName);
43-
if (null == observers || observers.size() <= 0) {
44-
observers = new ArrayList<>();
45-
iObserverMap.put(notificationName, observers);
46-
}
47-
observers.add(observer);
48-
}
49-
50-
@Override
51-
public void removeObserver(Object context, String notificationName) {
52-
ArrayList<IObserver> observers = iObserverMap.get(notificationName);
53-
if (null == observers || observers.size() <= 0) {
54-
return;
55-
}
56-
for (IObserver observer : observers) {
57-
if (observer.comparedNotifyContext(context)){
58-
observers.remove(observer);
59-
break;
60-
}
61-
}
62-
if (observers.size() == 0) {
63-
iObserverMap.remove(notificationName);
64-
}
65-
}
66-
6740
@Override
6841
public void registerMediator(String key, Class cls) {
6942
if (null == key || cls == null) {
@@ -126,6 +99,34 @@ public void removeMediator(String key) {
12699
mediator.onRemove();
127100
}
128101

102+
103+
@Override
104+
public void registerObserver(IObserver observer, String notificationName) {
105+
ArrayList<IObserver> observers = iObserverMap.get(notificationName);
106+
if (null == observers || observers.size() <= 0) {
107+
observers = new ArrayList<>();
108+
iObserverMap.put(notificationName, observers);
109+
}
110+
observers.add(observer);
111+
}
112+
113+
@Override
114+
public void removeObserver(Object context, String notificationName) {
115+
ArrayList<IObserver> observers = iObserverMap.get(notificationName);
116+
if (null == observers || observers.size() <= 0) {
117+
return;
118+
}
119+
for (IObserver observer : observers) {
120+
if (observer.comparedNotifyContext(context)){
121+
observers.remove(observer);
122+
break;
123+
}
124+
}
125+
if (observers.size() == 0) {
126+
iObserverMap.remove(notificationName);
127+
}
128+
}
129+
129130
@Override
130131
public IMediator getMediator(String key) {
131132
if (null == key) {

puremvc_appfacade/src/main/java/com/example/puremvc_appfacade/Runs/protocol/IMediator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
public interface IMediator {
8-
static final String Method_Name = "handleNotification";
8+
String Method_Name = "handleNotification";
99

1010
void onRegister();
1111
void onRemove();

0 commit comments

Comments
 (0)