From 0e927e914b80baf2d37439f8b99134cfe274a1d5 Mon Sep 17 00:00:00 2001 From: Lixin Yue Date: Tue, 9 Mar 2010 12:48:23 +0800 Subject: [PATCH] Not update TransferActivity button during activity creating. This is to fix below issue: when an ongoing transfer is almost to complete, click the ongoing notification to launch TransferActivity, there will be possible crash due to NullPointerException. Root casue is: when TransferActivity onCreate() is called, the transfer is still ongoing, so mIsComplete is false; but when onCreate() call to updateProgressbar(), the transfer may change to complete, and then updateButton() will be called; In updateButton(), mAlert (which will be initialized in father class AlertActivity) still not intialized, which caused NullPointerException. Change-Id: Ibfe363f3822386a38b9b108e29f60ad6673f70f6 --- .../android/bluetooth/opp/BluetoothOppTransferActivity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java index 4290d782..d63a6faa 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java +++ b/src/com/android/bluetooth/opp/BluetoothOppTransferActivity.java @@ -113,6 +113,10 @@ public class BluetoothOppTransferActivity extends AlertActivity implements /** Observer to get notified when the content observer's data changes */ private BluetoothTransferContentObserver mObserver; + // do not update button during activity creating, only update when db + // changes after activity created + private boolean mNeedUpdateButton = false; + private class BluetoothTransferContentObserver extends ContentObserver { public BluetoothTransferContentObserver() { super(new Handler()); @@ -121,6 +125,7 @@ public class BluetoothOppTransferActivity extends AlertActivity implements @Override public void onChange(boolean selfChange) { if (V) Log.v(TAG, "received db changes."); + mNeedUpdateButton = true; updateProgressbar(); } } @@ -245,6 +250,8 @@ public class BluetoothOppTransferActivity extends AlertActivity implements customizeViewContent(); + // no need update button when activity creating + mNeedUpdateButton = false; updateProgressbar(); return mView; @@ -435,12 +442,10 @@ public class BluetoothOppTransferActivity extends AlertActivity implements // DIALOG_RECEIVE_COMPLETE_SUCCESS/DIALOG_RECEIVE_COMPLETE_FAIL // Handle the case when DIALOG_SEND_ONGOING evolve to // DIALOG_SEND_COMPLETE_SUCCESS/DIALOG_SEND_COMPLETE_FAIL - if (!mIsComplete && BluetoothShare.isStatusCompleted(mTransInfo.mStatus)) { - + if (!mIsComplete && BluetoothShare.isStatusCompleted(mTransInfo.mStatus) + && mNeedUpdateButton) { displayWhichDialog(); - updateButton(); - customizeViewContent(); } } -- 2.11.0