only allow a reload, when the delay has really changed
authorMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 15:32:04 +0000 (17:32 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 15:32:04 +0000 (17:32 +0200)
MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java

index abdabfc..7cc7e1d 100644 (file)
@@ -41,17 +41,19 @@ public class MS2Debounce extends Activity
        private void updateUI() {
                disableUI();
 
        private void updateUI() {
                disableUI();
 
+               // Calling these is expensive, so cache the result...
                boolean loaded = module.isLoaded();
                boolean safe_to_load = module.is_safe_to_load();
                boolean loaded = module.isLoaded();
                boolean safe_to_load = module.is_safe_to_load();
+               int debounce_delay = module.getDelay();
 
                TextView text = (TextView)findViewById(R.id.text);
 
                TextView text = (TextView)findViewById(R.id.text);
-               text.setText("Current status:\n\nModule loaded: " + loaded + "\ndebounce_delay: " + module.getDelay() + "ms\nsafe_to_load: " + safe_to_load);
+               text.setText("Current status:\n\nModule loaded: " + loaded + "\ndebounce_delay: " + debounce_delay + "ms\nsafe_to_load: " + safe_to_load);
 
                //EditText textDelay = (EditText)findViewById(R.id.debounce_delay);
                //textDelay.setText(module.getSavedDelay());
 
                Button reload = (Button)findViewById(R.id.reload);
 
                //EditText textDelay = (EditText)findViewById(R.id.debounce_delay);
                //textDelay.setText(module.getSavedDelay());
 
                Button reload = (Button)findViewById(R.id.reload);
-               if (loaded) {
+               if (loaded && module.getSavedDelay() != debounce_delay) {
                        reload.setEnabled(true);
                } else {
                        reload.setEnabled(false);
                        reload.setEnabled(true);
                } else {
                        reload.setEnabled(false);
Impressum, Datenschutz