From: David A. Velasco Date: Wed, 10 Oct 2012 11:45:04 +0000 (+0200) Subject: Fixed crash when download notification is pressed in landscape mode X-Git-Tag: oc-android-1.4.3~158 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/b416f87c9201b63cb162a5ff3a059a2de81863a4?ds=inline Fixed crash when download notification is pressed in landscape mode --- diff --git a/src/com/owncloud/android/ui/activity/FileDetailActivity.java b/src/com/owncloud/android/ui/activity/FileDetailActivity.java index 539cf262..7937b901 100644 --- a/src/com/owncloud/android/ui/activity/FileDetailActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDetailActivity.java @@ -52,6 +52,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File private boolean mConfigurationChangedToLandscape = false; private FileDownloaderBinder mDownloaderBinder = null; + private ServiceConnection mConnection = null; @Override protected void onCreate(Bundle savedInstanceState) { @@ -64,6 +65,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File ); if (!mConfigurationChangedToLandscape) { + mConnection = new DetailsServiceConnection(); bindService(new Intent(this, FileDownloader.class), mConnection, Context.BIND_AUTO_CREATE); setContentView(R.layout.file_activity_details); @@ -88,14 +90,14 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File /** Defines callbacks for service binding, passed to bindService() */ - private ServiceConnection mConnection = new ServiceConnection() { + private class DetailsServiceConnection implements ServiceConnection { @Override public void onServiceConnected(ComponentName className, IBinder service) { mDownloaderBinder = (FileDownloaderBinder) service; FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); if (fragment != null) - fragment.updateFileDetails(); // a new chance to get the mDownloadBinder through getDownloadBinder() + fragment.updateFileDetails(); // let the fragment gets the mDownloadBinder through getDownloadBinder() (see FileDetailFragment#updateFileDetais()) } @Override @@ -108,7 +110,10 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File @Override public void onDestroy() { super.onDestroy(); - unbindService(mConnection); + if (mConnection != null) { + unbindService(mConnection); + mConnection = null; + } }