Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

Commit

Permalink
Some small bug fixes and cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
neatorobito committed Oct 26, 2015
1 parent 6d11b6d commit ca6beaf
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void doOnBackground() {
Log.d(Salut.TAG, "Registered Host | " + salutInstance.registeredHost.deviceName);

salutInstance.thisDevice.isRegistered = true;
salutInstance.dataReceiver.currentContext.runOnUiThread(new Runnable() {
salutInstance.dataReceiver.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (onRegistered != null)
Expand All @@ -86,13 +86,12 @@ public void run() {

salutInstance.thisDevice.isRegistered = false;
salutInstance.registeredHost = null;
salutInstance.cleanUpDataConnection(false);
salutInstance.cleanUpDeviceConnection(false);
salutInstance.closeDataSocket();
salutInstance.disconnectFromDevice();

if(onUnregisterSuccess != null) //Success Callback.
{
salutInstance.dataReceiver.currentContext.runOnUiThread(new Runnable() {
salutInstance.dataReceiver.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
onUnregisterSuccess.call();
Expand All @@ -110,8 +109,10 @@ public void run() {
}
catch (IOException ex)
{
ex.printStackTrace();

Log.e(Salut.TAG, "An error occurred while attempting to register or unregister.");
salutInstance.dataReceiver.currentContext.runOnUiThread(new Runnable() {
salutInstance.dataReceiver.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (onRegistrationFail != null && !salutInstance.thisDevice.isRegistered) //Prevents both callbacks from being called.
Expand All @@ -133,9 +134,8 @@ public void run() {

if(disableWiFiOnUnregister)
{
Salut.disableWiFi(salutInstance.dataReceiver.currentContext);
Salut.disableWiFi(salutInstance.dataReceiver.activity);
}

try
{
registrationSocket.close();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/peak/salut/BackgroundDataJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void doOnBackground() {

if(!data.isEmpty())
{
salutInstance.dataReceiver.currentContext.runOnUiThread(new Runnable() {
salutInstance.dataReceiver.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
salutInstance.dataReceiver.dataCallback.onDataReceived(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void doOnBackground() {
salutInstance.registeredClients.add(clientDevice);

if (salutInstance.onDeviceRegisteredWithHost != null) {
salutInstance.dataReceiver.currentContext.runOnUiThread(new Runnable() {
salutInstance.dataReceiver.activity.runOnUiThread(new Runnable() {
@Override
public void run() {
salutInstance.onDeviceRegisteredWithHost.call(finalDevice);
Expand Down Expand Up @@ -84,6 +84,7 @@ public void run() {
toClient.close();

} catch (Exception ex) {
ex.printStackTrace();
Log.e(Salut.TAG, "An error occurred while dealing with registration for a client.");
}
finally {
Expand Down
Loading

0 comments on commit ca6beaf

Please sign in to comment.