diff options
author | Jeremy Klein <jlklein@google.com> | 2015-08-07 17:14:34 -0700 |
---|---|---|
committer | Jeremy Klein <jlklein@google.com> | 2015-08-07 17:14:34 -0700 |
commit | c7f0ab6934e86f3d85d1895c6a71e16173993213 (patch) | |
tree | ecb1c87397abda242b6a043f29adb7a2d8a7230e /app/src/main | |
parent | 50b43262ee0e16377b5738164ef8255c959ed832 (diff) | |
download | connectbot-c7f0ab6934e86f3d85d1895c6a71e16173993213.tar.gz connectbot-c7f0ab6934e86f3d85d1895c6a71e16173993213.tar.bz2 connectbot-c7f0ab6934e86f3d85d1895c6a71e16173993213.zip |
Fix some unnecesary casts and lint errors
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/org/connectbot/ConsoleActivity.java | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/app/src/main/java/org/connectbot/ConsoleActivity.java b/app/src/main/java/org/connectbot/ConsoleActivity.java index 48675e5..91abb82 100644 --- a/app/src/main/java/org/connectbot/ConsoleActivity.java +++ b/app/src/main/java/org/connectbot/ConsoleActivity.java @@ -225,9 +225,9 @@ public class ConsoleActivity extends Activity { } protected PromptHelper getCurrentPromptHelper() { - View view = adapter.getCurrentTerminalView(); - if (!(view instanceof TerminalView)) return null; - return ((TerminalView) view).bridge.promptHelper; + TerminalView view = adapter.getCurrentTerminalView(); + if (view == null) return null; + return view.bridge.promptHelper; } protected void hideAllPrompts() { @@ -591,8 +591,6 @@ public class ConsoleActivity extends Activity { } } - Configuration config = getResources().getConfiguration(); - if (event.getAction() == MotionEvent.ACTION_DOWN) { lastX = event.getX(); lastY = event.getY(); @@ -646,14 +644,14 @@ public class ConsoleActivity extends Activity { public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - View view = adapter.getCurrentTerminalView(); - final boolean activeTerminal = (view instanceof TerminalView); + TerminalView view = adapter.getCurrentTerminalView(); + final boolean activeTerminal = view != null; boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { - TerminalBridge bridge = ((TerminalView) view).bridge; + TerminalBridge bridge = view.bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); @@ -671,7 +669,7 @@ public class ConsoleActivity extends Activity { disconnect.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { // disconnect or close the currently visible session - TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); + TerminalView terminalView = adapter.getCurrentTerminalView(); TerminalBridge bridge = terminalView.bridge; bridge.dispatchDisconnect(true); @@ -711,7 +709,7 @@ public class ConsoleActivity extends Activity { portForward.setEnabled(sessionOpen && canForwardPorts); portForward.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); + TerminalView terminalView = adapter.getCurrentTerminalView(); TerminalBridge bridge = terminalView.bridge; Intent intent = new Intent(ConsoleActivity.this, PortForwardListActivity.class); @@ -728,7 +726,7 @@ public class ConsoleActivity extends Activity { urlscan.setEnabled(activeTerminal); urlscan.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - final TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); + final TerminalView terminalView = adapter.getCurrentTerminalView(); List<String> urls = terminalView.bridge.scanForURLs(); @@ -754,7 +752,7 @@ public class ConsoleActivity extends Activity { resize.setEnabled(sessionOpen); resize.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { - final TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); + final TerminalView terminalView = adapter.getCurrentTerminalView(); final View resizeView = inflater.inflate(R.layout.dia_resize, null, false); new AlertDialog.Builder(ConsoleActivity.this) @@ -792,14 +790,14 @@ public class ConsoleActivity extends Activity { setVolumeControlStream(AudioManager.STREAM_NOTIFICATION); - final View view = adapter.getCurrentTerminalView(); - boolean activeTerminal = (view instanceof TerminalView); + final TerminalView view = adapter.getCurrentTerminalView(); + boolean activeTerminal = view != null; boolean sessionOpen = false; boolean disconnected = false; boolean canForwardPorts = false; if (activeTerminal) { - TerminalBridge bridge = ((TerminalView) view).bridge; + TerminalBridge bridge = view.bridge; sessionOpen = bridge.isSessionOpen(); disconnected = bridge.isDisconnected(); canForwardPorts = bridge.canFowardPorts(); @@ -841,12 +839,12 @@ public class ConsoleActivity extends Activity { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { - final View view = adapter.getCurrentTerminalView(); - boolean activeTerminal = (view instanceof TerminalView); + final TerminalView view = adapter.getCurrentTerminalView(); + boolean activeTerminal = view != null; boolean sessionOpen = false; if (activeTerminal) { - TerminalBridge bridge = ((TerminalView) view).bridge; + TerminalBridge bridge = view.bridge; sessionOpen = bridge.isSessionOpen(); } @@ -982,12 +980,11 @@ public class ConsoleActivity extends Activity { */ private void updateDefault() { // update the current default terminal - View view = adapter.getCurrentTerminalView(); - if (!(view instanceof TerminalView)) return; + TerminalView view = adapter.getCurrentTerminalView(); + if (view == null) return; - TerminalView terminal = (TerminalView) view; if (bound == null) return; - bound.defaultBridge = terminal.bridge; + bound.defaultBridge = view.bridge; } protected void updateEmptyVisible() { @@ -1099,7 +1096,7 @@ public class ConsoleActivity extends Activity { private void pasteIntoTerminal() { // force insert of clipboard text into current console - TerminalView terminalView = (TerminalView) adapter.getCurrentTerminalView(); + TerminalView terminalView = adapter.getCurrentTerminalView(); TerminalBridge bridge = terminalView.bridge; // pull string from clipboard and generate all events to force down |