Skip to content

Instantly share code, notes, and snippets.

@Xiryl
Xiryl / .eslintrc
Created July 11, 2020 08:03
eslint-guide-1
{
"extends": ["react-app", "plugin:prettier/recommended"]
}
@Xiryl
Xiryl / VScode-settings
Created July 11, 2020 08:09
eslint-guide-2
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false,
},
"eslint.autoFixOnSave": true,
"eslint.alwaysShowStatus": true,
"prettier.disableLanguages": [
"js"
],
@Xiryl
Xiryl / .editorconfig
Created July 11, 2020 08:18
eslint-guide-3
root = true
[*]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@Xiryl
Xiryl / .eslintrc
Created July 11, 2020 08:20
eslint-guide-4
{
...,
rules: {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"indent": [2, 4],
"react/jsx-indent": [2, 4],
"react/jsx-indent-props": [2, 4],
"react/prefer-stateless-function": [1, { "ignorePureComponents": true }],
"import/no-extraneous-dependencies": [1, {"peerDependencies": true}],
"import/no-extraneous-dependencies": "off",
@Xiryl
Xiryl / BluetoothUtils.kt
Created August 12, 2021 09:14
BluetoothSDK-BluetoothUtils
class BluetoothUtils {
companion object {
val ACTION_DISCOVERY_STARTED = "ACTION_DISCOVERY_STARTED"
val ACTION_DISCOVERY_STOPPED = "ACTION_DISCOVERY_STOPPED"
val ACTION_DEVICE_FOUND = "ACTION_DEVICE_FOUND"
val ACTION_DEVICE_CONNECTED = "ACTION_DEVICE_CONNECTED"
val ACTION_DEVICE_DISCONNECTED = "ACTION_DEVICE_DISCONNECTED"
val ACTION_MESSAGE_RECEIVED = "ACTION_MESSAGE_RECEIVED"
val ACTION_MESSAGE_SENT = "ACTION_MESSAGE_SENT"
val ACTION_CONNECTION_ERROR = "ACTION_CONNECTION_ERROR"
@Xiryl
Xiryl / IBluetoothSDKListener.kt
Created August 12, 2021 09:19
BluetoothSDK-Interface
interface IBluetoothSDKListener {
/**
* from action BluetoothUtils.ACTION_DISCOVERY_STARTED
*/
fun onDiscoveryStarted()
/**
* from action BluetoothUtils.ACTION_DISCOVERY_STOPPED
*/
fun onDiscoveryStopped()
@Xiryl
Xiryl / BluetoothSDKListenerHelper.kt
Last active August 12, 2021 09:34
BluetoothSDK-ListenerHelper
class BluetoothSDKListenerHelper {
companion object {
private var mBluetoothSDKBroadcastReceiver: BluetoothSDKBroadcastReceiver? = null
class BluetoothSDKBroadcastReceiver : BroadcastReceiver() {
private var mGlobalListener: IBluetoothSDKListener? = null
public fun setBluetoothSDKListener(listener: IBluetoothSDKListener) {
mGlobalListener = listener
@Xiryl
Xiryl / CoolFragment.kt
Created August 12, 2021 10:22
BluetoothSDK-Fragment
class CoolFragment() : BottomSheetDialogFragment() {
private lateinit var mService: BluetoothSDKService
private lateinit var binding: FragmentPopupDiscoveredLabelerDeviceBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater,
@Xiryl
Xiryl / BluetoothSDKService.kt
Created August 12, 2021 10:34
BluetoothSDK-Service1
class BluetoothSDKService : Service() {
// Service Binder
private val binder = LocalBinder()
// Bluetooth stuff
private lateinit var bluetoothAdapter: BluetoothAdapter
private lateinit var pairedDevices: MutableSet<BluetoothDevice>
private var connectedDevice: BluetoothDevice? = null
@Xiryl
Xiryl / BluetoothSDKService.kt
Created August 12, 2021 10:40
BluetoothSDK-Service2
/**
* Class used for the client Binder.
*/
inner class LocalBinder : Binder() {
/**
* Enable the discovery, registering a broadcastreceiver {@link discoveryBroadcastReceiver}
* The discovery filter by LABELER_SERVER_TOKEN_NAME
*/
public fun startDiscovery(context: Context) {