From 6ee19f79e74dede98a44422b759188717b708140 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 27 May 2020 00:14:10 +0530 Subject: Introduce and switch to FragmentViewBindingDelegate (#797) Signed-off-by: Harsh Shandilya --- .../java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/sshkeygen') diff --git a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt index 923b53a4..510f5ce2 100644 --- a/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/sshkeygen/SshKeyGenFragment.kt @@ -19,6 +19,7 @@ import com.jcraft.jsch.JSch import com.jcraft.jsch.KeyPair import com.zeapo.pwdstore.R import com.zeapo.pwdstore.databinding.FragmentSshKeygenBinding +import com.zeapo.pwdstore.utils.viewBinding import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -28,17 +29,9 @@ import java.io.FileOutputStream class SshKeyGenFragment : Fragment() { private var keyLength = 4096 - private var _binding: FragmentSshKeygenBinding? = null - private val binding get() = _binding!! + private val binding by viewBinding(FragmentSshKeygenBinding::bind) - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - _binding = FragmentSshKeygenBinding.inflate(inflater, container, false) - return binding.root - } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = binding.root override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) @@ -60,7 +53,6 @@ class SshKeyGenFragment : Fragment() { override fun onDestroyView() { super.onDestroyView() - _binding = null } // Invoked when 'Generate' button of SshKeyGenFragment clicked. Generates a -- cgit v1.2.3