Skip to content

Commit

Permalink
handle null pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Oct 2, 2023
1 parent 08d3bbd commit 0643148
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ViewHolderSSHAllKeyRow(private val binding: RowKeyBinding, private val lis
menu?.children?.forEach { it.setOnMenuItemClickListener(this) }
}

override fun onMenuItemClick(item: MenuItem?): Boolean {
when (item?.itemId) {
override fun onMenuItemClick(item: MenuItem): Boolean {
when (item.itemId) {
R.id.copy_public -> listener.onCopyPub(adapterPosition)
R.id.delete_key -> listener.onDelete(adapterPosition)
R.id.send_key -> listener.onSendToRaspberry(adapterPosition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class TerminalKeyListener(tm: TerminalManager?,
} else false
}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences,
key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?,
key: String?) {
if (PreferenceConstants.KEYMODE == key || PreferenceConstants.SHIFT_FKEYS == key || PreferenceConstants.CTRL_FKEYS == key || PreferenceConstants.VOLUME_FONT == key || PreferenceConstants.STICKY_MODIFIERS == key) {
updatePrefs()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ class TerminalManager : Service(), BridgeDisconnectedListener, OnSharedPreferenc
/* (non-Javadoc)
* @see android.content.SharedPreferences.OnSharedPreferenceChangeListener#onSharedPreferenceChanged(android.content.SharedPreferences, java.lang.String)
*/
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences,
key: String) {
if (PreferenceConstants.BUMPY_ARROWS == key) wantKeyVibration = sharedPreferences.getBoolean(PreferenceConstants.BUMPY_ARROWS, true)
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?,
key: String?) {
if (PreferenceConstants.BUMPY_ARROWS == key) wantKeyVibration = sharedPreferences!!.getBoolean(PreferenceConstants.BUMPY_ARROWS, true)
else if (PreferenceConstants.WIFI_LOCK == key) { } else if (PreferenceConstants.MEMKEYS == key) savingKeys = prefs!!.getBoolean(PreferenceConstants.MEMKEYS, true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ class TerminalView(context: Context, bridge: TerminalBridge, pager: TerminalView
* This should only handle scrolling when terminalTextViewOverlay is `null`, but
* we need to handle the page up/down gesture if it's enabled.
*/
override fun onScroll(e1: MotionEvent, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
// activate consider if within x tolerance
val touchSlop = ViewConfiguration.get(this@TerminalView.context).scaledTouchSlop
if (Math.abs(e1.x - e2.x) < touchSlop * 4) {
if (Math.abs(e1!!.x - e2.x) < touchSlop * 4) {
// estimate how many rows we have scrolled through
// accumulate distance that doesn't trigger immediate scroll
totalY += distanceY
Expand Down Expand Up @@ -346,7 +346,7 @@ class TerminalView(context: Context, bridge: TerminalBridge, pager: TerminalView
return super.onSingleTapConfirmed(e)
}

override fun onDoubleTap(e: MotionEvent?): Boolean {
override fun onDoubleTap(e: MotionEvent): Boolean {
try {
bridge.transport?.write(0x09)
bridge.tryKeyVibrate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ open class SSHConsole : DerivedSSHConsole(), BridgeDisconnectedListener {
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item == null) return false
return when (item.itemId) {
android.R.id.home -> {
Expand Down

0 comments on commit 0643148

Please sign in to comment.