diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2019-11-04 19:18:08 +0530 |
---|---|---|
committer | Harsh Shandilya <msfjarvis@gmail.com> | 2019-11-04 19:50:48 +0530 |
commit | 14d997f50078af890c7cf0359ec7c94f5194cb7f (patch) | |
tree | 5a3b342e9c4cbb80a7a822978981c0ca8b1303e3 /app/src | |
parent | 077e67d8e3537463a9719c4bc9f663bbe143978b (diff) |
Cleanup
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/SelectFolderActivity.kt | 2 | ||||
-rw-r--r-- | app/src/main/java/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<File> + private var pathStack: Stack<File> = 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) } } |