More refactoring

pull/14/head
sh123 2020-12-04 22:16:42 +02:00
rodzic 251c11550e
commit 7179b7a759
4 zmienionych plików z 13 dodań i 9 usunięć

Wyświetl plik

@ -12,7 +12,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Codec2Talkie">
<activity android:name=".BluetoothConnectActivity" />
<activity android:name=".bluetooth.ConnectActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Wyświetl plik

@ -18,6 +18,8 @@ import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.radio.codec2talkie.bluetooth.ConnectActivity;
import com.radio.codec2talkie.bluetooth.SocketHandler;
import com.ustadmobile.codec2.Codec2;
import java.io.IOException;
@ -54,7 +56,7 @@ public class MainActivity extends AppCompatActivity {
}
protected void startBluetoothConnectActivity() {
Intent bluetoothConnectIntent = new Intent(this, BluetoothConnectActivity.class);
Intent bluetoothConnectIntent = new Intent(this, ConnectActivity.class);
startActivityForResult(bluetoothConnectIntent, REQUEST_CONNECT_BT);
}
@ -133,7 +135,7 @@ public class MainActivity extends AppCompatActivity {
_textBtName.setText(data.getStringExtra("name"));
try {
_codec2Player = new Codec2Player(
BluetoothSocketHandler.getSocket(),
SocketHandler.getSocket(),
onPlayerStateChanged,
Codec2.CODEC2_MODE_450,
true);

Wyświetl plik

@ -1,4 +1,4 @@
package com.radio.codec2talkie;
package com.radio.codec2talkie.bluetooth;
import androidx.appcompat.app.AppCompatActivity;
@ -17,10 +17,12 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.radio.codec2talkie.R;
import java.io.IOException;
import java.util.UUID;
public class BluetoothConnectActivity extends AppCompatActivity {
public class ConnectActivity extends AppCompatActivity {
private final static int BT_ENABLE = 1;
private final static int BT_CONNECT_SUCCESS = 2;
@ -112,7 +114,7 @@ public class BluetoothConnectActivity extends AppCompatActivity {
toastMsg = "Bluetooth adapter is not found";
} else {
toastMsg = "Connected";
BluetoothSocketHandler.setSocket(_btSocket);
SocketHandler.setSocket(_btSocket);
Intent resultIntent = new Intent();
resultIntent.putExtra("name", _btSelectedName);
setResult(Activity.RESULT_OK, resultIntent);

Wyświetl plik

@ -1,8 +1,8 @@
package com.radio.codec2talkie;
package com.radio.codec2talkie.bluetooth;
import android.bluetooth.BluetoothSocket;
public class BluetoothSocketHandler {
public class SocketHandler {
private static BluetoothSocket socket;
public static synchronized BluetoothSocket getSocket(){
@ -10,6 +10,6 @@ public class BluetoothSocketHandler {
}
public static synchronized void setSocket(BluetoothSocket socket){
BluetoothSocketHandler.socket = socket;
SocketHandler.socket = socket;
}
}