Skip to content

Commit

Permalink
Fix a bunch of nullable ref
Browse files Browse the repository at this point in the history
  • Loading branch information
nkming2 committed Jan 22, 2018
1 parent 9d89ed6 commit cb66885
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InstallConfirmFragment : DialogFragment()

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog
{
return MaterialDialog.Builder(activity)
return MaterialDialog.Builder(activity!!)
.title(R.string.install_confirm_title)
.content(R.string.install_confirm_content)
.theme(if (_pref.isDarkTheme) Theme.DARK else Theme.LIGHT)
Expand Down Expand Up @@ -66,11 +66,11 @@ class InstallConfirmFragment : DialogFragment()
super.onDismiss(dialog)
if (activity != null && !_isNoFinish)
{
activity.finish()
activity!!.finish()
}
}

private lateinit var _listener: Listener
private var _isNoFinish = false
private val _pref by lazy{Preference.from(context)}
private val _pref by lazy{Preference.from(context!!)}
}
23 changes: 12 additions & 11 deletions src/main/kotlin/com/nkming/powermenu/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MainFragment : Fragment()
override fun onActivityCreated(savedInstanceState: Bundle?)
{
super.onActivityCreated(savedInstanceState)
if (!PermissionUtils.hasWriteExternalStorage(context))
if (!PermissionUtils.hasWriteExternalStorage(context!!))
{
_isReqPermission = true
PermissionUtils.requestWriteExternalStorage(this)
Expand All @@ -62,7 +62,7 @@ class MainFragment : Fragment()
{
// Like noHistory, not using that because we don't want the
// permission activity to kill our activity
activity.finish()
activity?.finish()
}
}

Expand Down Expand Up @@ -92,7 +92,7 @@ class MainFragment : Fragment()
{
_root.setOnClickListener(
{
activity.finish()
activity?.finish()
})
}

Expand All @@ -112,7 +112,7 @@ class MainFragment : Fragment()
.setStartDelay(Res.ANIMATION_FAST.toLong() / 2 * i)
}

val pref = Preference.from(context)
val pref = Preference.from(context!!)
_restartNormalBtn.label.text = getString(
if (pref.isSoftRebootEnabled && SystemHelper.isBusyboxPresent())
R.string.restart_mode_normal_or_soft
Expand All @@ -129,7 +129,7 @@ class MainFragment : Fragment()
})
}

val pref = Preference.from(context)
val pref = Preference.from(context!!)
if (pref.isSoftRebootEnabled && SystemHelper.isBusyboxPresent())
{
_restartNormalBtn.bound.isHapticFeedbackEnabled =
Expand All @@ -144,7 +144,7 @@ class MainFragment : Fragment()

private fun _onShutdownClick()
{
val action = object: ShutdownAction(_appContext, activity,
val action = object: ShutdownAction(_appContext, activity!!,
isExplicitTheming = true)
{
override fun onPostConfirm()
Expand Down Expand Up @@ -180,7 +180,8 @@ class MainFragment : Fragment()
activity?.unregisterReceiver(this)
}
}
activity.registerReceiver(receiver, IntentFilter(Intent.ACTION_SCREEN_ON))
activity!!.registerReceiver(receiver,
IntentFilter(Intent.ACTION_SCREEN_ON))

// Sleep will run on a new thread and involve su, that takes quite some
// time so do it at once
Expand Down Expand Up @@ -233,7 +234,7 @@ class MainFragment : Fragment()
_startReveal(_screenshotBtn.btn, R.color.screenshot_bg, true,
{
activity ?: return@_startReveal
activity.finish()
activity!!.finish()

val receiver = object: BroadcastReceiver()
{
Expand All @@ -260,7 +261,7 @@ class MainFragment : Fragment()
private fun _onRestartMenuClick(meta: RestartButtonMeta,
rebootMode: SystemHelper.RebootMode)
{
val action = object: RebootAction(_appContext, activity, rebootMode,
val action = object: RebootAction(_appContext, activity!!, rebootMode,
isExplicitTheming = true)
{
override fun onPostConfirm()
Expand Down Expand Up @@ -290,7 +291,7 @@ class MainFragment : Fragment()

private fun _onRestartNormalLongClick()
{
val action = object: SoftRebootAction(_appContext, activity,
val action = object: SoftRebootAction(_appContext, activity!!,
isExplicitTheming = true)
{
override fun onPostConfirm()
Expand Down Expand Up @@ -491,7 +492,7 @@ class MainFragment : Fragment()
bound.isEnabled = false
}

private val _appContext by lazy({activity.applicationContext})
private val _appContext by lazy({activity!!.applicationContext})
private val _handler by lazy({Handler()})
private var _activeDangerousAction: DangerousAction? = null
private var _isReqPermission = false
Expand Down

0 comments on commit cb66885

Please sign in to comment.