Skip to content

Commit 9041a3a

Browse files
committed
Updated BluetoothCommunicator and fixed errors
1 parent 88dc732 commit 9041a3a

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131
implementation 'androidx.appcompat:appcompat:1.2.0'
3232
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
3333
//bluetooth communicator
34-
implementation 'com.github.niedev:BluetoothCommunicator:1.0.1'
34+
implementation 'com.github.niedev:BluetoothCommunicator:1.0.5'
3535
// Support libraries
3636
implementation "com.google.android.material:material:1.0.0"
3737
implementation "androidx.cardview:cardview:1.0.0"

app/src/main/java/com/bluetooth/communicatorexample/fragments/PairingFragment.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import androidx.constraintlayout.widget.ConstraintLayout;
3737
import androidx.fragment.app.Fragment;
3838

39+
import com.bluetooth.communicator.tools.Timer;
3940
import com.bluetooth.communicatorexample.Global;
4041
import com.bluetooth.communicatorexample.MainActivity;
4142
import com.bluetooth.communicatorexample.R;
@@ -47,8 +48,6 @@
4748
import com.bluetooth.communicatorexample.tools.Tools;
4849
import com.bluetooth.communicator.BluetoothCommunicator;
4950
import com.bluetooth.communicator.Peer;
50-
import com.bluetooth.communicator.connection.Channel;
51-
import com.bluetooth.communicator.connection.client.BluetoothConnectionClient;
5251

5352
import java.text.DateFormat;
5453
import java.util.ArrayList;
@@ -62,7 +61,7 @@ public class PairingFragment extends Fragment {
6261
private ConstraintLayout constraintLayout;
6362
private Peer confirmConnectionPeer;
6463
private ListView listViewGui;
65-
private Channel.Timer connectionTimer;
64+
private Timer connectionTimer;
6665
@Nullable
6766
private PeerListAdapter listView;
6867
private TextView discoveryDescription;
@@ -139,7 +138,7 @@ public void onConnectionSuccess(Peer peer, int source) {
139138
public void onConnectionFailed(Peer peer, int errorCode) {
140139
super.onConnectionFailed(peer, errorCode);
141140
if (connectingPeer != null) {
142-
if (connectionTimer != null && !connectionTimer.isFinished() && errorCode != BluetoothConnectionClient.CONNECTION_REJECTED) {
141+
if (connectionTimer != null && !connectionTimer.isFinished() && errorCode != BluetoothCommunicator.CONNECTION_REJECTED) {
143142
// the timer has not expired and the connection has not been refused, so we try again
144143
activity.connect(peer);
145144
} else {
@@ -149,7 +148,7 @@ public void onConnectionFailed(Peer peer, int errorCode) {
149148
activateInputs();
150149
disappearLoading(true, null);
151150
connectingPeer = null;
152-
if (errorCode == BluetoothConnectionClient.CONNECTION_REJECTED) {
151+
if (errorCode == BluetoothCommunicator.CONNECTION_REJECTED) {
153152
Toast.makeText(activity, peer.getName() + " refused the connection request", Toast.LENGTH_SHORT).show();
154153
} else {
155154
Toast.makeText(activity, "Connection error", Toast.LENGTH_SHORT).show();
@@ -399,7 +398,7 @@ public RequestDialog getConnectionConfirmDialog() {
399398
}
400399

401400
private void startConnectionTimer() {
402-
connectionTimer = new Channel.Timer(CONNECTION_TIMEOUT);
401+
connectionTimer = new Timer(CONNECTION_TIMEOUT);
403402
connectionTimer.start();
404403
}
405404

0 commit comments

Comments
 (0)