fixes a certain condition where start date equaled end date (#7)

This commit is contained in:
y20k 2017-01-21 11:32:51 +01:00
parent cb56291dee
commit 56ee80b1b4
4 changed files with 37 additions and 14 deletions

View file

@ -293,6 +293,14 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
} }
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// LogHelper.v(LOG_TAG, "onNewIntent called.");
// handleIncomingIntent(intent);
// }
//
//
/* Loads state of Floating Action Button from preferences */ /* Loads state of Floating Action Button from preferences */
private void loadFloatingActionButtonState(Context context) { private void loadFloatingActionButtonState(Context context) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
@ -583,13 +591,22 @@ public class MainActivity extends AppCompatActivity implements TrackbookKeys {
case ACTION_SHOW_MAP: case ACTION_SHOW_MAP:
mSelectedTab = FRAGMENT_ID_MAP; mSelectedTab = FRAGMENT_ID_MAP;
mViewPager.setCurrentItem(mSelectedTab); mViewPager.setCurrentItem(mSelectedTab);
if (intent.hasExtra(EXTRA_TRACKING_STATE)) { // if (intent.hasExtra(EXTRA_TRACKING_STATE)) {
mTrackerServiceRunning = intent.getBooleanExtra(EXTRA_TRACKING_STATE, false); // mTrackerServiceRunning = intent.getBooleanExtra(EXTRA_TRACKING_STATE, false);
if (mTrackerServiceRunning) { // if (mTrackerServiceRunning) {
// set FAB state // // set FAB state
mFloatingActionButtonState = FAB_STATE_RECORDING; // mFloatingActionButtonState = FAB_STATE_RECORDING;
} // }
} // }
//
// Intent i = new Intent();
// i.setAction(ACTION_TRACK_REQUEST);
// LocalBroadcastManager.getInstance(this).sendBroadcast(i);
// LogHelper.v(LOG_TAG, "MapActivity: requesting updated track from service.");
// clear intent
intent.setAction(ACTION_DEFAULT);
break; break;
default: default:

View file

@ -391,12 +391,13 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
public void setTrackingState(boolean trackingState) { public void setTrackingState(boolean trackingState) {
mTrackerServiceRunning = trackingState; mTrackerServiceRunning = trackingState;
// got a new track (from notification) // // got a new track (from notification)
Intent intent = mActivity.getIntent(); // // todo check for ACTION
if (intent != null && intent.hasExtra(EXTRA_TRACK)) { // Intent intent = mActivity.getIntent();
mTrack = intent.getParcelableExtra(EXTRA_TRACK); // if (intent != null && intent.hasExtra(EXTRA_TRACK)) {
LogHelper.v(LOG_TAG, "MapFragment: getting track from intent."); // mTrack = intent.getParcelableExtra(EXTRA_TRACK);
} // LogHelper.v(LOG_TAG, "MapFragment: getting track from intent.");
// }
// turn on/off tracking for MainActivity Fragment - prevent double tracking // turn on/off tracking for MainActivity Fragment - prevent double tracking
if (mTrackerServiceRunning) { if (mTrackerServiceRunning) {
@ -406,7 +407,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
} }
if (mTrack != null) { if (mTrack != null) {
drawTrackOverlay(mTrack); drawTrackOverlay(mTrack); // TODO check if redundant
} }
// update marker // update marker
@ -435,6 +436,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
SaveTrackAsyncHelper saveTrackAsyncHelper = new SaveTrackAsyncHelper(); SaveTrackAsyncHelper saveTrackAsyncHelper = new SaveTrackAsyncHelper();
saveTrackAsyncHelper.execute(); saveTrackAsyncHelper.execute();
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_save_track), Toast.LENGTH_LONG).show(); Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_save_track), Toast.LENGTH_LONG).show();
LogHelper.v(LOG_TAG, "!!! MapFragment: Saving current track. Start == End -> " + (mTrack.getRecordingStart().equals(mTrack.getRecordingStop())) ); // TODO REMOVE
} else { } else {
// clear track object and delete temp file // clear track object and delete temp file
mTrack = null; mTrack = null;
@ -625,6 +627,7 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
// clear intent // clear intent
intent.setAction(ACTION_DEFAULT); intent.setAction(ACTION_DEFAULT);
LogHelper.v(LOG_TAG, "MapFragment: Track update received - drawing map."); LogHelper.v(LOG_TAG, "MapFragment: Track update received - drawing map.");
LogHelper.v(LOG_TAG, "!!! MapFragment: Track update received. Start == End -> " + (mTrack.getRecordingStart().equals(mTrack.getRecordingStop())) ); // TODO REMOVE
} }
} }
}; };

View file

@ -318,6 +318,7 @@ public class TrackerService extends Service implements TrackbookKeys, SensorEven
i.putExtra(EXTRA_TRACK, mTrack); i.putExtra(EXTRA_TRACK, mTrack);
i.putExtra(EXTRA_LAST_LOCATION, mCurrentBestLocation); i.putExtra(EXTRA_LAST_LOCATION, mCurrentBestLocation);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(i); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(i);
LogHelper.v(LOG_TAG, "!!! sendTrackUpdate. Start == End -> " + (mTrack.getRecordingStart().equals(mTrack.getRecordingStop())) ); // TODO REMOVE
} }

View file

@ -72,6 +72,8 @@ public class NotificationHelper implements TrackbookKeys {
NotificationManager notificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) mService.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(TRACKER_SERVICE_NOTIFICATION_ID, mNotification); notificationManager.notify(TRACKER_SERVICE_NOTIFICATION_ID, mNotification);
LogHelper.v(LOG_TAG, "!!! Notification: Received updated Track. Start == End -> " + (track.getRecordingStart().equals(track.getRecordingStop())) ); // TODO REMOVE
if (!tracking) { if (!tracking) {
// make notification swipe-able // make notification swipe-able
mService.stopForeground(false); mService.stopForeground(false);