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>
++i
}
if (i * 8 == prefixSize) return true
val mask = 256 - (1 shl (i * 8 + 8 - prefixSize))
return (a[i].toInt() and mask) == (b[i].toInt() and mask)
val mask = 256 - (1 shl i * 8 + 8 - prefixSize)
return a[i].toInt() and mask == b[i].toInt() and mask
}
override fun toString(): String =
......
......@@ -126,7 +126,7 @@ class GlobalSettingsPreferenceFragment : PreferenceFragmentCompat() {
if (preference == hosts) BrowsableEditTextPreferenceDialogFragment().apply {
setKey(hosts.key)
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?) {
......
......@@ -136,7 +136,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
PluginConfigurationDialogFragment().apply {
setArg(Key.pluginConfigure, pluginConfiguration.selected)
setTargetFragment(this@ProfileConfigFragment, 0)
}.show(fragmentManager ?: return, Key.pluginConfigure)
}.show(parentFragmentManager, Key.pluginConfigure)
}
private fun saveAndExit() {
......@@ -178,7 +178,7 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
Key.plugin -> BottomSheetPreferenceDialogFragment().apply {
setArg(Key.plugin)
setTargetFragment(this@ProfileConfigFragment, 0)
}.show(fragmentManager ?: return, Key.plugin)
}.show(parentFragmentManager, Key.plugin)
Key.pluginConfigure -> {
val intent = PluginManager.buildIntent(pluginConfiguration.selected, PluginContract.ACTION_CONFIGURE)
if (intent.resolveActivity(requireContext().packageManager) == null) showPluginEditor() else {
......
......@@ -77,8 +77,8 @@ class ProfilesDialogFragment : LeanbackListPreferenceDialogFragmentCompat() {
private val adapter = ProfilesAdapter()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
return super.onCreateView(inflater, container, savedInstanceState)!!.also {
val list = it.findViewById<RecyclerView>(android.R.id.list)
return super.onCreateView(inflater, container, savedInstanceState)!!.apply {
val list = findViewById<RecyclerView>(android.R.id.list)
list.adapter = adapter
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