From 14d997f50078af890c7cf0359ec7c94f5194cb7f Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 4 Nov 2019 19:18:08 +0530 Subject: Cleanup Signed-off-by: Harsh Shandilya --- .../com/zeapo/pwdstore/SelectFolderActivity.kt | 2 +- .../com/zeapo/pwdstore/SelectFolderFragment.kt | 26 +++++++++------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt b/app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt index 04ff95b4..0a6dfcf6 100644 --- a/app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt @@ -27,7 +27,7 @@ class SelectFolderActivity : AppCompatActivity() { passwordList = SelectFolderFragment() val args = Bundle() - args.putString("Path", PasswordRepository.getRepositoryDirectory(applicationContext)?.absolutePath) + args.putString("Path", PasswordRepository.getRepositoryDirectory(applicationContext).absolutePath) passwordList.arguments = args diff --git a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt index 2668517b..8b1d856b 100644 --- a/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt +++ b/app/src/main/java/com/zeapo/pwdstore/SelectFolderFragment.kt @@ -38,21 +38,15 @@ import java.util.Stack class SelectFolderFragment : Fragment() { // store the pass files list in a stack - private lateinit var pathStack: Stack + private var pathStack: Stack = Stack() private lateinit var recyclerAdapter: FolderRecyclerAdapter private lateinit var recyclerView: RecyclerView - private lateinit var mListener: OnFragmentInteractionListener + private lateinit var listener: OnFragmentInteractionListener override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val path = requireArguments().getString("Path") - pathStack = Stack() - recyclerAdapter = FolderRecyclerAdapter( - mListener, - getPasswords( - File(path), - getRepositoryDirectory(requireActivity())!!, - sortOrder)) + val path = requireNotNull(requireArguments().getString("Path")) + recyclerAdapter = FolderRecyclerAdapter(listener, getPasswords(File(path), getRepositoryDirectory(requireActivity()), sortOrder)) } override fun onCreateView( @@ -78,18 +72,18 @@ class SelectFolderFragment : Fragment() { override fun onAttach(context: Context) { super.onAttach(context) try { - mListener = object : OnFragmentInteractionListener { + listener = object : OnFragmentInteractionListener { override fun onFragmentInteraction(item: PasswordItem) { if (item.type == PasswordItem.TYPE_CATEGORY) { // push the category were we're going pathStack.push(item.file) recyclerView.scrollToPosition(0) recyclerAdapter.clear() - recyclerAdapter.addAll( - getPasswords( - item.file, - getRepositoryDirectory(context)!!, - sortOrder)) + recyclerAdapter.addAll(getPasswords( + item.file, + getRepositoryDirectory(context), + sortOrder) + ) (requireActivity() as AppCompatActivity).supportActionBar?.setDisplayHomeAsUpEnabled(true) } } -- cgit v1.2.3