@Override protected ResponseObject doInBackground(String[] params) { ResponseObject<ArrayList<SubItem>> result = QuestionAPI.getAllMyTags(); if (TextUtils.isEmpty(UserAPI.getUserID())) { result.error_message = "无法获得用户id"; result.error = ResponseError.NO_USER_ID; } else if (result.ok) { ArrayList<SubItem> subItems = result.result; ArrayList<AskTag> myTags = new ArrayList<>(); for (int i = 0; i < subItems.size(); i++) { SubItem item = subItems.get(i); AskTag myTag = new AskTag(); myTag.setName(item.getName()); myTag.setValue(item.getValue()); myTag.setType(item.getType()); myTag.setSection(item.getSection()); myTag.setSelected(i < defaultTagsNumber); myTag.setOrder(i); myTags.add(myTag); } mergeMyGroups(myTags); AskTagHelper.putAllMyTags(myTags); getButtons(); } return result; }
private void commitChanges() { if (desk.getSenator().getList() != null && desk.getSenator().getList().size() > 0) { ArrayList<MovableButton> buttons = desk.getButtons(); ArrayList<AskTag> sections = new ArrayList<>(); for (int i = 0; i < buttons.size(); i++) { AskTag askTag = (AskTag) buttons.get(i).getSection(); if (!askTag.getSelected()) { askTag.setOrder(1024 + askTag.getOrder()); } sections.add(askTag); } if (sections.size() > 0) { AskTagHelper.putAllMyTags(sections); } setResult(RESULT_OK); } }