TransactionDetailPresenter extends BasePresenter<TransactionDetailContract.View> implements TransactionDetailContract.Presenter { @SuppressLint("CheckResult") @Override public void loadData() { if (mTransaction != null) { getWalletNameByAddressFromWalletDB(mTransaction.getFrom()) .flatMap(new Function<String, SingleSource<String>>() { @Override public SingleSource<String> apply(String s) throws Exception { if (TextUtils.isEmpty(s)) { return getWalletNameByAddressFromAddressDB(mTransaction.getFrom()); } else { return Single.just(s); } } }) .compose(RxUtils.getSingleSchedulerTransformer()) .compose(RxUtils.bindToLifecycle(getView())) .compose(LoadingTransformer.bindToSingleLifecycle(currentActivity())) .subscribe(new Consumer<String>() { @Override public void accept(String walletName) throws Exception { if (isViewAttached()) { getView().setTransactionDetailInfo(mTransaction, mQueryAddressList, walletName); } } }); } }  @Override void init(); @SuppressLint("CheckResult") @Override void loadData(); @SuppressLint("CheckResult") @Override void updateTransactionDetailInfo(Transaction transaction);  }
@Test public void testLoadData() { Single.fromCallable(new Callable<String>() { @Override public String call() throws Exception { return "0x2e95e3ce0a54951eb9a99152a6d5827872dfb4fd"; } }).flatMap(new Function<String, SingleSource<String>>() { @Override public SingleSource<String> apply(String s) throws Exception { if (TextUtils.isEmpty(s)) { return Single.fromCallable(new Callable<String>() { @Override public String call() throws Exception { return "0x2e95e3ce0a54951eb9a99152a6d5827872dfb4fd"; } }); } else { return Single.just(s); } } }).subscribe(new Consumer<String>() { @Override public void accept(String s) throws Exception { System.out.println("====================" + s); } }); }