Well, I think I have something here, perhaps it will be useful to others. Who knows how long it will work properly.
So prelude: I needed to be able to tell when a user had completed changing an edit text so that I could then redo a computation and update a graph. I really have no room for an "update" button and felt from a UI standpoint it would have quickly become annoying.
Codewise:
I have a "display" method with an inner "watcher" class with a watch() method. The watcher class has many things, including the various editTexts which watch()..watches. I ddapted some code I found here, which determines if the keyboard is open or closed. currentView is the root view of the graphing activity.
currentView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// TODO Auto-generated method stub
Rect r = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
int screenHeight = getWindow().getDecorView().getRootView().getHeight();
int heightDifference = screenHeight - (r.bottom - r.top);
if (MainActivity.debug) Log.d("Keyboard Size", "Size: " + heightDifference+" screenHeight: "+screenHeight);
boolean keyboardVisible = heightDifference > (screenHeight / 3);
if (keyboardToggle) { // someone has updated one of the editTexts
if(!keyboardVisible) { // and they have closed the soft keyboard so are done
// do something
if(MainActivity.debug) {
if(rIDchangedET == firstET.getId()) Log.i(TAG,"update the first thing");
if(rIDchangedET == secondET.getId()) Log.i(TAG,"update the second thing");
if(rIDchangedET == thirdET.getId()) Log.i(TAG,"update the third thing");
}
// reset the keyboard toggle
keyboardToggle = false;
}
}
}
});
This helps but in a somewhat backward way. Knowing open/closed by itself is not useful within any of the text watchers as those are not triggered by the act of closing the keyboard (so you can't actually test for it within the listener)
However, thinking about it a bit I added a boolean keyboard toggle which is set to true in the afterTextChanged of the addTextChangedListener. In addition, I put the rID of that editText in another class variable.
The code which checks the keyboard status then calls the appropriate updating procedure if the a) keyboard is closed b) some text has actually been changed (keyboard toggle) and c) uses the rID to determine what procedure to then call.
I know its a bit convoluted, but it does seem to work.