// Called when the Activity starts, or when the App is coming to the foreground. Check to see
  // the state of the LayerClient, and if everything is set up, display all the Conversations
  public void onResume() {

    Log.d("Activity", "Conversation Activity onResume");

    super.onResume();

    // If the user is not authenticated, make sure they are logged in, and if they are,
    // re-authenticate
    if (!LayerImpl.isAuthenticated()) {

      if (ParseUser.getCurrentUser() == null) {

        Log.d("Activity", "User is not authenticated or logged in - returning to login screen");
        Utils.gotoLoginActivity(this);

      } else {

        Log.d("Activity", "User is not authenticated, but is logged in - re-authenticating user");
        LayerImpl.authenticateUser();
      }

      // Everything is set up, so start populating the Conversation list
    } else {

      Log.d("Activity", "Starting conversation view");
      setupConversationView();
    }

    ParseInstallation installation = ParseInstallation.getCurrentInstallation();
    installation.put("inMessageActivity", false);
    installation.put("user", ParseUser.getCurrentUser());
    installation.saveInBackground();
  }
  // Set up the Query Adapter that will drive the RecyclerView on the conversations_screen
  private void setupConversationView() {

    Log.d("Activity", "Setting conversation view");

    // Grab the Recycler View and list all conversation objects in a vertical list
    RecyclerView conversationsView = (RecyclerView) findViewById(R.id.recyclerView);

    // Register the button click listeners
    FloatingActionButton newConversationBtn =
        (FloatingActionButton) findViewById(R.id.newConversation);
    if (newConversationBtn != null) newConversationBtn.setOnClickListener(this);
    newConversationBtn.attachToRecyclerView(conversationsView);

    RecyclerView.LayoutManager layoutManager =
        new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    conversationsView.setLayoutManager(layoutManager);

    // The Query Adapter drives the recycler view, and calls back to this activity when the user
    // taps on a Conversation
    mConversationsAdapter =
        new ConversationQueryAdapter(
            getApplicationContext(),
            LayerImpl.getLayerClient(),
            this,
            new QueryAdapter.Callback() {
              @Override
              public void onItemInserted() {
                Log.d("Activity", "Conversation Adapter, new conversation inserted");
              }
            });

    // Attach the Query Adapter to the Recycler View
    conversationsView.setAdapter(mConversationsAdapter);

    // Execute the Query
    mConversationsAdapter.refresh();
  }