Commit 5dba56a1 authored by Bartek Fabiszewski's avatar Bartek Fabiszewski
Browse files

Minor cleanup

parent 33bf533c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ class DbAccess {
                mDbHelper = DbHelper.getInstance(context.getApplicationContext());
                db = mDbHelper.getWritableDatabase();
            }
            if (Logger.DEBUG) { Log.d(TAG, "[+openCount = " + openCount + "]"); }
        }
    }

@@ -335,6 +336,7 @@ class DbAccess {
                    mDbHelper.close();
                }
            }
            if (Logger.DEBUG) { Log.d(TAG, "[-openCount = " + openCount + "]"); }
        }
    }

+10 −11
Original line number Diff line number Diff line
@@ -91,14 +91,6 @@ public class MainActivity extends AppCompatActivity {
        locLabel = (TextView) findViewById(R.id.location_status);
        locLed = (TextView) findViewById(R.id.loc_led);

        db = DbAccess.getInstance();
        db.open(this);
        String trackName = db.getTrackName();
        if (trackName != null) {
            updateTrackLabel(trackName);
        }
        registerBroadcastReceiver();
        updateStatus();
    }

    /**
@@ -109,6 +101,13 @@ public class MainActivity extends AppCompatActivity {
        super.onResume();
        if (Logger.DEBUG) { Log.d(TAG, "[onResume]"); }

        db = DbAccess.getInstance();
        db.open(this);
        String trackName = db.getTrackName();
        if (trackName != null) {
            updateTrackLabel(trackName);
        }

        if (LoggerService.isRunning()) {
            toggleButton.setText(TXT_STOP);
            setLocLed(LED_GREEN);
@@ -127,6 +126,9 @@ public class MainActivity extends AppCompatActivity {
    protected void onPause() {
        if (Logger.DEBUG) { Log.d(TAG, "[onPause]"); }
        unregisterReceiver(mBroadcastReceiver);
        if (db != null) {
            db.close();
        }
        super.onPause();
    }

@@ -136,9 +138,6 @@ public class MainActivity extends AppCompatActivity {
    @Override
    protected void onDestroy() {
        if (Logger.DEBUG) { Log.d(TAG, "[onDestroy]"); }
        if (db != null) {
            db.close();
        }
        super.onDestroy();
    }

+10 −4
Original line number Diff line number Diff line
@@ -56,6 +56,16 @@ public class WebSyncService extends IntentService {
        super("WebSyncService");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        if (Logger.DEBUG) { Log.d(TAG, "[websync create]"); }

        web = new WebHelper(this);
        db = DbAccess.getInstance();
        db.open(this);
    }

    /**
     * Handle synchronization intent
     * @param intent Intent
@@ -72,10 +82,6 @@ public class WebSyncService extends IntentService {
            pi = null;
        }

        web = new WebHelper(this);
        db = DbAccess.getInstance();
        db.open(this);

        if (!isAuthorized) {
            try {
                web.authorize();