RxJava简单使用一

1.发出指令RxBus.get().post(Constants.RXBUS_REFRESH_MAP, "refresh");

2.处理指令
private Observable observable = null;

observable = RxBus.get().register(Constants.RXBUS_REFRESH_MAP);
observable.subscribeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() {    
@Override    
public void call(String s) {        
if (s.equals("refresh")) {                    frame_hudview.setVisibility(View.VISIBLE);            mStartPoints.add(ConstantsBean.getLocationNavi().getmStartLatlng());            mEndPoints.add(ConstantsBean.getLocationNavi().getmEndLatlng());           
 mAMapNavi.calculateDriveRoute(mStartPoints, mEndPoints, null, PathPlanningStrategy.DRIVING_DEFAULT);        
} else if ("reLoad".equals(s)) {            frame_hudview.setVisibility(View.VISIBLE);            mStartPoints.add(ConstantsBean.getLocationNavi().getmStartLatlng());            mEndPoints.add(ConstantsBean.getLocationNavi().getmEndLatlng());            
mAMapNavi.calculateDriveRoute(mStartPoints, mEndPoints, null, PathPlanningStrategy.DRIVING_DEFAULT);       
 } else if ("finish".equals(s)) {            frame_hudview.setVisibility(View.GONE);            mAMapNavi.stopNavi();            
mTtsManager.stopSpeaking();            //显示导航图标        
}    
}
});

你可能感兴趣的:(RxJava简单使用一)