From 633f380aab5d1556006c5f1c29802a6fe62fee6a Mon Sep 17 00:00:00 2001 From: Zhengyu Peng Date: Wed, 23 Feb 2022 22:08:52 -0500 Subject: [PATCH] clean --- .../java/com/rookiedev/hexapod/ControlActivity.kt | 10 +++------- .../com/rookiedev/hexapod/DeviceListActivity.kt | 8 +++----- .../main/java/com/rookiedev/hexapod/MainActivity.kt | 13 ++++++------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/software/android/app/src/main/java/com/rookiedev/hexapod/ControlActivity.kt b/software/android/app/src/main/java/com/rookiedev/hexapod/ControlActivity.kt index a04bd5e..aa31534 100644 --- a/software/android/app/src/main/java/com/rookiedev/hexapod/ControlActivity.kt +++ b/software/android/app/src/main/java/com/rookiedev/hexapod/ControlActivity.kt @@ -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() diff --git a/software/android/app/src/main/java/com/rookiedev/hexapod/DeviceListActivity.kt b/software/android/app/src/main/java/com/rookiedev/hexapod/DeviceListActivity.kt index 5089d76..87babe8 100644 --- a/software/android/app/src/main/java/com/rookiedev/hexapod/DeviceListActivity.kt +++ b/software/android/app/src/main/java/com/rookiedev/hexapod/DeviceListActivity.kt @@ -23,13 +23,11 @@ class DeviceAdapter(mContext: Context?, private val devices: ArrayList(R.id.list_device_name) val textDeviceAddress = cView.findViewById(R.id.list_device_address) @@ -38,7 +36,7 @@ class DeviceAdapter(mContext: Context?, private val devices: ArrayList + OnItemClickListener { av, _, arg2, _ -> val device: BluetoothDevice = av.getItemAtPosition(arg2) as BluetoothDevice diff --git a/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt b/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt index ce2d783..1bb43aa 100644 --- a/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt +++ b/software/android/app/src/main/java/com/rookiedev/hexapod/MainActivity.kt @@ -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()