Hello All,

Can someone please advice me on how what is going wrong.

My android app has an expandablelistview and an object (which extends 
BaseExpandableListAdapter) which is set as the adapter for the 
expandablelistview. The object is called logELA (see code snippet below).

My application receives a lot of information from a backend server which I 
display on this expandablelistview. When the backend server resets for any 
reason, I get a lot of messages (firstly deleting all information and 
resending them again). I maintain a local copy so that I can perform any 
updates if necessary. After every delete/add/update message I receive from 
the server I send a message of notifyDataSetChanged to the activity so that 
screen will show the latest information. Note that information can be as 
little as 1 or 2 items or in the hundreds.

The issue is that if the expandablelistview is in focus (as in the user is 
looking at the information on the screen) and if the server resets then the 
application crashes (which processing the deletion and addition). Log cat 
information is not very useful as it does not point to anything related to 
my app although the exception starts with a null-pointer exception.

HOWEVER if the expandablelistview is not in focus (i.e. user is doing 
something else on the screen) and if the server resets then there is no 
issue. Application continues to process the items and everything is fine.

Some code snippets as follow:

logELA object is as follow:
public class callLogExpandableListAdapter extends BaseExpandableListAdapter
{
    ....
    public void addUpdateCDRMessage(....)
    {
        this.logListLock.lock();
        ....
        ....
        // update local cache
        ....
        ....
        // update UI
        Global.mainActivityInstance.notifyUIOnLogUpdate();
this.logListLock.unlock();
    }

    ....
    ....

    public void removeCDRMessage(int cdrId)
    {
    this.logListLock.lock();
    for (int i = 0; i < this.logList.size(); i++)
    {
    if (this.logList.get(i).cdrInfo.getId() == cdrId)
    {
    this.logList.remove(i);
    break;
    }
    }
    
        // update UI
        Global.mainActivityInstance.notifyUIOnLogUpdate();
this.logListLock.unlock();
}


The function notifyUIOnLogUpdate() is in the main activity which is as 
follow:
public void notifyUIOnLogUpdate()
{
runOnUiThread(new Runnable()
{
@Override
public void run()
{
try
{
logELA.notifyDataSetChanged();
}
catch (Exception e)
{
Log.e(LOGTAG, "notifyUIOnLogUpdate(): Exception - " + e.getMessage());
}
finally
{
}
}
});
}

If I comment out notify function call in the removeCDRMessage then the app 
does not crash.
Any ideas of what is going on?

Thanks for your time and help.

Cheers



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

Reply via email to