-1
Java 8 lambda/stream()を使用して、より直感的な方法で関数型プログラミングでこのメソッドを書く方法は?メソッドをJava 8ラムダに変換
int animation = R.style.DialogAnimationSlideHorizontal;
String body;
String subject = mSubjectView.getText().toString();
BaseDialog dialog = dialogFactory.getType(DialogTypes.DIALOG_FULL);
if (!checkFields()) {
// one of the recipients is invalid.
body = getString(R.string.bad_address);
dialog.showDialog(body, animation, new DialogBuilder.Positive() {
@Override
public void handleClick(DialogInterface dialogInterface, View view) {
// do nothing
}
});
} else if (Helpers.isEmpty(subject)) {
// Yup, empty... send the message without a subject?
body = getString(R.string.empty_subject_compose);
dialog.showDialog(body, animation, new DialogBuilder.Positive() {
@Override
public void handleClick(DialogInterface dialogInterface, View view) {
// user accepted to send anyway.
mWebView.getComposeContent();
}
});
} else {
// everything is correct! send the message.
mWebView.getComposeContent();
}
'checkFields()'のようなメソッドを含むより広範なオーバーホールを試してみてください(そのコードが一連のフィールドをチェックすると、ストリームの候補になります)。機能は、全体的な機能スタイル・アーキテクチャーと組み合わされたときに最も効果的です。 – zapl