mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-14 08:11:00 +00:00
Merge branch 'ubilabs--buoy_positioning_app--feature--use_message_sending_service_for_pings' into ubilabs--buoy_positioning_app--develop
This commit is contained in:
commit
b208317b9f
4 files changed
+58
-30
No files matched your search
@@ -4,8 +4,8 @@
|
||||
<string name="title_activity_positioning">Markierungs Position setzen</string>
|
||||
<string name="course_type">Kurstyp</string>
|
||||
<string name="marks">Kursmarkierungen</string>
|
||||
<string name="longitude">Breitengrad</string>
|
||||
<string name="latitude">Längengrad</string>
|
||||
<string name="longitude">Längengrad</string>
|
||||
<string name="latitude">Breitengrad</string>
|
||||
<string name="set_position">Position setzen</string>
|
||||
<string name="reset_position">Position zurücksetzen</string>
|
||||
<string name="getting_marks">Empfangen der Markierungen..</string>
|
||||
|
||||
+50
-1
@@ -1,8 +1,11 @@
|
||||
package com.sap.sailing.android.buoy.positioning.app.ui.activities;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.os.IBinder;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
@@ -17,6 +20,7 @@ import com.sap.sailing.android.buoy.positioning.app.valueobjects.CheckinData;
|
||||
import com.sap.sailing.android.buoy.positioning.app.valueobjects.MarkInfo;
|
||||
import com.sap.sailing.android.shared.data.AbstractCheckinData;
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.shared.services.sending.MessageSendingService;
|
||||
import com.sap.sailing.android.shared.ui.activities.AbstractRegattaActivity;
|
||||
import com.sap.sailing.android.shared.ui.customviews.OpenSansToolbar;
|
||||
|
||||
@@ -32,6 +36,8 @@ public class RegattaActivity extends AbstractRegattaActivity {
|
||||
private String checkinUrl;
|
||||
|
||||
private AppPreferences prefs;
|
||||
private MessageSendingService messageSendingService;
|
||||
private boolean messageSendingServiceBound;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -76,6 +82,28 @@ public class RegattaActivity extends AbstractRegattaActivity {
|
||||
setTitle(leaderboardName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Intent messageSendingServiceIntent = new Intent(this, MessageSendingService.class);
|
||||
bindService(messageSendingServiceIntent, messageSendingServiceConnection, Context.BIND_AUTO_CREATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
if (messageSendingServiceBound) {
|
||||
messageSendingService.unregisterAPIConnectivityListener();
|
||||
unbindService(messageSendingServiceConnection);
|
||||
|
||||
messageSendingServiceBound = false;
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
ExLog.i(this, TAG, "Unbound transmitting Service");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
@@ -138,4 +166,25 @@ public class RegattaActivity extends AbstractRegattaActivity {
|
||||
this.marks = marks;
|
||||
}
|
||||
|
||||
/** Defines callbacks for service binding, passed to bindService() */
|
||||
private ServiceConnection messageSendingServiceConnection = new ServiceConnection() {
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
// We've bound to LocalService, cast the IBinder and get
|
||||
// LocalService instance
|
||||
MessageSendingService.MessageSendingBinder binder = (MessageSendingService.MessageSendingBinder) service;
|
||||
messageSendingService = binder.getService();
|
||||
messageSendingServiceBound = true;
|
||||
if (BuildConfig.DEBUG) {
|
||||
ExLog.i(RegattaActivity.this, TAG, "connected to message sending service");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName arg0) {
|
||||
messageSendingServiceBound = false;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
+1
-3
@@ -145,8 +145,6 @@ public class DatabaseHelper {
|
||||
* When checking in, store info on the event, the competitor and the leaderboard in the database.
|
||||
*
|
||||
* @param context
|
||||
* @param event
|
||||
* @param competitor
|
||||
* @param leaderboard
|
||||
* @return success or failure
|
||||
* @throws GeneralDatabaseHelperException
|
||||
@@ -209,7 +207,7 @@ public class DatabaseHelper {
|
||||
|
||||
public void storeMarkPing(Context context, MarkPingInfo markPing) throws GeneralDatabaseHelperException{
|
||||
ContentResolver cr = context.getContentResolver();
|
||||
|
||||
deletePingsFromDataBase(context, markPing.getMarkId());
|
||||
ArrayList<ContentProviderOperation> opList = new ArrayList<ContentProviderOperation>();
|
||||
ContentValues mpcv = new ContentValues();
|
||||
mpcv.put(MarkPing.MARK_ID, markPing.getMarkId());
|
||||
|
||||
+5
-24
@@ -10,6 +10,7 @@ import com.sap.sailing.android.buoy.positioning.app.valueobjects.MarkPingInfo;
|
||||
import com.sap.sailing.android.shared.data.LeaderboardInfo;
|
||||
import com.sap.sailing.android.shared.data.http.HttpJsonPostRequest;
|
||||
import com.sap.sailing.android.shared.logging.ExLog;
|
||||
import com.sap.sailing.android.shared.services.sending.MessageSendingService;
|
||||
import com.sap.sailing.android.shared.util.NetworkHelper;
|
||||
import com.sap.sailing.android.shared.util.NetworkHelper.NetworkHelperError;
|
||||
import com.sap.sailing.android.shared.util.NetworkHelper.NetworkHelperSuccessListener;
|
||||
@@ -19,6 +20,7 @@ import org.json.JSONObject;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PingHelper {
|
||||
private static String TAG = PingHelper.class.getName();
|
||||
@@ -36,37 +38,16 @@ public class PingHelper {
|
||||
|
||||
String postUrlStr = leaderBoard.serverUrl
|
||||
+ prefs.getServerMarkPingPath(leaderBoard.name, mark.getId());
|
||||
|
||||
HttpJsonPostRequest request = new HttpJsonPostRequest(new URL(postUrlStr),
|
||||
fixJson.toString(), context);
|
||||
NetworkHelper.getInstance(context)
|
||||
.executeHttpJsonRequestAsnchronously(request, new NetworkHelperSuccessListener() {
|
||||
|
||||
@Override
|
||||
public void performAction(JSONObject arg0) {
|
||||
Toast.makeText(context, "DATA SEND TO SERVER", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
}, new NetworkHelper.NetworkHelperFailureListener() {
|
||||
|
||||
@Override
|
||||
public void performAction(NetworkHelperError arg0) {
|
||||
Toast.makeText(context, "FAILURE SERVER WAS NOT NOTIFIED", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
});;
|
||||
|
||||
//context.startService(MessageSendingService.createMessageIntent(context,
|
||||
// postUrlStr, null, UUID.randomUUID(), fixJson.toString(), null));
|
||||
context.startService(MessageSendingService.createMessageIntent(context, postUrlStr,
|
||||
null, UUID.randomUUID(), fixJson.toString(), null));
|
||||
|
||||
|
||||
} catch (JSONException ex) {
|
||||
ExLog.i(context, TAG,
|
||||
"Error while building ping json " + ex.getMessage());
|
||||
} catch (GeneralDatabaseHelperException e) {
|
||||
e.printStackTrace();
|
||||
} catch (MalformedURLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user