]> www.average.org Git - WhereAmI.git/commitdiff
cleaner placing of activation/deactivation elements
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Wed, 8 Feb 2012 13:28:25 +0000 (17:28 +0400)
committerEugene Crosser <Eugene.Crosser@ru.ibm.com>
Wed, 8 Feb 2012 13:28:25 +0000 (17:28 +0400)
src/org/average/whereami/WhereAmI.java

index 94c0139f116211bb12e910a2d96d53acf6272751..9731e099c75d717d95e9d496f0114850b09b8e29 100644 (file)
@@ -165,6 +165,7 @@ public class WhereAmI extends Activity
                 for (int i = 0; i < ut.length; i++) {
                     ut[i].cancel();
                 }
                 for (int i = 0; i < ut.length; i++) {
                     ut[i].cancel();
                 }
+                runningtasks = 0;
                 Time tm = new Time();
                 tm.setToNow();
                 tvs.setText(R.string.failtry);
                 Time tm = new Time();
                 tm.setToNow();
                 tvs.setText(R.string.failtry);
@@ -220,6 +221,12 @@ public class WhereAmI extends Activity
         tvt = (TextView)findViewById(R.id.time);
         tvd = (TextView)findViewById(R.id.date);
         tvs = (TextView)findViewById(R.id.timestamp);
         tvt = (TextView)findViewById(R.id.time);
         tvd = (TextView)findViewById(R.id.date);
         tvs = (TextView)findViewById(R.id.timestamp);
+       ut = new UpdateTarget[] {
+            new UpdateTarget((TextView)findViewById(R.id.phonecall),
+                             new PhoneLog(res, store)),
+            new UpdateTarget((TextView)findViewById(R.id.location),
+                             new LastLocation(res, store))
+        };
     }
 
     /** Called when reactivated */
     }
 
     /** Called when reactivated */
@@ -239,17 +246,10 @@ public class WhereAmI extends Activity
         } else {
             getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
         }
         } else {
             getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
         }
-       ut = new UpdateTarget[] {
-            new UpdateTarget((TextView)findViewById(R.id.phonecall),
-                             new PhoneLog(res, store)),
-            new UpdateTarget((TextView)findViewById(R.id.location),
-                             new LastLocation(res, store))
-        };
-        Log.v(TAG, "created UI, about to start update tasks");
        mHandler.post(updateClock);
        mHandler.post(updateCal);
        mHandler.post(updateInfo);
        mHandler.post(updateClock);
        mHandler.post(updateCal);
        mHandler.post(updateInfo);
-        Log.v(TAG, "created UI, update tasks created");
+        Log.v(TAG, "update tasks scheduled");
     }
 
     /** Called when put to background */
     }
 
     /** Called when put to background */
@@ -258,6 +258,9 @@ public class WhereAmI extends Activity
         super.onPause();
         Log.v(TAG, "going background");
         resetInfo.run();
         super.onPause();
         Log.v(TAG, "going background");
         resetInfo.run();
+       mHandler.removeCallbacks(updateClock);
+       mHandler.removeCallbacks(updateCal);
+       mHandler.removeCallbacks(updateInfo);
     }
 
     /** Called when the activity is destroyed. */
     }
 
     /** Called when the activity is destroyed. */
@@ -265,17 +268,6 @@ public class WhereAmI extends Activity
     public void onDestroy() {
         super.onDestroy();
         Log.v(TAG, "going down");
     public void onDestroy() {
         super.onDestroy();
         Log.v(TAG, "going down");
-       mHandler.removeCallbacks(updateClock);
-       mHandler.removeCallbacks(updateCal);
-       mHandler.removeCallbacks(updateInfo);
-        if (connChangedRegistered) {
-            unregisterReceiver(connChanged);
-            connChangedRegistered = false;
-        }
-        if (managewifi) {
-            boolean wifion = wifiman.setWifiEnabled(false);
-            Log.v(TAG, "disabling wifi result " + wifion);
-        }
     }
 
     /** Called when the menu is activated. */
     }
 
     /** Called when the menu is activated. */