BatchButton area toggling should't happen from anything other than the

UiThread:

Fixes a common error from the market:

android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRoot.checkThread(ViewRoot.java:2802)
at android.view.ViewRoot.invalidateChild(ViewRoot.java:607)
at android.view.ViewRoot.invalidateChildInParent(ViewRoot.java:633)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:2505)
at android.view.View.invalidate(View.java:5139)
at android.view.View.setFlags(View.java:4502)
at android.view.View.setVisibility(View.java:3030)
at
com.fsck.k9.activity.MessageList.hideBatchButtons(MessageList.java:2883)
at
com.fsck.k9.activity.MessageList.toggleBatchButtons(MessageList.java:2906)
at com.fsck.k9.activity.MessageList.access$500(MessageList.java:77)
at
com.fsck.k9.activity.MessageList$MessageListAdapter.pruneDirtyMessages(MessageList.java:2302)
at com.fsck.k9.activity.MessageList$1.run(MessageList.java:811)
This commit is contained in:
Jesse Vincent 2010-11-26 03:53:10 +00:00
parent 4f08820683
commit 23254e8998

View file

@ -2983,45 +2983,58 @@ public class MessageList
private void toggleBatchButtons()
{
if (mSelectedCount < 0)
{
mSelectedCount = 0;
}
int readButtonIconId;
int flagButtonIconId;
runOnUiThread(new Runnable()
{
@Override
public void run()
{
if (mSelectedCount < 0)
{
mSelectedCount = 0;
}
int readButtonIconId;
int flagButtonIconId;
if (mSelectedCount==0)
{
readButtonIconId = R.drawable.ic_button_mark_read;
flagButtonIconId = R.drawable.ic_button_flag;
hideBatchButtons();
}
else
{
boolean newReadState = computeBatchDirection(false);
if (newReadState)
{
readButtonIconId = R.drawable.ic_button_mark_read;
}
else
{
readButtonIconId = R.drawable.ic_button_mark_unread;
}
boolean newFlagState = computeBatchDirection(true);
if (newFlagState)
{
flagButtonIconId = R.drawable.ic_button_flag;
}
else
{
flagButtonIconId = R.drawable.ic_button_unflag;
}
showBatchButtons();
}
mBatchReadButton.setImageResource(readButtonIconId);
mBatchFlagButton.setImageResource(flagButtonIconId);
}
});
if (mSelectedCount==0)
{
readButtonIconId = R.drawable.ic_button_mark_read;
flagButtonIconId = R.drawable.ic_button_flag;
hideBatchButtons();
}
else
{
boolean newReadState = computeBatchDirection(false);
if (newReadState)
{
readButtonIconId = R.drawable.ic_button_mark_read;
}
else
{
readButtonIconId = R.drawable.ic_button_mark_unread;
}
boolean newFlagState = computeBatchDirection(true);
if (newFlagState)
{
flagButtonIconId = R.drawable.ic_button_flag;
}
else
{
flagButtonIconId = R.drawable.ic_button_unflag;
}
showBatchButtons();
}
mBatchReadButton.setImageResource(readButtonIconId);
mBatchFlagButton.setImageResource(flagButtonIconId);
}
class FooterViewHolder