private Fragment[] fragments = new Fragment[FRAGMENT_COUNT];
the length of your fragments array is 2;
so when you call
private void showFragment(int fragmentIndex, boolean addToBackStack) {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
for (int i = 0; i < fragments.length; i++) {
if (i == fragmentIndex) {
transaction.show(fragments[i]);
} else {
transaction.hide(fragments[i]);
}
}
if (addToBackStack) {
transaction.addToBackStack(null);
}
transaction.commit();
}
with fragmentIndex = 1, which is null, as you have commented the line
// fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
so it tries to show a null fragment (as the loop will still run twice, even though you have only one fragment)
that might give you a null Pointer Exception