Commit dec2059a authored by Mygod's avatar Mygod

Fix NPE in primaryClip

parent f7083025
...@@ -368,14 +368,14 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener { ...@@ -368,14 +368,14 @@ class ProfilesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener {
} }
R.id.action_import -> { R.id.action_import -> {
try { try {
val profiles = Profile.findAll(clipboard.primaryClip.getItemAt(0).text).toList() val profiles = Profile.findAll(clipboard.primaryClip!!.getItemAt(0).text).toList()
if (profiles.isNotEmpty()) { if (profiles.isNotEmpty()) {
profiles.forEach { ProfileManager.createProfile(it) } profiles.forEach { ProfileManager.createProfile(it) }
Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_msg, Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_msg,
Snackbar.LENGTH_LONG).show() Snackbar.LENGTH_LONG).show()
return true return true
} }
} catch (_: IndexOutOfBoundsException) { } } catch (_: Exception) { }
Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_err, Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_err,
Snackbar.LENGTH_LONG).show() Snackbar.LENGTH_LONG).show()
true true
......
...@@ -438,7 +438,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, ...@@ -438,7 +438,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
} }
R.id.action_import -> { R.id.action_import -> {
try { try {
adapter.addToProxy(clipboard.primaryClip.getItemAt(0).text.toString()) != null check(adapter.addToProxy(clipboard.primaryClip!!.getItemAt(0).text.toString()) != null)
} catch (exc: Exception) { } catch (exc: Exception) {
Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_err, Snackbar.make(requireActivity().findViewById(R.id.snackbar), R.string.action_import_err,
Snackbar.LENGTH_LONG).show() Snackbar.LENGTH_LONG).show()
......
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