io.reactivex.rxjava3.disposables.CompositeDisposable Java Examples

The following examples show how to use io.reactivex.rxjava3.disposables.CompositeDisposable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitcoinStringAnalyzer.java    From zap-android with MIT License 6 votes vote down vote up
private static void checkIfLnUrl(Context ctx, CompositeDisposable compositeDisposable, @NonNull String inputString, OnDataDecodedListener listener) {
    LnUrlUtil.readLnUrl(ctx, inputString, new LnUrlUtil.OnLnUrlReadListener() {
        @Override
        public void onValidLnUrlWithdraw(LnUrlWithdrawResponse withdrawResponse) {
            listener.onValidLnurlWithdraw(withdrawResponse);
        }

        @Override
        public void onValidLnUrlPayRequest() {
            // ToDo: implement
            listener.onValidLnurlPay();
        }

        @Override
        public void onError(String error, int duration) {
            listener.onError(error, duration);
        }

        @Override
        public void onNoLnUrlData() {
            checkIfRemoteConnection(ctx, compositeDisposable, inputString, listener);
        }
    });
}
 
Example #2
Source File: BitcoinStringAnalyzer.java    From zap-android with MIT License 6 votes vote down vote up
private static void checkIfLnOrBitcoinInvoice(Context ctx, CompositeDisposable compositeDisposable, @NonNull String inputString, OnDataDecodedListener listener) {
    InvoiceUtil.readInvoice(ctx, compositeDisposable, inputString, new InvoiceUtil.OnReadInvoiceCompletedListener() {
        @Override
        public void onValidLightningInvoice(PayReq paymentRequest, String invoice) {
            listener.onValidLightningInvoice(paymentRequest, invoice);
        }

        @Override
        public void onValidBitcoinInvoice(String address, long amount, String message) {
            listener.onValidBitcoinInvoice(address, amount, message);
        }

        @Override
        public void onError(String error, int duration) {
            listener.onError(error, duration);
        }

        @Override
        public void onNoInvoiceData() {
            // No Invoice or Address either, we have unrecognizable data
            listener.onError(ctx.getString(R.string.string_analyzer_unrecognized_data), RefConstants.ERROR_DURATION_SHORT);
        }
    });
}
 
Example #3
Source File: BitcoinStringAnalyzer.java    From zap-android with MIT License 5 votes vote down vote up
private static void checkIfNodeUri(Context ctx, CompositeDisposable compositeDisposable, @NonNull String inputString, OnDataDecodedListener listener) {
    LightningNodeUri nodeUri = LightningParser.parseNodeUri(inputString);

    if (nodeUri != null) {
        listener.onValidNodeUri(nodeUri);

    } else {
        checkIfLnOrBitcoinInvoice(ctx, compositeDisposable, inputString, listener);
    }
}
 
Example #4
Source File: InvoiceUtil.java    From zap-android with MIT License 5 votes vote down vote up
private static void decodeLightningInvoice(Context ctx, OnReadInvoiceCompletedListener listener, String invoice, CompositeDisposable compositeDisposable) {
    PayReqString decodePaymentRequest = PayReqString.newBuilder()
            .setPayReq(invoice)
            .build();

    compositeDisposable.add(LndConnection.getInstance().getLightningService().decodePayReq(decodePaymentRequest)
            .timeout(RefConstants.TIMEOUT_SHORT * TorUtil.getTorTimeoutMultiplier(), TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(paymentRequest -> {
                ZapLog.debug(LOG_TAG, paymentRequest.toString());

                if (paymentRequest.getTimestamp() + paymentRequest.getExpiry() < System.currentTimeMillis() / 1000) {
                    // Show error: payment request expired.
                    listener.onError(ctx.getString(R.string.error_paymentRequestExpired), RefConstants.ERROR_DURATION_SHORT);
                } else if (paymentRequest.getNumSatoshis() == 0) {
                    // Disable 0 sat invoices
                    listener.onError(ctx.getString(R.string.error_notAPaymentRequest), RefConstants.ERROR_DURATION_LONG);
                } else {
                    listener.onValidLightningInvoice(paymentRequest, invoice);
                }
            }, throwable -> {
                // If LND can't decode the payment request, show the error LND throws (always english)
                listener.onError(throwable.getMessage(), RefConstants.ERROR_DURATION_MEDIUM);

                ZapLog.debug(LOG_TAG, throwable.getMessage());
            }));

}
 
Example #5
Source File: BaseDialog.java    From GetApk with MIT License 5 votes vote down vote up
BaseDialog(Builder builder) {
    super(builder.context);
    mBuilder = builder;
    mCompositeDisposable = new CompositeDisposable();
    setCancelable(builder.cancelable);
    setCanceledOnTouchOutside(builder.canceledOnTouchOutside);
    setOnShowListener(builder.showListener);
    setOnDismissListener(builder.dismissListener);
    setOnCancelListener(builder.cancelListener);
    setOnKeyListener(builder.keyListener);
    getWindow().setSoftInputMode(mBuilder.softInputMode);
}
 
Example #6
Source File: RxBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    compositeDisposable = new CompositeDisposable();
}
 
Example #7
Source File: RxBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
@NonNull
public CompositeDisposable getCompositeDisposable() {
    return compositeDisposable;
}
 
Example #8
Source File: HistoryItemAdapter.java    From zap-android with MIT License 4 votes vote down vote up
public HistoryItemAdapter(List<HistoryListItem> dataset, TransactionSelectListener transactionSelectListener, CompositeDisposable compositeDisposable) {
    mItems = dataset;
    mTransactionSelectListener = transactionSelectListener;
    mCompositeDisposable = compositeDisposable;
}
 
Example #9
Source File: LnPaymentViewHolder.java    From zap-android with MIT License 4 votes vote down vote up
public void setCompositeDisposable(CompositeDisposable compositeDisposable) {
    mCompositeDisposable = compositeDisposable;
}
 
Example #10
Source File: BitcoinStringAnalyzer.java    From zap-android with MIT License 4 votes vote down vote up
public static void analyze(Context ctx, CompositeDisposable compositeDisposable, @NonNull String inputString, OnDataDecodedListener listener) {
    checkIfLnUrl(ctx, compositeDisposable, inputString, listener);
}
 
Example #11
Source File: BaseDialog.java    From GetApk with MIT License 2 votes vote down vote up
/**
 * 获取观察者集合
 *
 * @return
 */
public CompositeDisposable getCompositeDisposable() {
    return mCompositeDisposable;
}