From 80f235c3ac05e57fe1f878c37cb141374e643e50 Mon Sep 17 00:00:00 2001 From: Jacek Kowalski <Jacek@jacekk.info> Date: Sat, 17 Jan 2015 21:13:39 +0000 Subject: [PATCH] Extract TextWatcher to separate variable for re-use. --- app/src/main/java/net/jacekk/bridge/android/MainActivity.java | 44 ++++++++++++++------------------------------ 1 files changed, 14 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/net/jacekk/bridge/android/MainActivity.java b/app/src/main/java/net/jacekk/bridge/android/MainActivity.java index 744ecd6..e7fe4cd 100644 --- a/app/src/main/java/net/jacekk/bridge/android/MainActivity.java +++ b/app/src/main/java/net/jacekk/bridge/android/MainActivity.java @@ -151,39 +151,23 @@ NVToggle.setOnClickListener(baClickListener); NNToggle.setOnClickListener(baClickListener); - PCInput.addTextChangedListener( - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { - } + TextWatcher textWatcher = new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { + } - @Override - public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { - } + @Override + public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { + } - @Override - public void afterTextChanged(Editable editable) { - updateResults(); - } - } - ); + @Override + public void afterTextChanged(Editable editable) { + updateResults(); + } + }; - TricksInput.addTextChangedListener( - new TextWatcher() { - @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { - } - - @Override - public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { - } - - @Override - public void afterTextChanged(Editable editable) { - updateResults(); - } - } - ); + PCInput.addTextChangedListener(textWatcher); + TricksInput.addTextChangedListener(textWatcher); } public void updateResults() { -- Gitblit v1.9.1