/**
   * 选择了分组,切换查看分组微博
   *
   * @param position
   * @param group
   */
  @Override
  public void onGroupSelected(int position, Group group) {
    Fragment fragment = null;
    if (position <= 2) {
      fragment = TimelineDefFragment.newInstance(group.getId());
    } else {
      fragment = TimelineGroupsFragment.newInstance(group);
    }

    setFragemnt(fragment, group.getName());

    if (materialSheetFab.isSheetVisible()) {
      materialSheetFab.hideSheet();
    }
  }
  /**
   * 显示一个Dialog,用来设置分组
   *
   * @param activity
   * @param selectedGroups
   * @param callback
   * @param titleId
   */
  public static void showOfflineGroupsModifyDialog(
      Activity activity,
      List<Group> selectedGroups,
      final OnOfflineGroupSetCallback callback,
      int titleId) {
    String[] items = new String[AppContext.getGroups().getLists().size()];
    final boolean[] editCheckedItems = new boolean[AppContext.getGroups().getLists().size()];

    for (int i = 0; i < AppContext.getGroups().getLists().size(); i++) {
      Group group = AppContext.getGroups().getLists().get(i);

      items[i] = group.getName();
      editCheckedItems[i] = false;
      for (Group groupSelectd : selectedGroups) {
        if (groupSelectd.getId().equals(group.getIdstr())) {
          editCheckedItems[i] = true;
          break;
        }
      }
    }
    AlertDialogWrapper.Builder dialogBuilder =
        new AlertDialogWrapper.Builder(activity)
            .setTitle(titleId)
            .setMultiChoiceItems(
                items,
                editCheckedItems,
                new DialogInterface.OnMultiChoiceClickListener() {

                  @Override
                  public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    editCheckedItems[which] = isChecked;
                  }
                });
    dialogBuilder
        .setNegativeButton(R.string.cancel, null)
        .setPositiveButton(
            R.string.confirm,
            new DialogInterface.OnClickListener() {

              @Override
              public void onClick(DialogInterface dialog, int which) {
                // 艹,这个控件这里有bug
                GlobalContext.getInstance()
                    .getHandler()
                    .postDelayed(
                        new Runnable() {
                          @Override
                          public void run() {
                            List<Group> groups = new ArrayList<Group>();

                            for (int i = 0; i < editCheckedItems.length; i++) {
                              if (editCheckedItems[i]) {
                                groups.add(AppContext.getGroups().getLists().get(i));
                              }
                            }

                            callback.onChanged(groups);
                          }
                        },
                        300);
              }
            })
        .show();
  }