mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
# explicit logging out of course area to support correct reloading of data
This commit is contained in:
1 parent
4b80afede4
commit
045767ea5a
11 files changed
+113
-34
No files matched your search
@@ -45,7 +45,8 @@
|
||||
<activity
|
||||
android:name=".ui.activities.LoginActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:launchMode="singleTop" >
|
||||
android:launchMode="standard"
|
||||
android:finishOnTaskLaunch="true" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
+10
-1
@@ -42,6 +42,7 @@ import com.sap.sailing.racecommittee.app.data.parsers.MarksDataParser;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRaceIdentifier;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.DomainFactoryImpl;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.coursedata.impl.ControlPointDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.coursedata.impl.CourseDataDeserializer;
|
||||
@@ -66,7 +67,7 @@ import com.sap.sailing.server.gateway.deserialization.racelog.impl.RaceLogEventD
|
||||
* Enables accessing of data.
|
||||
*/
|
||||
public class OnlineDataManager extends DataManager {
|
||||
// private static final String TAG = OnlineDataManager.class.getName();
|
||||
private static final String TAG = OnlineDataManager.class.getName();
|
||||
|
||||
private Context context;
|
||||
|
||||
@@ -79,6 +80,7 @@ public class OnlineDataManager extends DataManager {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadEvents(LoadClient<Collection<EventBase>> client) {
|
||||
if (dataStore.getEvents().isEmpty()) {
|
||||
reloadEvents(client);
|
||||
@@ -93,6 +95,7 @@ public class OnlineDataManager extends DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
//@Override
|
||||
public LoaderCallbacks<DataLoaderResult<Collection<EventBase>>> getEventsLoader(
|
||||
LoadClient<Collection<EventBase>> callback) {
|
||||
return new DataLoaderCallbacks<Collection<EventBase>>(callback) {
|
||||
@@ -104,6 +107,8 @@ public class OnlineDataManager extends DataManager {
|
||||
DataParser<Collection<EventBase>> parser = new EventsDataParser(new EventBaseJsonDeserializer(
|
||||
new VenueJsonDeserializer(new CourseAreaJsonDeserializer(domainFactory))));
|
||||
DataHandler<Collection<EventBase>> handler = new EventsDataHandler(OnlineDataManager.this);
|
||||
|
||||
ExLog.i(TAG, "getEventsLoader created new loader...");
|
||||
|
||||
return new OnlineDataLoader<Collection<EventBase>>(context, URI.create(AppPreferences
|
||||
.getServerBaseURL(context) + "/sailingserver/events"), parser, handler);
|
||||
@@ -112,6 +117,7 @@ public class OnlineDataManager extends DataManager {
|
||||
};
|
||||
}
|
||||
|
||||
//@Override
|
||||
public LoaderCallbacks<DataLoaderResult<Collection<CourseArea>>> getCourseAreasLoader(
|
||||
final Serializable parentEventId, LoadClient<Collection<CourseArea>> callback) {
|
||||
return new DataLoaderCallbacks<Collection<CourseArea>>(callback) {
|
||||
@@ -152,6 +158,7 @@ public class OnlineDataManager extends DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCourseAreas(final Serializable parentEventId, final LoadClient<Collection<CourseArea>> client) {
|
||||
|
||||
if (dataStore.hasEvent(parentEventId)) {
|
||||
@@ -185,6 +192,7 @@ public class OnlineDataManager extends DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRaces(Serializable courseAreaId, LoadClient<Collection<ManagedRace>> client) {
|
||||
if (!dataStore.hasCourseArea(courseAreaId)) {
|
||||
client.onLoadFailed(new DataLoadingException(String.format("No course area found with id %s", courseAreaId)));
|
||||
@@ -214,6 +222,7 @@ public class OnlineDataManager extends DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadMarks(ManagedRace managedRace, LoadClient<Collection<Mark>> client) {
|
||||
SharedDomainFactory domainFactory = DomainFactoryImpl.INSTANCE;
|
||||
JsonDeserializer<Mark> markDeserializer = new MarkDeserializer(domainFactory);
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ public class OnlineDataLoader<T> extends AsyncTaskLoader<DataLoaderResult<T>> {
|
||||
ExLog.i(TAG, "Using cached results...");
|
||||
deliverResult(new DataLoaderResult<T>(dataHandler.getCachedResults()));
|
||||
} else {
|
||||
ExLog.i(TAG, "No cached results. Forcing load now.");
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
|
||||
+26
-4
@@ -77,7 +77,6 @@ public abstract class BaseActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
case R.id.options_menu_settings:
|
||||
ExLog.i(TAG, "Clicked SETTINGS.");
|
||||
@@ -86,8 +85,7 @@ public abstract class BaseActivity extends Activity {
|
||||
case R.id.options_menu_reload:
|
||||
ExLog.i(TAG, "Clicked RESET.");
|
||||
InMemoryDataStore.INSTANCE.reset();
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
return onReset();
|
||||
case R.id.options_menu_live:
|
||||
ExLog.i(TAG, "Clicked LIVE.");
|
||||
Toast.makeText(this, getLiveIconText(), Toast.LENGTH_LONG).show();
|
||||
@@ -109,10 +107,21 @@ public abstract class BaseActivity extends Activity {
|
||||
updateSendingServiceInformation();
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
ExLog.i(TAG, String.format("Back pressed on activity %s", this.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
protected boolean onHomeClicked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean onReset() {
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -129,6 +138,20 @@ public abstract class BaseActivity extends Activity {
|
||||
bindService(intent, sendingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ExLog.i(TAG, String.format("Resuming activity %s", this.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
||||
ExLog.i(TAG, String.format("Pausing activity %s", this.getClass().getSimpleName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
@@ -143,7 +166,6 @@ public abstract class BaseActivity extends Activity {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
ExLog.i(TAG, String.format("Destroying activity %s", this.getClass().getSimpleName()));
|
||||
InMemoryDataStore.INSTANCE.reset();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -49,6 +49,7 @@ public class LoginActivity extends BaseActivity implements EventSelectedListener
|
||||
|
||||
// on first create add event list fragment
|
||||
if (savedInstanceState == null) {
|
||||
ExLog.i(TAG, "Seems to be first start. Creating event fragment.");
|
||||
addEventListFragment();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-17
@@ -32,7 +32,7 @@ import com.sap.sailing.racecommittee.app.ui.fragments.lists.ManagedRaceListFragm
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.ManagedRaceListFragment.FilterMode;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
|
||||
public class RacingActivity extends BaseActivity implements RaceInfoListener {
|
||||
public class RacingActivity extends SessionActivity implements RaceInfoListener {
|
||||
// private final static String TAG = RacingActivity.class.getName();
|
||||
private final static String ListFragmentTag = RacingActivity.class.getName() + ".ManagedRaceListFragment";
|
||||
|
||||
@@ -80,12 +80,6 @@ public class RacingActivity extends BaseActivity implements RaceInfoListener {
|
||||
|
||||
private ReadonlyDataManager dataManager;
|
||||
|
||||
@Override
|
||||
protected boolean onHomeClicked() {
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// features must be requested before anything else
|
||||
@@ -109,11 +103,14 @@ public class RacingActivity extends BaseActivity implements RaceInfoListener {
|
||||
Toast.makeText(this, getString(R.string.racing_course_area_missing), Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
setupActionBar(courseArea);
|
||||
// unload and unregister from all races here!
|
||||
unloadAllRaces();
|
||||
loadRaces(courseArea);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
logoutSession();
|
||||
}
|
||||
|
||||
private ManagedRaceListFragment getOrCreateRaceListFragment() {
|
||||
Fragment fragment = getFragmentManager().findFragmentByTag(ListFragmentTag);
|
||||
@@ -149,8 +146,6 @@ public class RacingActivity extends BaseActivity implements RaceInfoListener {
|
||||
|
||||
private void setupActionBar(CourseArea courseArea) {
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
actionBar.setTitle(String.format(getString(R.string.racingview_header), courseArea.getName()));
|
||||
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
||||
@@ -160,12 +155,6 @@ public class RacingActivity extends BaseActivity implements RaceInfoListener {
|
||||
new FilterModeSelectionBinder(raceListFragment, actionBar, adapter, ManagedRaceListFragment.FilterMode.values());
|
||||
}
|
||||
|
||||
private void unloadAllRaces() {
|
||||
ExLog.i(TAG, "Issuing intent action clear races");
|
||||
Intent intent = new Intent(AppConstants.INTENT_ACTION_CLEAR_RACES);
|
||||
this.startService(intent);
|
||||
}
|
||||
|
||||
private void loadRaces(final CourseArea courseArea) {
|
||||
setProgressBarIndeterminateVisibility(true);
|
||||
|
||||
|
||||
+1
-8
@@ -29,7 +29,7 @@ import com.sap.sailing.racecommittee.app.ui.adapters.PhotoAdapter;
|
||||
import com.sap.sailing.racecommittee.app.ui.views.CameraView;
|
||||
import com.sap.sailing.racecommittee.app.utils.MailHelper;
|
||||
|
||||
public class ResultsCapturingActivity extends BaseActivity {
|
||||
public class ResultsCapturingActivity extends SessionActivity {
|
||||
private static String ARGUMENTS_KEY_SUBJECT = "subject";
|
||||
private static String ARGUMENTS_KEY_TEXT = "text";
|
||||
|
||||
@@ -161,12 +161,6 @@ public class ResultsCapturingActivity extends BaseActivity {
|
||||
currentImageFile = createFinisherImageFile(currentImageIndex++);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHomeClicked() {
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setupListView() {
|
||||
TextView header = new TextView(this);
|
||||
header.setText(getString(R.string.results_capturing_view_list_header));
|
||||
@@ -181,7 +175,6 @@ public class ResultsCapturingActivity extends BaseActivity {
|
||||
|
||||
private void setupActionBar() {
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setTitle(getString(R.string.results_capturing_title));
|
||||
}
|
||||
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.sap.sailing.racecommittee.app.ui.activities;
|
||||
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.logging.ExLog;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class SessionActivity extends BaseActivity {
|
||||
|
||||
private static final String TAG = BaseActivity.class.getName();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onHomeClicked() {
|
||||
return logoutSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onReset() {
|
||||
return logoutSession();
|
||||
}
|
||||
|
||||
protected boolean logoutSession() {
|
||||
ExLog.i(TAG, String.format("Logging out of activity %s", this.getClass().getSimpleName()));
|
||||
AlertDialog dialog = new AlertDialog.Builder(this).setTitle("Sure?").setPositiveButton("Logout", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
logout();
|
||||
}
|
||||
}).setNegativeButton("Cancel", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
}).create();
|
||||
dialog.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void logout() {
|
||||
unloadAllRaces();
|
||||
fadeActivity(LoginActivity.class, true);
|
||||
}
|
||||
|
||||
private void unloadAllRaces() {
|
||||
ExLog.i(TAG, "Issuing intent action clear races");
|
||||
Intent intent = new Intent(AppConstants.INTENT_ACTION_CLEAR_RACES);
|
||||
this.startService(intent);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -39,7 +39,7 @@ import com.sap.sailing.racecommittee.app.ui.views.CompassView;
|
||||
import com.sap.sailing.racecommittee.app.ui.views.CompassView.CompassDirectionListener;
|
||||
import com.sap.sailing.racecommittee.app.utils.GeoUtils;
|
||||
|
||||
public class WindActivity extends BaseActivity implements CompassDirectionListener, LocationListener {
|
||||
public class WindActivity extends SessionActivity implements CompassDirectionListener, LocationListener {
|
||||
|
||||
private final static int FIVE_SEC = 5000;
|
||||
private final static int EVERY_POSITION_CHANGE = 0;
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ public abstract class NamedListFragment<T extends Named> extends ListFragment im
|
||||
|
||||
private void loadItems() {
|
||||
OnlineDataManager dataManager = (OnlineDataManager) OnlineDataManager.create(getActivity());
|
||||
getLoaderManager().initLoader(0, null, createLoaderCallbacks(dataManager));
|
||||
getLoaderManager().restartLoader(0, null, createLoaderCallbacks(dataManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
|
||||
Reference in new issue
Block a user