I suspect that you are talking about this code: with the if on line 6, and possibly other locations.
When the code is executed correctly then you are probably correct and that those if statements are not needed.
However, you can easily call the setListeners method from nearly anywhere you want to and you can pass in bad/null values.
Or you may not be passing in the null values, but someone else who uses your code in the future might.
This could be a simple as a typo or someone trying to hack your code.
With a very simple if like this you are guarding your code against being misused (at least partly).
Now if you were to use Kotlin you would end up with something kind of like the following code which has been commented out because I'm not too sure if it works.
Kotlin deals with null checking differently then Java which is why you may not have to program in the null checks.
By the way, did you know that you can have both Java and Kotlin files in the same Android project running together in unison?
In doing this you can migrate away from Java and toward Kotlin.
Not only that, but Google officially supports Kotlin for Android app development.