Refine code style
This commit is contained in:
@@ -363,7 +363,7 @@ style:
|
|||||||
OptionalUnit:
|
OptionalUnit:
|
||||||
active: true
|
active: true
|
||||||
OptionalWhenBraces:
|
OptionalWhenBraces:
|
||||||
active: true
|
active: false
|
||||||
PreferToOverPairSyntax:
|
PreferToOverPairSyntax:
|
||||||
active: false
|
active: false
|
||||||
ProtectedMemberInFinalClass:
|
ProtectedMemberInFinalClass:
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.netId
|
|||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels
|
||||||
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps
|
||||||
import be.mygod.vpnhotspot.util.StickyEvent0
|
import be.mygod.vpnhotspot.util.*
|
||||||
import be.mygod.vpnhotspot.util.StickyEvent1
|
|
||||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
|
||||||
import be.mygod.vpnhotspot.util.intentFilter
|
|
||||||
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
@@ -233,6 +230,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
registerReceiver(receiver, intentFilter(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION,
|
registerReceiver(receiver, intentFilter(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION,
|
||||||
WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION))
|
WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION))
|
||||||
receiverRegistered = true
|
receiverRegistered = true
|
||||||
|
try {
|
||||||
p2pManager.requestGroupInfo(channel) {
|
p2pManager.requestGroupInfo(channel) {
|
||||||
when {
|
when {
|
||||||
it == null -> doStart()
|
it == null -> doStart()
|
||||||
@@ -247,15 +245,26 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: SecurityException) {
|
||||||
|
Timber.w(e)
|
||||||
|
startFailure(e.readableMessage)
|
||||||
|
}
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* startService Step 2 (if a group isn't already available)
|
* startService Step 2 (if a group isn't already available)
|
||||||
*/
|
*/
|
||||||
private fun doStart() = p2pManager.createGroup(channel, object : WifiP2pManager.ActionListener {
|
private fun doStart() = try {
|
||||||
override fun onFailure(reason: Int) = startFailure(formatReason(R.string.repeater_create_group_failure, reason))
|
p2pManager.createGroup(channel, object : WifiP2pManager.ActionListener {
|
||||||
|
override fun onFailure(reason: Int) {
|
||||||
|
startFailure(formatReason(R.string.repeater_create_group_failure, reason))
|
||||||
|
}
|
||||||
override fun onSuccess() { } // wait for WIFI_P2P_CONNECTION_CHANGED_ACTION to fire to go to step 3
|
override fun onSuccess() { } // wait for WIFI_P2P_CONNECTION_CHANGED_ACTION to fire to go to step 3
|
||||||
})
|
})
|
||||||
|
} catch (e: SecurityException) {
|
||||||
|
Timber.w(e)
|
||||||
|
startFailure(e.readableMessage)
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Used during step 2, also called when connection changed
|
* Used during step 2, also called when connection changed
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package be.mygod.vpnhotspot.manage
|
package be.mygod.vpnhotspot.manage
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.annotation.TargetApi
|
import android.annotation.TargetApi
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -21,7 +22,8 @@ abstract class Manager {
|
|||||||
const val VIEW_TYPE_REPEATER = 7
|
const val VIEW_TYPE_REPEATER = 7
|
||||||
|
|
||||||
override fun areItemsTheSame(oldItem: Manager, newItem: Manager) = oldItem.isSameItemAs(newItem)
|
override fun areItemsTheSame(oldItem: Manager, newItem: Manager) = oldItem.isSameItemAs(newItem)
|
||||||
override fun areContentsTheSame(oldItem: Manager, newItem: Manager) = oldItem == newItem
|
@SuppressLint("DiffUtilEquals")
|
||||||
|
override fun areContentsTheSame(oldItem: Manager, newItem: Manager) = oldItem === newItem
|
||||||
|
|
||||||
fun createViewHolder(inflater: LayoutInflater, parent: ViewGroup, type: Int) = when (type) {
|
fun createViewHolder(inflater: LayoutInflater, parent: ViewGroup, type: Int) = when (type) {
|
||||||
VIEW_TYPE_INTERFACE ->
|
VIEW_TYPE_INTERFACE ->
|
||||||
|
|||||||
Reference in New Issue
Block a user