Hello all,

I have a semi-complicated problem and hoping that someone here will be
able to help me.

On a click event I create a thread and start a long-running operation
based on this method (http://jnb.ociweb.com/jnb/jnbJan2009.html).
After the long-running task is completed, it does a callback to
another method, which does a post to the handler:

@Override
public void contentSearchModelChanged(Model_ContentSearch csm,
ArrayList<Class_Reminder> newRemindersList) {
    remindersList = newRemindersList;
    mHandler.post(mUpdateDisplayRunnable);
}
Which calls a Runnable:

// post this to the Handler when the background thread completes
private final Runnable mUpdateDisplayRunnable = new Runnable() {
  public void run() {
    updateDisplay();
  }
};
Finally, here is what my updateDisplay() method is doing:

private void updateDisplay() {
    if (csModel.getState() != Model_ContentSearch.State.RUNNING) {
        if(remindersList != null && remindersList.size() > 0){
                r_adapter = new
ReminderAdapater(Activity_ContentSearch.this, remindersList,
thisListView);
                thisListView.setAdapter(r_adapter);
                r_adapter.notifyDataSetChanged();
        }
    }
}
This works beautifully when I do this normally. However, if I change
the orientation while the long-running operation is running, it
doesn't work. It does make the callback properly, and the
remindersList does have items in it. But when it gets to this line:

r_adapter.notifyDataSetChanged();
Nothing happens. The odd thing is, if I do another submit and have it
run the whole process again (without changing orientation), it
actually updates the view twice, once for the previous submit and
again for the next. So the view updates once with the results of the
first submit, then again with the results of the second submit a
second later. So the adapater DID get the data, it just isn't
refreshing the view.

I know this has something to do with the orientation change, but I
can't for the life of me figure out why. Can anyone help? Or, can
anyone suggest an alternative method of handling threads with
orientation changes?

Bara

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to