From 2ab812c89474881462d88200292aa9ba6dfb718e Mon Sep 17 00:00:00 2001 From: 0xflotus <0xflotus@gmail.com> Date: Sun, 13 Jan 2019 23:56:22 +0100 Subject: [PATCH] refactored examples... ... to >= Java 8 --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5845e7b..7e8ba19 100644 --- a/README.md +++ b/README.md @@ -80,28 +80,28 @@ String[] commands = text.split(" "); RxFFmpegInvoke.getInstance().runCommandRxJava(commands).subscribe(new RxFFmpegSubscriber() { @Override public void onFinish() { - if (mProgressDialog != null) - mProgressDialog.cancel(); + Optional.ofNullable(mProgressDialog) + .ifPresent(ProgressDialog::cancel); showDialog("处理成功"); } @Override public void onProgress(int progress) { - if (mProgressDialog != null) - mProgressDialog.setProgress(progress); + Optional.ofNullable(mProgressDialog) + .ifPresent(pd -> pd.setProgress(progress)); } @Override public void onCancel() { - if (mProgressDialog != null) - mProgressDialog.cancel(); + Optional.ofNullable(mProgressDialog) + .ifPresent(ProgressDialog::cancel); showDialog("已取消"); } @Override public void onError(String message) { - if (mProgressDialog != null) - mProgressDialog.cancel(); + Optional.ofNullable(mProgressDialog) + .ifPresent(ProgressDialog::cancel); showDialog("出错了 onError:" + message); } });