Talk is Cheap.
public class AppEvent {
private static AtomicInteger atomicInteger = new AtomicInteger(1000);
// 標記生成
public static int newTag() {
return atomicInteger.incrementAndGet();
}
// 標記
private int tag;
// 傳遞數(shù)據(jù)
public Object obj;
private AppEvent(int tag) {
this.tag = tag;
}
private AppEvent(int tag, Object obj) {
this(tag);
this.obj = obj;
}
/**
* 有數(shù)據(jù)傳輸
*/
public static AppEvent newInstance(int tag, Object obj) {
return new AppEvent(tag, obj);
}
/**
* 無數(shù)據(jù)傳輸
*/
public static AppEvent newInstance(int tag) {
return new AppEvent(tag);
}
/**
* 事件匹配
*/
public boolean match(int tag) {
return this.tag == tag;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者