mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-02 23:02:37 -08:00
Fix null inheritance
This commit is contained in:
1 parent
e1d997cc91
commit
47f340d576
7 files changed
+28
-30
No files matched your search
@@ -53,31 +53,31 @@ class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionLis
|
||||
val isEmpty: Boolean
|
||||
get() = mAdapter == null || mAdapter?.itemCount?:0 <= 0
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
try {
|
||||
nodeClickCallback = context as NodeAdapter.NodeClickCallback?
|
||||
nodeClickCallback = context as NodeAdapter.NodeClickCallback
|
||||
} catch (e: ClassCastException) {
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw ClassCastException(context?.toString()
|
||||
throw ClassCastException(context.toString()
|
||||
+ " must implement " + NodeAdapter.NodeClickCallback::class.java.name)
|
||||
}
|
||||
|
||||
try {
|
||||
nodeMenuListener = context as NodeAdapter.NodeMenuListener?
|
||||
nodeMenuListener = context as NodeAdapter.NodeMenuListener
|
||||
} catch (e: ClassCastException) {
|
||||
nodeMenuListener = null
|
||||
// Context menu can be omit
|
||||
Log.w(TAG, context?.toString()
|
||||
Log.w(TAG, context.toString()
|
||||
+ " must implement " + NodeAdapter.NodeMenuListener::class.java.name)
|
||||
}
|
||||
|
||||
try {
|
||||
onScrollListener = context as OnScrollListener?
|
||||
onScrollListener = context as OnScrollListener
|
||||
} catch (e: ClassCastException) {
|
||||
onScrollListener = null
|
||||
// Context menu can be omit
|
||||
Log.w(TAG, context?.toString()
|
||||
Log.w(TAG, context.toString()
|
||||
+ " must implement " + RecyclerView.OnScrollListener::class.java.name)
|
||||
}
|
||||
}
|
||||
@@ -195,14 +195,14 @@ class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionLis
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||
inflater?.inflate(R.menu.tree, menu)
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
inflater.inflate(R.menu.tree, menu)
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
|
||||
when (item?.itemId) {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
|
||||
R.id.menu_sort -> {
|
||||
context?.let { context ->
|
||||
|
||||
+2
-2
@@ -84,12 +84,12 @@ class AssignMasterKeyDialogFragment : DialogFragment() {
|
||||
keyFileChecked: Boolean, keyFile: Uri?)
|
||||
}
|
||||
|
||||
override fun onAttach(activity: Context?) {
|
||||
override fun onAttach(activity: Context) {
|
||||
super.onAttach(activity)
|
||||
try {
|
||||
mListener = activity as AssignPasswordDialogListener?
|
||||
} catch (e: ClassCastException) {
|
||||
throw ClassCastException(activity?.toString()
|
||||
throw ClassCastException(activity.toString()
|
||||
+ " must implement " + AssignPasswordDialogListener::class.java.name)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -54,12 +54,12 @@ class GeneratePasswordDialogFragment : DialogFragment() {
|
||||
private var bracketsBox: CompoundButton? = null
|
||||
private var extendedBox: CompoundButton? = null
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
try {
|
||||
mListener = context as GeneratePasswordListener?
|
||||
mListener = context as GeneratePasswordListener
|
||||
} catch (e: ClassCastException) {
|
||||
throw ClassCastException(context?.toString()
|
||||
throw ClassCastException(context.toString()
|
||||
+ " must implement " + GeneratePasswordListener::class.java.name)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -62,15 +62,15 @@ class GroupEditDialogFragment : DialogFragment(), IconPickerDialogFragment.IconP
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
// Verify that the host activity implements the callback interface
|
||||
try {
|
||||
// Instantiate the NoticeDialogListener so we can send events to the host
|
||||
editGroupListener = context as EditGroupListener?
|
||||
editGroupListener = context as EditGroupListener
|
||||
} catch (e: ClassCastException) {
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw ClassCastException(context?.toString()
|
||||
throw ClassCastException(context.toString()
|
||||
+ " must implement " + GroupEditDialogFragment::class.java.name)
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -45,13 +45,13 @@ class IconPickerDialogFragment : DialogFragment() {
|
||||
private var iconPickerListener: IconPickerListener? = null
|
||||
private var iconPack: IconPack? = null
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
try {
|
||||
iconPickerListener = context as IconPickerListener?
|
||||
iconPickerListener = context as IconPickerListener
|
||||
} catch (e: ClassCastException) {
|
||||
// The activity doesn't implement the interface, throw exception
|
||||
throw ClassCastException(context!!.toString()
|
||||
throw ClassCastException(context.toString()
|
||||
+ " must implement " + IconPickerListener::class.java.name)
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class IconPickerDialogFragment : DialogFragment() {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
builder.setNegativeButton(R.string.cancel) { _, _ -> this@IconPickerDialogFragment.dialog.cancel() }
|
||||
builder.setNegativeButton(R.string.cancel) { _, _ -> this@IconPickerDialogFragment.dialog?.cancel() }
|
||||
|
||||
return builder.create()
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ class SortDialogFragment : DialogFragment() {
|
||||
|
||||
private var recycleBinBottomView: CompoundButton? = null
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
try {
|
||||
mListener = context as SortSelectionListener?
|
||||
mListener = context as SortSelectionListener
|
||||
} catch (e: ClassCastException) {
|
||||
throw ClassCastException(context!!.toString()
|
||||
throw ClassCastException(context.toString()
|
||||
+ " must implement " + SortSelectionListener::class.java.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +36,9 @@ abstract class StylishFragment : Fragment() {
|
||||
protected var themeId: Int = 0
|
||||
protected var contextThemed: Context? = null
|
||||
|
||||
override fun onAttach(context: Context?) {
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
if (context != null) {
|
||||
this.themeId = Stylish.getThemeId(context)
|
||||
}
|
||||
this.themeId = Stylish.getThemeId(context)
|
||||
contextThemed = ContextThemeWrapper(context, themeId)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user