]> git.zerfleddert.de Git - ms2-fixes/blobdiff - MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java
only allow a reload, when the delay has really changed
[ms2-fixes] / MS2Debounce / src / de / rmdir / ms2debounce / MS2Debounce.java
index 3b4804cf67c506594010ac58aa459a99cfc1dd31..7cc7e1d488345f45db8819974d2a3f668274c029 100644 (file)
@@ -7,6 +7,7 @@ import android.os.Bundle;
 import android.content.Intent;
 import android.content.DialogInterface;
 import android.widget.TextView;
+import android.widget.EditText;
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.view.View;
@@ -38,17 +39,21 @@ public class MS2Debounce extends Activity
        }
 
        private void updateUI() {
-               TextView text = (TextView)findViewById(R.id.text);
-
                disableUI();
 
+               // Calling these is expensive, so cache the result...
                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);
+               text.setText("Current status:\n\nModule loaded: " + loaded + "\ndebounce_delay: " + debounce_delay + "ms\nsafe_to_load: " + safe_to_load);
 
-               text.setText("Current status:\n\nModule loaded: " + loaded + "\ndebounce_delay: " + module.getDelay() + "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);
-               if (loaded) {
+               if (loaded && module.getSavedDelay() != debounce_delay) {
                        reload.setEnabled(true);
                } else {
                        reload.setEnabled(false);
@@ -69,6 +74,7 @@ public class MS2Debounce extends Activity
                }
 
                CheckBox on_boot = (CheckBox)findViewById(R.id.on_boot);
+               on_boot.setChecked(module.get_on_boot());
                if (safe_to_load) {
                        on_boot.setEnabled(true);
                } else {
@@ -117,6 +123,12 @@ public class MS2Debounce extends Activity
                updateUI();
        }
 
+       public void toggle_on_boot(View view) {
+               CheckBox on_boot = (CheckBox)view;
+
+               module.set_on_boot(on_boot.isChecked());
+       }
+
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
                MenuInflater inflater = getMenuInflater();
Impressum, Datenschutz