|
|
@ -54,12 +54,12 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs |
|
|
|
|
|
|
|
|
|
|
|
@Override public void register(Object obj) { |
|
|
|
@Override public void register(Object obj) { |
|
|
|
String targetName = obj.getClass().getName(); |
|
|
|
String targetName = obj.getClass().getName(); |
|
|
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener = mObservers.get(targetName); |
|
|
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener = mObservers.get(getKey(obj)); |
|
|
|
if (listener == null) { |
|
|
|
if (listener == null) { |
|
|
|
listener = createListener(targetName); |
|
|
|
listener = createListener(targetName); |
|
|
|
if (listener != null) { |
|
|
|
if (listener != null) { |
|
|
|
listener.setListener(obj); |
|
|
|
listener.setListener(obj); |
|
|
|
mObservers.put(targetName, listener); |
|
|
|
mObservers.put(getKey(obj), listener); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ALog.e(TAG, "注册错误,没有【" + targetName + "】观察者"); |
|
|
|
ALog.e(TAG, "注册错误,没有【" + targetName + "】观察者"); |
|
|
|
} |
|
|
|
} |
|
|
@ -73,12 +73,16 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs |
|
|
|
for (Iterator<Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>>> iter = |
|
|
|
for (Iterator<Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>>> iter = |
|
|
|
mObservers.entrySet().iterator(); iter.hasNext(); ) { |
|
|
|
mObservers.entrySet().iterator(); iter.hasNext(); ) { |
|
|
|
Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>> entry = iter.next(); |
|
|
|
Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>> entry = iter.next(); |
|
|
|
if (entry.getKey().equals(obj.getClass().getName())) { |
|
|
|
if (entry.getKey().equals(getKey(obj))) { |
|
|
|
iter.remove(); |
|
|
|
iter.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getKey(Object obj) { |
|
|
|
|
|
|
|
return obj.getClass().getName() + obj.hashCode(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 创建代理类 |
|
|
|
* 创建代理类 |
|
|
|
* |
|
|
|
* |
|
|
|