Issue #2431 OpenCV Manager UI crashes at start fixed.
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Thu, 11 Oct 2012 10:04:11 +0000 (14:04 +0400)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Thu, 11 Oct 2012 10:39:42 +0000 (14:39 +0400)
Data rase in OpenCV Manager connection fixed.

android/service/engine/src/org/opencv/engine/manager/ManagerActivity.java

index b8fc2d9..fc7db03 100644 (file)
@@ -196,7 +196,7 @@ public class ManagerActivity extends Activity
     protected void onResume() {
        super.onResume();
        Log.d(TAG, "Filling package list on resume");
-        if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE))
+        if (!bindService(new Intent("org.opencv.engine.BIND"), new OpenCVEngineServiceConnection(), Context.BIND_AUTO_CREATE))
         {
                TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
                EngineVersionView.setText("not avaliable");
@@ -221,7 +221,7 @@ public class ManagerActivity extends Activity
                public void onReceive(Context context, Intent intent) {
                        Log.d("OpenCVManager/Reciever", "Bradcast message " + intent.getAction() + " reciever");
                        Log.d("OpenCVManager/Reciever", "Filling package list on broadcast message");
-               if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE))
+               if (!bindService(new Intent("org.opencv.engine.BIND"), new OpenCVEngineServiceConnection(), Context.BIND_AUTO_CREATE))
                {
                        TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
                        EngineVersionView.setText("not avaliable");
@@ -229,8 +229,8 @@ public class ManagerActivity extends Activity
                }
        };
 
-    protected ServiceConnection mServiceConnection = new ServiceConnection() {
-
+    protected class OpenCVEngineServiceConnection implements ServiceConnection
+    {
                public void onServiceDisconnected(ComponentName name) {
                        // TODO Auto-generated method stub
                        
@@ -262,11 +262,11 @@ public class ManagerActivity extends Activity
                        Log.d(TAG, "Filling package list on service connection");
                        FillPackageList();
 
-                       unbindService(mServiceConnection);
+                       unbindService(this);
                }
        };
        
-       protected void FillPackageList()
+       synchronized protected void FillPackageList()
        {
                synchronized (mListViewItems) {
                        mMarket.mIncludeManager = false;