Fix crash when rotating while connecting.
When being created, the MainActivity restores its references to the fragments using the FragmentManager, which looks up the fragments currently being displayed in the three positions.  However, the fragments are not actually set into these positions until the connection is complete.  Because of this, if the user rotates the device and causes the MainActivity to be destroyed and recreated, the references to the old fragments are lost.  This causes a crash when later attempting to display the fragments.  The solution is to initialize the fragments immediately before displaying them.  Additionally, a check needs to be added before hiding the keyboard using a reference to the chatFragment.  This won't cause a change in functionality because the keyboard can only be displayed once the chat fragment is actually populated with a chat, and the chat fragment cannot become populated with a chat until after the connection is already complete.