1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Avoid division by zero.

Fixes issue 2259
This commit is contained in:
cketti 2010-09-03 00:56:19 +00:00
parent 8fa1c793ea
commit 0c27a1ab0e

View File

@ -308,10 +308,14 @@ public class MessageList
if (mCurrentFolder != null && mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0) if (mCurrentFolder != null && mCurrentFolder.loading && mAdapter.mListener.getFolderTotal() > 0)
{ {
level = (Window.PROGRESS_END / mAdapter.mListener.getFolderTotal()) * (mAdapter.mListener.getFolderCompleted()) ; int divisor = mAdapter.mListener.getFolderTotal();
if (level > Window.PROGRESS_END) if (divisor != 0)
{ {
level = Window.PROGRESS_END; level = (Window.PROGRESS_END / divisor) * (mAdapter.mListener.getFolderCompleted()) ;
if (level > Window.PROGRESS_END)
{
level = Window.PROGRESS_END;
}
} }
} }
@ -2061,7 +2065,7 @@ public class MessageList
private void addOrUpdateMessages(final Account account, final String folder, final List<Message> providedMessages, final boolean verifyAgainstSearch) private void addOrUpdateMessages(final Account account, final String folder, final List<Message> providedMessages, final boolean verifyAgainstSearch)
{ {
// we copy the message list because the callback doesn't expect // we copy the message list because the callback doesn't expect
// the callbacks to mutate it. // the callbacks to mutate it.
final List<Message> messages = new ArrayList<Message>(providedMessages); final List<Message> messages = new ArrayList<Message>(providedMessages);
runOnUiThread(new Runnable() runOnUiThread(new Runnable()