[android] Fix null pointer crash.

This commit is contained in:
vng 2012-07-26 02:11:35 -07:00 committed by Alex Zolotarev
parent 984822ca02
commit 5d1c3e852b

View file

@ -578,10 +578,17 @@ public class DownloadUI extends ListActivity implements MapStorage.Listener
View v = list.getChildAt(position - list.getFirstVisiblePosition());
if (v != null)
{
ViewHolder holder = (ViewHolder) v.getTag();
holder.m_summary.setText(String.format(m_context.getString(R.string.downloading_touch_to_cancel),
current * 100 / total));
v.invalidate();
final ViewHolder holder = (ViewHolder) v.getTag();
// This function actually is a callback from downloading engine and
// when using cached views and holders, summary may be null
// because of different ListView context.
if (holder != null && holder.m_summary != null)
{
holder.m_summary.setText(String.format(m_context.getString(R.string.downloading_touch_to_cancel),
current * 100 / total));
v.invalidate();
}
}
}
}