diff --git a/.gitignore b/.gitignore index 39fb081..17e0c3d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ /.idea/libraries .DS_Store /build +/Application/build /captures .externalNativeBuild diff --git a/.idea/modules.xml b/.idea/modules.xml index 4e077ec..c8421df 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,7 +3,7 @@ - + \ No newline at end of file diff --git a/Application/Application.iml b/Application/Application.iml index 620e43d..c1cea51 100644 --- a/Application/Application.iml +++ b/Application/Application.iml @@ -66,13 +66,6 @@ - - - - - - - @@ -80,7 +73,13 @@ - + + + + + + + diff --git a/Application/src/main/java/org/surfsite/iconsole/BluetoothChatFragment.java b/Application/src/main/java/org/surfsite/iconsole/BluetoothChatFragment.java index 54f484d..1d26767 100644 --- a/Application/src/main/java/org/surfsite/iconsole/BluetoothChatFragment.java +++ b/Application/src/main/java/org/surfsite/iconsole/BluetoothChatFragment.java @@ -108,7 +108,7 @@ public class BluetoothChatFragment extends Fragment { super.onStart(); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult - if (!mBluetoothAdapter.isEnabled()) { + if (null == mBluetoothAdapter || !mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session @@ -161,7 +161,7 @@ public class BluetoothChatFragment extends Fragment { Log.d(TAG, "setupChat()"); // Initialize the array adapter for the conversation thread - mConversationArrayAdapter = new ArrayAdapter(getActivity(), R.layout.message); + mConversationArrayAdapter = new ArrayAdapter<>(getActivity(), R.layout.message); mConversationView.setAdapter(mConversationArrayAdapter); diff --git a/Application/src/main/java/org/surfsite/iconsole/BluetoothChatService.java b/Application/src/main/java/org/surfsite/iconsole/BluetoothChatService.java index 90258a5..0ece924 100644 --- a/Application/src/main/java/org/surfsite/iconsole/BluetoothChatService.java +++ b/Application/src/main/java/org/surfsite/iconsole/BluetoothChatService.java @@ -153,8 +153,8 @@ public class BluetoothChatService { * @param device The BluetoothDevice that has been connected */ public synchronized void connected(BluetoothSocket socket, BluetoothDevice - device, final String socketType) { - Log.d(TAG, "connected, Socket Type:" + socketType); + device) { + Log.d(TAG, "connected"); // Cancel the thread that completed the connection if (mConnectThread != null) { @@ -169,7 +169,7 @@ public class BluetoothChatService { } // Start the thread to manage the connection and perform transmissions - mConnectedThread = new ConnectedThread(socket, socketType); + mConnectedThread = new ConnectedThread(socket); mConnectedThread.start(); // Send the name of the connected device back to the UI Activity @@ -258,7 +258,6 @@ public class BluetoothChatService { private class ConnectThread extends Thread { private final BluetoothSocket mmSocket; private final BluetoothDevice mmDevice; - private String mSocketType; public ConnectThread(BluetoothDevice device) { mmDevice = device; @@ -276,8 +275,8 @@ public class BluetoothChatService { } public void run() { - Log.i(TAG, "BEGIN mConnectThread SocketType:" + mSocketType); - setName("ConnectThread" + mSocketType); + Log.i(TAG, "BEGIN mConnectThread"); + setName("ConnectThread"); // Always cancel discovery because it will slow down a connection mAdapter.cancelDiscovery(); @@ -292,8 +291,7 @@ public class BluetoothChatService { try { mmSocket.close(); } catch (IOException e2) { - Log.e(TAG, "unable to close() " + mSocketType + - " socket during connection failure", e2); + Log.e(TAG, "unable to close() socket during connection failure", e2); } connectionFailed(); return; @@ -305,14 +303,14 @@ public class BluetoothChatService { } // Start the connected thread - connected(mmSocket, mmDevice, mSocketType); + connected(mmSocket, mmDevice); } public void cancel() { try { mmSocket.close(); } catch (IOException e) { - Log.e(TAG, "close() of connect " + mSocketType + " socket failed", e); + Log.e(TAG, "close() of socket failed", e); } } } @@ -326,8 +324,8 @@ public class BluetoothChatService { private final InputStream mmInStream; private final OutputStream mmOutStream; - public ConnectedThread(BluetoothSocket socket, String socketType) { - Log.d(TAG, "create ConnectedThread: " + socketType); + public ConnectedThread(BluetoothSocket socket) { + Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; diff --git a/BluetoothChat.iml b/BluetoothChat.iml deleted file mode 100644 index 14e1837..0000000 --- a/BluetoothChat.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file