示例#1
0
  /**
   * 选择了分组,切换查看分组微博
   *
   * @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();
    }
  }
示例#2
0
  private void setupFab(Bundle savedInstanceState) {
    ArrayList<Group> groupList = new ArrayList<>();
    // 全部微博
    Group group = new Group();
    group.setName(getString(R.string.timeline_all));
    group.setId("statusesFriendsTimeLine");
    groupList.add(group);
    // 互相关注
    group = new Group();
    group.setName(getString(R.string.timeline_bilateral));
    group.setId("statusesBilateralTimeLine");
    groupList.add(group);
    // 发给我的
    group = new Group();
    group.setName(getString(R.string.timeline_tome));
    group.setId("statusesToMe");
    groupList.add(group);
    // 分组微博
    groupList.addAll(AppContext.getAccount().getGroups().getLists());

    fabGroupsFragment =
        (FabGroupsFragment) getFragmentManager().findFragmentById(R.id.fragmentFabGroups);
    fabGroupsFragment.resetSelectedPosition();
    fabGroupsFragment.setItems(groupList);

    View sheetView = findViewById(R.id.fab_sheet);
    View overlay = findViewById(R.id.overlay);
    int sheetColor = getResources().getColor(R.color.comm_white);
    int fabColor = MDHelper.resolveColor(this, R.attr.colorPrimary, Color.BLACK);

    materialSheetFab = new MaterialSheetFab(fabBtn, sheetView, overlay, sheetColor, fabColor);
    materialSheetFab.setEventListener(
        new MaterialSheetFabEventListener() {

          @Override
          public void onShowSheet() {
            super.onShowSheet();

            fabGroupsFragment.show();

            MobclickAgent.onEvent(MainActivity.this, "fab_groups");
          }
        });
    materialSheetFab.showFab();
  }
示例#3
0
  /**
   * 显示一个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();
  }