/**
   * Determine the changeid to load and send an intent to load the change. By sending an intent, the
   * main activity is notified (GerritControllerActivity on tablets. This can then tell the change
   * list adapter that we have selected a change.
   *
   * @param direct true: load this change directly, false: send out an intent
   */
  private void loadChange(boolean direct) {
    if (mStatus == null) {
      // Without the status we cannot find a changeid to load data for
      return;
    }

    Pair<String, Integer> change = SelectedChange.getSelectedChange(mContext, mStatus);
    String changeID;
    int changeNumber;

    if (change == null || change.first.isEmpty()) {
      change = Changes.getMostRecentChange(mParent, mStatus);
      if (change == null || change.first.isEmpty()) {
        // No changes to load data from
        AnalyticsHelper.sendAnalyticsEvent(
            mParent, "PatchSetViewerFragment", "load_change", "null_changeID", null);
        return;
      }
    }

    changeID = change.first;
    mChangeNumber = change.second;

    if (direct) loadChange(changeID);
    else {
      mEventBus.post(new NewChangeSelected(changeID, mChangeNumber, mStatus, this));
    }
  }
  @Override
  public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    String changeID = args.getString(PatchSetViewerFragment.CHANGE_ID);

    switch (id) {
      case LOADER_COMMIT:
        return UserChanges.getCommitProperties(mContext, changeID);
      case LOADER_PROPERTIES:
        return Changes.getCommitProperties(mContext, changeID);
      case LOADER_MESSAGE:
        return Revisions.getCommitMessage(mContext, changeID);
      case LOADER_FILES:
        return FileChanges.getFileChanges(mContext, changeID);
      case LOADER_REVIEWERS:
        return UserReviewers.getReviewersForChange(mContext, changeID);
      case LOADER_COMMENTS:
        return UserMessage.getMessagesForChange(mContext, changeID);
    }

    return null;
  }