Closed gadget-man closed 4 years ago
Yeah there are breaking changes in 1.6.0
onConnectionResult
now accepts a ConnectionSuccessListener
interface as a parameter. Have a look at MainActivity to see how this works.
I noticed that, but can't get the example you pointed to to work in Kotlin, which translates to:
`WifiUtils.withContext(mContext) .connectWith(sSID.trim(), password.trim()) .setTimeout(15000) .onConnectionResult(object : ConnectionSuccessListener { fun success() { Toast.makeText(mContext, "SUCCESS!", Toast.LENGTH_SHORT).show() }
fun failed(errorCode: ConnectionErrorCode) {
Toast.makeText(
mContext,
"EPIC FAIL!" + errorCode.toString(),
Toast.LENGTH_SHORT
).show()
}
})
.start()`
And this won't build. Also, ConnectionErrorCode doesn't seem to be available in com.thanosfisherman.wifiutils.wifiConnect (it shows red)
I also tried this:
WifiUtils.withContext(mContext).connectWith(sSID.trim(), password.trim()).setTimeout(15000).onConnectionResult( object: ConnectionSuccessListener { override fun isSuccessful(isSuccess: Boolean) { TODO("Not yet implemented") LoggerUtils.logMessage("PMN onSuccessListener") } }).start()
But get Object is not abstract and does not implement abstract member public abstract fun failed(@NonNull p0: ConnectionErrorCode): Unit defined in com.thanosfisherman.wifiutils.wifiConnect.ConnectionSuccessListener
I see some syntactical errors in your code.
I updated the sample app by including MainKotlinActivity class to demonstrate usage of the lib in Kotlin.
Check it out and let me know if you still get errors
Thank you. Not sure what I'd done but this part is working now.
I've updated to test 1.6.0, but the following command which was fine in 1.5.1 is no longer able to build:
WifiUtils.withContext(mContext).connectWith(sSID.trim(), password.trim()).setTimeout(15000).onConnectionResult {isSuccess -> mIsWifiConnected = isSuccess LoggerUtils.logMessage("Connected Status :$mIsWifiConnected") if (mIsWifiConnected) { bindToNetwork(mContext) } wifiConnector.onWifiConnected() }.start()
Type mismatch: inferred type is (???) -> Unit but ConnectionSuccessListener? was expected