Commit 230d75b2 authored by Mygod's avatar Mygod

Refine code style

parent fdf45fbb
...@@ -56,8 +56,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet> ...@@ -56,8 +56,8 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet>
++i ++i
} }
if (i * 8 == prefixSize) return true if (i * 8 == prefixSize) return true
val mask = 256 - (1 shl (i * 8 + 8 - prefixSize)) val mask = 256 - (1 shl i * 8 + 8 - prefixSize)
return (a[i].toInt() and mask) == (b[i].toInt() and mask) return a[i].toInt() and mask == b[i].toInt() and mask
} }
override fun toString(): String = override fun toString(): String =
......
...@@ -126,7 +126,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() { ...@@ -126,7 +126,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
if (preference == hosts) BrowsableEditTextPreferenceDialogFragment().apply { if (preference == hosts) BrowsableEditTextPreferenceDialogFragment().apply {
setKey(hosts.key) setKey(hosts.key)
setTargetFragment(this@GlobalSettingsPreferenceFragment, REQUEST_BROWSE) setTargetFragment(this@GlobalSettingsPreferenceFragment, REQUEST_BROWSE)
}.show(fragmentManager ?: return, hosts.key) else super.onDisplayPreferenceDialog(preference) }.show(parentFragmentManager, hosts.key) else super.onDisplayPreferenceDialog(preference)
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
......
...@@ -136,7 +136,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), ...@@ -136,7 +136,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
PluginConfigurationDialogFragment().apply { PluginConfigurationDialogFragment().apply {
setArg(Key.pluginConfigure, pluginConfiguration.selected) setArg(Key.pluginConfigure, pluginConfiguration.selected)
setTargetFragment(this@ProfileConfigFragment, 0) setTargetFragment(this@ProfileConfigFragment, 0)
}.show(fragmentManager ?: return, Key.pluginConfigure) }.show(parentFragmentManager, Key.pluginConfigure)
} }
private fun saveAndExit() { private fun saveAndExit() {
...@@ -178,7 +178,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(), ...@@ -178,7 +178,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
Key.plugin -> BottomSheetPreferenceDialogFragment().apply { Key.plugin -> BottomSheetPreferenceDialogFragment().apply {
setArg(Key.plugin) setArg(Key.plugin)
setTargetFragment(this@ProfileConfigFragment, 0) setTargetFragment(this@ProfileConfigFragment, 0)
}.show(fragmentManager ?: return, Key.plugin) }.show(parentFragmentManager, Key.plugin)
Key.pluginConfigure -> { Key.pluginConfigure -> {
val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE) val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE)
if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else { if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else {
......
...@@ -77,8 +77,8 @@ class ProfilesDialogFragment : LeanbackListPreferenceDialogFragmentCompat() { ...@@ -77,8 +77,8 @@ class ProfilesDialogFragment : LeanbackListPreferenceDialogFragmentCompat() {
private val adapter = ProfilesAdapter() private val adapter = ProfilesAdapter()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return super.onCreateView(inflater, container, savedInstanceState)!!.also { return super.onCreateView(inflater, container, savedInstanceState)!!.apply {
val list = it.findViewById<RecyclerView>(android.R.id.list) val list = findViewById<RecyclerView>(android.R.id.list)
list.adapter = adapter list.adapter = adapter
list.layoutManager!!.scrollToPosition(adapter.profiles.indexOfFirst { it.id == DataStore.profileId }) list.layoutManager!!.scrollToPosition(adapter.profiles.indexOfFirst { it.id == DataStore.profileId })
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment