clean
This commit is contained in:
parent
fcfcfe4c7c
commit
8830f7e2ef
@ -3,7 +3,6 @@ package com.rookiedev.hexapod
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
@ -408,9 +407,6 @@ class ControlActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
println("on Pause")
|
|
||||||
|
|
||||||
// saveSharedPref()
|
|
||||||
if (connectInterface == "WiFi") {
|
if (connectInterface == "WiFi") {
|
||||||
tcpClient!!.stopClient()
|
tcpClient!!.stopClient()
|
||||||
tcpClient!!.interrupt()
|
tcpClient!!.interrupt()
|
||||||
@ -461,10 +457,10 @@ class ControlActivity : AppCompatActivity() {
|
|||||||
alert.setMessage(
|
alert.setMessage(
|
||||||
"Unable to connect to the Hexapod."
|
"Unable to connect to the Hexapod."
|
||||||
)
|
)
|
||||||
alert.setOnCancelListener(DialogInterface.OnCancelListener { finish() })
|
alert.setOnCancelListener { finish() }
|
||||||
alert.setButton(AlertDialog.BUTTON_POSITIVE,
|
alert.setButton(AlertDialog.BUTTON_POSITIVE,
|
||||||
"OK",
|
"OK"
|
||||||
DialogInterface.OnClickListener { dialog, which -> finish() })
|
) { _, _ -> finish() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alert.show()
|
alert.show()
|
||||||
|
@ -23,13 +23,11 @@ class DeviceAdapter(mContext: Context?, private val devices: ArrayList<Bluetooth
|
|||||||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
|
||||||
// Get the data item for this position
|
// Get the data item for this position
|
||||||
var cView = convertView
|
var cView = convertView
|
||||||
val device: BluetoothDevice? = getItem(position)
|
val device: BluetoothDevice = getItem(position)
|
||||||
// Check if an existing view is being reused, otherwise inflate the view
|
// Check if an existing view is being reused, otherwise inflate the view
|
||||||
if (cView == null) {
|
if (cView == null) {
|
||||||
cView = LayoutInflater.from(context).inflate(R.layout.device_list, parent, false)
|
cView = LayoutInflater.from(context).inflate(R.layout.device_list, parent, false)
|
||||||
}
|
}
|
||||||
// Lookup view for data population
|
|
||||||
// cView!!.isClickable = true
|
|
||||||
|
|
||||||
val textDeviceName = cView!!.findViewById<TextView>(R.id.list_device_name)
|
val textDeviceName = cView!!.findViewById<TextView>(R.id.list_device_name)
|
||||||
val textDeviceAddress = cView.findViewById<TextView>(R.id.list_device_address)
|
val textDeviceAddress = cView.findViewById<TextView>(R.id.list_device_address)
|
||||||
@ -38,7 +36,7 @@ class DeviceAdapter(mContext: Context?, private val devices: ArrayList<Bluetooth
|
|||||||
bluetoothIcon.setImageResource(R.drawable.ic_baseline_bluetooth_24)
|
bluetoothIcon.setImageResource(R.drawable.ic_baseline_bluetooth_24)
|
||||||
|
|
||||||
// Populate the data into the template view using the data object
|
// Populate the data into the template view using the data object
|
||||||
textDeviceName.text = device!!.name
|
textDeviceName.text = device.name
|
||||||
textDeviceAddress.text = device.address
|
textDeviceAddress.text = device.address
|
||||||
// Return the completed view to render on screen
|
// Return the completed view to render on screen
|
||||||
return cView
|
return cView
|
||||||
@ -104,7 +102,7 @@ class DeviceListActivity : Activity() {
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
private val mDeviceClickListener =
|
private val mDeviceClickListener =
|
||||||
OnItemClickListener { av, v, arg2, arg3 ->
|
OnItemClickListener { av, _, arg2, _ ->
|
||||||
|
|
||||||
val device: BluetoothDevice = av.getItemAtPosition(arg2) as BluetoothDevice
|
val device: BluetoothDevice = av.getItemAtPosition(arg2) as BluetoothDevice
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.rookiedev.hexapod
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.DialogInterface
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.InetAddresses.isNumericAddress
|
import android.net.InetAddresses.isNumericAddress
|
||||||
@ -305,11 +304,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alert.setMessage(
|
alert.setMessage(
|
||||||
"Bluetooth permission is required. Please enable the permission in Settings."
|
"Bluetooth permission is required. Please enable the permission in Settings."
|
||||||
)
|
)
|
||||||
alert.setOnCancelListener(DialogInterface.OnCancelListener { })
|
alert.setOnCancelListener { }
|
||||||
alert.setButton(
|
alert.setButton(
|
||||||
AlertDialog.BUTTON_POSITIVE,
|
AlertDialog.BUTTON_POSITIVE,
|
||||||
"OK",
|
"OK"
|
||||||
DialogInterface.OnClickListener { dialog, which -> })
|
) { _, _ -> }
|
||||||
}
|
}
|
||||||
ERROR_NO_DEVICE -> {
|
ERROR_NO_DEVICE -> {
|
||||||
alert.setTitle("Empty Device")
|
alert.setTitle("Empty Device")
|
||||||
@ -317,11 +316,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
alert.setMessage(
|
alert.setMessage(
|
||||||
"Please select a Bluetooth device."
|
"Please select a Bluetooth device."
|
||||||
)
|
)
|
||||||
alert.setOnCancelListener(DialogInterface.OnCancelListener { })
|
alert.setOnCancelListener { }
|
||||||
alert.setButton(
|
alert.setButton(
|
||||||
AlertDialog.BUTTON_POSITIVE,
|
AlertDialog.BUTTON_POSITIVE,
|
||||||
"OK",
|
"OK"
|
||||||
DialogInterface.OnClickListener { dialog, which -> })
|
) { _, _ -> }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alert.show()
|
alert.show()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user