master
Zhengyu Peng 2 years ago
parent 2de9e47ef8
commit 633f380aab

@ -3,7 +3,6 @@ package com.rookiedev.hexapod
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.os.Handler
import android.os.Looper
@ -408,9 +407,6 @@ class ControlActivity : AppCompatActivity() {
override fun onPause() {
super.onPause()
println("on Pause")
// saveSharedPref()
if (connectInterface == "WiFi") {
tcpClient!!.stopClient()
tcpClient!!.interrupt()
@ -461,10 +457,10 @@ class ControlActivity : AppCompatActivity() {
alert.setMessage(
"Unable to connect to the Hexapod."
)
alert.setOnCancelListener(DialogInterface.OnCancelListener { finish() })
alert.setOnCancelListener { finish() }
alert.setButton(AlertDialog.BUTTON_POSITIVE,
"OK",
DialogInterface.OnClickListener { dialog, which -> finish() })
"OK"
) { _, _ -> finish() }
}
}
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 {
// Get the data item for this position
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
if (cView == null) {
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 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)
// Populate the data into the template view using the data object
textDeviceName.text = device!!.name
textDeviceName.text = device.name
textDeviceAddress.text = device.address
// Return the completed view to render on screen
return cView
@ -104,7 +102,7 @@ class DeviceListActivity : Activity() {
*/
@SuppressLint("MissingPermission")
private val mDeviceClickListener =
OnItemClickListener { av, v, arg2, arg3 ->
OnItemClickListener { av, _, arg2, _ ->
val device: BluetoothDevice = av.getItemAtPosition(arg2) as BluetoothDevice

@ -3,7 +3,6 @@ package com.rookiedev.hexapod
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.pm.PackageManager
import android.net.InetAddresses.isNumericAddress
@ -305,11 +304,11 @@ class MainActivity : AppCompatActivity() {
alert.setMessage(
"Bluetooth permission is required. Please enable the permission in Settings."
)
alert.setOnCancelListener(DialogInterface.OnCancelListener { })
alert.setOnCancelListener { }
alert.setButton(
AlertDialog.BUTTON_POSITIVE,
"OK",
DialogInterface.OnClickListener { dialog, which -> })
"OK"
) { _, _ -> }
}
ERROR_NO_DEVICE -> {
alert.setTitle("Empty Device")
@ -317,11 +316,11 @@ class MainActivity : AppCompatActivity() {
alert.setMessage(
"Please select a Bluetooth device."
)
alert.setOnCancelListener(DialogInterface.OnCancelListener { })
alert.setOnCancelListener { }
alert.setButton(
AlertDialog.BUTTON_POSITIVE,
"OK",
DialogInterface.OnClickListener { dialog, which -> })
"OK"
) { _, _ -> }
}
}
alert.show()

Loading…
Cancel
Save