Various style fixes
This commit is contained in:
@@ -158,7 +158,7 @@ class DiscoverActivity : Activity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
this@DiscoverActivity.nsdManager!!.resolveService(service, resolver)
|
||||
this@DiscoverActivity.nsdManager.resolveService(service, resolver)
|
||||
} else {
|
||||
Log.d(TAG, "Unknown Service name: " + service.serviceName)
|
||||
}
|
||||
|
||||
@@ -72,14 +72,11 @@ class ListenService : Service() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
this.listenThread?.let {
|
||||
this.listenThread?.interrupt()
|
||||
this.listenThread = null
|
||||
it.interrupt()
|
||||
}
|
||||
|
||||
// Cancel the persistent notification.
|
||||
val NOTIFICATION = R.string.listening
|
||||
notificationManager.cancel(NOTIFICATION)
|
||||
notificationManager.cancel(R.string.listening)
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
// Tell the user we stopped.
|
||||
Toast.makeText(this, R.string.stopped, Toast.LENGTH_SHORT).show()
|
||||
|
||||
@@ -166,16 +166,17 @@ class MonitorService : Service() {
|
||||
// Save the service name. Android may have changed it in order to
|
||||
// resolve a conflict, so update the name you initially requested
|
||||
// with the name Android actually used.
|
||||
val serviceName = nsdServiceInfo.serviceName
|
||||
nsdServiceInfo.serviceName.let { serviceName ->
|
||||
Log.i(TAG, "Service name: $serviceName")
|
||||
val ma = monitorActivity
|
||||
ma?.runOnUiThread {
|
||||
monitorActivity?.let { ma ->
|
||||
ma.runOnUiThread {
|
||||
val statusText = ma.findViewById<TextView>(R.id.textStatus)
|
||||
statusText.setText(R.string.waitingForParent)
|
||||
val serviceText = ma.findViewById<TextView>(R.id.textService)
|
||||
serviceText.text = serviceName
|
||||
val portText = ma.findViewById<TextView>(R.id.port)
|
||||
portText.text = Integer.toString(port)
|
||||
portText.text = port.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,13 +238,13 @@ class MonitorService : Service() {
|
||||
unregisterService()
|
||||
this.connectionToken = null
|
||||
this.currentSocket?.let {
|
||||
this.currentSocket = null
|
||||
try {
|
||||
it.close()
|
||||
} catch (e: IOException) {
|
||||
Log.e(TAG, "Failed to close active socket on port $currentPort")
|
||||
}
|
||||
}
|
||||
this.currentSocket = null
|
||||
|
||||
// Cancel the persistent notification.
|
||||
this.notificationManager.cancel(R.string.listening)
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import kotlin.math.min
|
||||
|
||||
class VolumeView : View {
|
||||
private val paint: Paint
|
||||
@@ -52,8 +53,7 @@ class VolumeView : View {
|
||||
val size = volumeHistory.size() // Size is at most width
|
||||
val volumeNorm = volumeHistory.volumeNorm
|
||||
val relativeBrightness: Double = if (size > 0) {
|
||||
val normalizedVolume = volumeHistory[size - 1]
|
||||
Math.max(0.3, normalizedVolume)
|
||||
volumeHistory[size - 1].coerceAtLeast(0.3)
|
||||
} else {
|
||||
0.3
|
||||
}
|
||||
@@ -73,11 +73,11 @@ class VolumeView : View {
|
||||
}
|
||||
val margins = height * 0.1
|
||||
val graphHeight = height - 2.0 * margins
|
||||
val leftMost = Math.max(0, volumeHistory.size() - width)
|
||||
val leftMost = (volumeHistory.size() - width).coerceAtLeast(0)
|
||||
val graphScale = graphHeight * volumeNorm
|
||||
var xPrev = 0
|
||||
var yPrev = (margins + graphHeight - volumeHistory[leftMost] * graphScale).toInt()
|
||||
val length = Math.min(size, width)
|
||||
val length = min(size, width)
|
||||
for (xNext in 1 until length - 1) {
|
||||
val yNext = (margins + graphHeight - volumeHistory[leftMost + xNext] * graphScale).toInt()
|
||||
canvas.drawLine(xPrev.toFloat(), yPrev.toFloat(), xNext.toFloat(), yNext.toFloat(), paint)
|
||||
|
||||
Reference in New Issue
Block a user