Skip to content

Commit

Permalink
Check for null on TerminalManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kruton committed Aug 11, 2015
1 parent c175466 commit fe491c0
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions app/src/main/java/org/connectbot/ConsoleActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.view.PagerAdapter;
Expand Down Expand Up @@ -97,6 +98,7 @@ public class ConsoleActivity extends Activity {
private static final int KEYBOARD_DISPLAY_TIME = 1500;

protected ViewPager pager = null;
@Nullable
protected TerminalManager bound = null;
protected TerminalPagerAdapter adapter = null;
protected LayoutInflater inflater = null;
Expand Down Expand Up @@ -903,8 +905,9 @@ public void onPause() {
super.onPause();
Log.d(TAG, "onPause called");

if (forcedOrientation && bound != null)
if (forcedOrientation && bound != null) {
bound.setResizeAllowed(false);
}
}

@Override
Expand All @@ -922,8 +925,9 @@ public void onResume() {

configureOrientation();

if (forcedOrientation && bound != null)
if (forcedOrientation && bound != null) {
bound.setResizeAllowed(true);
}
}

/* (non-Javadoc)
Expand Down Expand Up @@ -1007,9 +1011,9 @@ private void startCopyMode() {
private void updateDefault() {
// update the current default terminal
TerminalView view = adapter.getCurrentTerminalView();
if (view == null) return;

if (bound == null) return;
if (view == null || bound == null) {
return;
}
bound.defaultBridge = view.bridge;
}

Expand Down Expand Up @@ -1189,10 +1193,15 @@ public void destroyItem(ViewGroup container, int position, Object object) {

@Override
public int getItemPosition(Object object) {
final View view = (View) object;
if (bound == null) {
return POSITION_NONE;
}

View view = (View) object;
TerminalView terminal = (TerminalView) view.findViewById(R.id.console_flip);
final HostBean host = terminal.bridge.host;
int itemIndex = -1;
HostBean host = terminal.bridge.host;

int itemIndex = POSITION_NONE;
int i = 0;
for (TerminalBridge bridge : bound.getBridges()) {
if (bridge.host.equals(host)) {
Expand All @@ -1201,14 +1210,14 @@ public int getItemPosition(Object object) {
}
i++;
}
if (itemIndex == -1) {
return POSITION_NONE;
} else {
return itemIndex;
}
return itemIndex;
}

public TerminalBridge getBridgeAtPosition(int position) {
if (bound == null) {
return null;
}

ArrayList<TerminalBridge> bridges = bound.getBridges();
if (position < 0 || position >= bridges.size()) {
return null;
Expand Down

0 comments on commit fe491c0

Please sign in to comment.