@Override
  public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
    CommitDetailsAdapter.Cards cardType = null;

    switch (cursorLoader.getId()) {
      case LOADER_COMMIT:
        cardType = CommitDetailsAdapter.Cards.COMMIT;
        break;
      case LOADER_PROPERTIES:
        cardType = CommitDetailsAdapter.Cards.PROPERTIES;
        break;
      case LOADER_MESSAGE:
        cardType = CommitDetailsAdapter.Cards.COMMIT_MSG;
        break;
      case LOADER_FILES:
        cardType = CommitDetailsAdapter.Cards.CHANGED_FILES;
        break;
      case LOADER_REVIEWERS:
        cardType = CommitDetailsAdapter.Cards.REVIEWERS;
        break;
      case LOADER_COMMENTS:
        cardType = CommitDetailsAdapter.Cards.COMMENTS;
        break;
    }
    if (cardType != null) mAdapter.setCursor(cardType, cursor);
  }
  private void init() {
    View currentFragment = this.getView();

    ExpandableListView mListView =
        (ExpandableListView) currentFragment.findViewById(R.id.commit_cards);
    disconnectedView = currentFragment.findViewById(R.id.disconnected_view);

    sIsLegacyVersion = !Config.isDiffSupported(mParent);

    mAdapter = new CommitDetailsAdapter(mParent);
    mListView.setAdapter(mAdapter);

    // Child click listeners (relevant for the changes cards)
    mListView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    mFilesCAB = new FilesCAB(mParent, !sIsLegacyVersion);
    mAdapter.setContextualActionBar(mFilesCAB);
    mListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ExpandableListView listView = (ExpandableListView) parent;
            long pos = listView.getExpandableListPosition(position);
            int groupPos = ExpandableListView.getPackedPositionGroup(pos);
            int childPos = ExpandableListView.getPackedPositionChild(pos);

            if (!mAdapter.isLongClickSupported(groupPos, childPos)) {
              return false;
            }

            // In case this is a group view and does not have the change number tagged
            view.setTag(R.id.changeID, mSelectedChange);
            FilesCAB.TagHolder holder =
                new FilesCAB.TagHolder(view, mContext, groupPos, childPos >= 0);

            // Set the title to be shown in the action bar
            if (holder.filePath != null) {
              mFilesCAB.setTitle(holder.filePath);
            } else {
              String s = mParent.getResources().getString(R.string.change_detail_heading);
              mFilesCAB.setTitle(String.format(s, holder.changeNumber.intValue()));
            }

            mFilesCAB.setActionMode(getActivity().startActionMode(mFilesCAB));
            ActionMode actionMode = mFilesCAB.getActionMode();

            // Call requires API 14 (ICS)
            actionMode.setTag(holder);
            view.setSelected(true);
            return true;
          }
        });
    mListView.setOnChildClickListener(
        new ExpandableListView.OnChildClickListener() {
          @Override
          public boolean onChildClick(
              ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
            // This is only valid for the changed files group
            int childItemType = mAdapter.getChildType(groupPosition, childPosition);
            if (childItemType != CommitDetailsAdapter.Cards.CHANGED_FILES.ordinal()) {
              return false;
            }
            // View the diff and close the CAB if a change diff could be viewed
            boolean diffLaunched = PatchSetChangesCard.onViewClicked(mParent, v);
            if (diffLaunched) {
              ActionMode mode = mFilesCAB.getActionMode();
              if (mode != null) mode.finish();
            }
            return diffLaunched;
          }
        });

    // Remember to expand the groups which don't have a header otherwise they will not be shown
    mListView.expandGroup(0);

    Button retryButton = (Button) currentFragment.findViewById(R.id.btn_retry);
    retryButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            sendRequest(GerritService.DataType.CommitDetails);
          }
        });

    if (getArguments() == null) {
      /** This should be the default value of {@link ChangeListFragment.mSelectedStatus } */
      setStatus(JSONCommit.Status.NEW.toString());
      loadChange(true);
    } else {
      Bundle args = getArguments();
      setStatus(args.getString(STATUS));
      String changeid = args.getString(CHANGE_ID);
      mChangeNumber = args.getInt(CHANGE_NO);

      if (changeid != null && !changeid.isEmpty()) {
        loadChange(changeid);
      }
    }

    mEventBus = EventBus.getDefault();
  }