Gaeburider
Gaeburider

Reputation: 158

Bad practise to call listener method manually

I'm writing two listener for EditTexts : One is

onFocusChange(View v, boolean hasFocus)

which implements the code to switch to the next EditText and enables the custom keyboard. The second is

public void onClick(View v)

which should request the focus on the view and also enables the custom keyboard. So I could simply call the onFocusChange(View v, boolean hasFocus) like this

onFocusChange(v, true);

and it would do its job.

Is it bad practise to call a listener methode manually (without throwing an event) or should I write an seperate private method as recommended in this post. Which practise is better/cleaner?

Upvotes: 1

Views: 1260

Answers (1)

lordoku
lordoku

Reputation: 1112

I think functionally it doesn't matter. However I'd argue that a listen should follow an event, so writing a private method that does the work would probably be cleaner. For reuse, you could have the listener call this method.

Upvotes: 4

Related Questions