|  |  |  | @ -281,26 +281,6 @@ public class BookcasePresenter implements BasePresenter { | 
			
		
	
		
			
				
					|  |  |  |  |                     mBookcaseFragment.getmBtnAddGroup().performClick(); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |  |             /*initBookGroups(true); | 
			
		
	
		
			
				
					|  |  |  |  |             showSelectGroupDia((dialog, which) -> { | 
			
		
	
		
			
				
					|  |  |  |  |                 if (which < mBookGroups.size()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     BookGroup bookGroup = mBookGroups.get(which); | 
			
		
	
		
			
				
					|  |  |  |  |                     ArrayList<Book> mSelectBooks = (ArrayList<Book>) mBookcaseAdapter.getSelectBooks(); | 
			
		
	
		
			
				
					|  |  |  |  |                     for (Book book : mSelectBooks) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (!bookGroup.getId().equals(book.getGroupId())) { | 
			
		
	
		
			
				
					|  |  |  |  |                             book.setGroupId(bookGroup.getId()); | 
			
		
	
		
			
				
					|  |  |  |  |                             book.setGroupSort(0); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     mBookService.updateBooks(mSelectBooks); | 
			
		
	
		
			
				
					|  |  |  |  |                     ToastUtils.showSuccess("成功将《" + mSelectBooks.get(0).getName() + "》" | 
			
		
	
		
			
				
					|  |  |  |  |                             + (mSelectBooks.size() > 1 ? "等" : "") | 
			
		
	
		
			
				
					|  |  |  |  |                             + "加入[" + bookGroup.getName() + "]分组"); | 
			
		
	
		
			
				
					|  |  |  |  |                     init(); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else if (which == mBookGroups.size()) { | 
			
		
	
		
			
				
					|  |  |  |  |                     showAddOrRenameGroupDia(false, true, 0); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             });*/ | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -646,124 +626,6 @@ public class BookcasePresenter implements BasePresenter { | 
			
		
	
		
			
				
					|  |  |  |  |                 }).show(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 添加/重命名分组对话框 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private void showAddOrRenameGroupDia(boolean isRename, boolean isAddGroup, int groupNum){ | 
			
		
	
		
			
				
					|  |  |  |  |         View view = LayoutInflater.from(mMainActivity).inflate(R.layout.edit_dialog, null); | 
			
		
	
		
			
				
					|  |  |  |  |         TextInputLayout textInputLayout = view.findViewById(R.id.text_input_lay); | 
			
		
	
		
			
				
					|  |  |  |  |         textInputLayout.setCounterMaxLength(10); | 
			
		
	
		
			
				
					|  |  |  |  |         EditText editText = textInputLayout.getEditText(); | 
			
		
	
		
			
				
					|  |  |  |  |         editText.setHint("请输入分组名"); | 
			
		
	
		
			
				
					|  |  |  |  |         BookGroup bookGroup = !isRename ? new BookGroup() : mBookGroups.get(groupNum); | 
			
		
	
		
			
				
					|  |  |  |  |         String oldName = bookGroup.getName(); | 
			
		
	
		
			
				
					|  |  |  |  |         if (isRename) { | 
			
		
	
		
			
				
					|  |  |  |  |             editText.setText(oldName); | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         editText.requestFocus(); | 
			
		
	
		
			
				
					|  |  |  |  |         InputMethodManager imm = (InputMethodManager) mMainActivity.getSystemService(Context.INPUT_METHOD_SERVICE); | 
			
		
	
		
			
				
					|  |  |  |  |         mHandler.postDelayed(() ->{ | 
			
		
	
		
			
				
					|  |  |  |  |             imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED); | 
			
		
	
		
			
				
					|  |  |  |  |         }, 220); | 
			
		
	
		
			
				
					|  |  |  |  |         AlertDialog newGroupDia = MyAlertDialog.build(mMainActivity) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setTitle(!isRename ? "新建分组" : "重命名分组") | 
			
		
	
		
			
				
					|  |  |  |  |                 .setView(view) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setCancelable(false) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setPositiveButton("确认", null) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setNegativeButton("取消", null) | 
			
		
	
		
			
				
					|  |  |  |  |                 .show(); | 
			
		
	
		
			
				
					|  |  |  |  |         Button posBtn = newGroupDia.getButton(AlertDialog.BUTTON_POSITIVE); | 
			
		
	
		
			
				
					|  |  |  |  |         posBtn.setEnabled(false); | 
			
		
	
		
			
				
					|  |  |  |  |         posBtn.setOnClickListener(v1 -> { | 
			
		
	
		
			
				
					|  |  |  |  |             CharSequence newGroupName = editText.getText().toString(); | 
			
		
	
		
			
				
					|  |  |  |  |             for (CharSequence oldGroupName : mGroupNames){ | 
			
		
	
		
			
				
					|  |  |  |  |                 if (oldGroupName.equals(newGroupName)){ | 
			
		
	
		
			
				
					|  |  |  |  |                     ToastUtils.showWarring("分组[" + newGroupName + "]已存在,无法" + (!isRename ? "添加!" : "重命名!")); | 
			
		
	
		
			
				
					|  |  |  |  |                     return; | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             bookGroup.setName(newGroupName.toString()); | 
			
		
	
		
			
				
					|  |  |  |  |             if (!isRename) { | 
			
		
	
		
			
				
					|  |  |  |  |                 mBookGroupService.addBookGroup(bookGroup); | 
			
		
	
		
			
				
					|  |  |  |  |             }else { | 
			
		
	
		
			
				
					|  |  |  |  |                 mBookGroupService.updateEntity(bookGroup); | 
			
		
	
		
			
				
					|  |  |  |  |                 SharedPreUtils spu = SharedPreUtils.getInstance(); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (spu.getString(mMainActivity.getString(R.string.curBookGroupName), "").equals(oldName)){ | 
			
		
	
		
			
				
					|  |  |  |  |                     spu.putString(mMainActivity.getString(R.string.curBookGroupName), newGroupName.toString()); | 
			
		
	
		
			
				
					|  |  |  |  |                     ogcl.onChange(); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |             ToastUtils.showSuccess("成功" + | 
			
		
	
		
			
				
					|  |  |  |  |                     (!isRename ? "添加分组[" : "成功将[" + oldName + "]重命名为[") | 
			
		
	
		
			
				
					|  |  |  |  |                     + bookGroup.getName() + "]"); | 
			
		
	
		
			
				
					|  |  |  |  |             imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED); | 
			
		
	
		
			
				
					|  |  |  |  |             newGroupDia.dismiss(); | 
			
		
	
		
			
				
					|  |  |  |  |             if (isAddGroup){ | 
			
		
	
		
			
				
					|  |  |  |  |                 mBookcaseFragment.getmBtnAddGroup().performClick(); | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |         editText.addTextChangedListener(new TextWatcher() { | 
			
		
	
		
			
				
					|  |  |  |  |             @Override | 
			
		
	
		
			
				
					|  |  |  |  |             public void beforeTextChanged(CharSequence s, int start, int count, int after) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             @Override | 
			
		
	
		
			
				
					|  |  |  |  |             public void onTextChanged(CharSequence s, int start, int before, int count) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             @Override | 
			
		
	
		
			
				
					|  |  |  |  |             public void afterTextChanged(Editable s) { | 
			
		
	
		
			
				
					|  |  |  |  |                 String text = editText.getText().toString(); | 
			
		
	
		
			
				
					|  |  |  |  |                 if (editText.getText().length() > 0 && editText.getText().length() <= 10 && !text.equals(oldName)) { | 
			
		
	
		
			
				
					|  |  |  |  |                     posBtn.setEnabled(true); | 
			
		
	
		
			
				
					|  |  |  |  |                 } else { | 
			
		
	
		
			
				
					|  |  |  |  |                     posBtn.setEnabled(false); | 
			
		
	
		
			
				
					|  |  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         }); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 删除分组对话框 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     private void showDeleteGroupDia() { | 
			
		
	
		
			
				
					|  |  |  |  |         boolean[] checkedItems = new boolean[mGroupNames.length]; | 
			
		
	
		
			
				
					|  |  |  |  |         new MultiChoiceDialog().create(mMainActivity, "删除分组", mGroupNames | 
			
		
	
		
			
				
					|  |  |  |  |                 , checkedItems, 0, (dialog, which) -> { | 
			
		
	
		
			
				
					|  |  |  |  |                     StringBuilder sb = new StringBuilder(); | 
			
		
	
		
			
				
					|  |  |  |  |                     for (int i = 0; i < checkedItems.length; i++) { | 
			
		
	
		
			
				
					|  |  |  |  |                         if (checkedItems[i]) { | 
			
		
	
		
			
				
					|  |  |  |  |                             mBookGroupService.deleteEntity(mBookGroups.get(i)); | 
			
		
	
		
			
				
					|  |  |  |  |                             sb.append(mBookGroups.get(i).getName()).append("、"); | 
			
		
	
		
			
				
					|  |  |  |  |                         } | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     if (sb.length() > 0){ | 
			
		
	
		
			
				
					|  |  |  |  |                         sb.deleteCharAt(sb.lastIndexOf("、")); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     SharedPreUtils spu = SharedPreUtils.getInstance(); | 
			
		
	
		
			
				
					|  |  |  |  |                     if (mBookGroupService.getGroupById(spu.getString(mMainActivity.getString(R.string.curBookGroupId), "")) == null){ | 
			
		
	
		
			
				
					|  |  |  |  |                         spu.putString(mMainActivity.getString(R.string.curBookGroupId), ""); | 
			
		
	
		
			
				
					|  |  |  |  |                         spu.putString(mMainActivity.getString(R.string.curBookGroupName), ""); | 
			
		
	
		
			
				
					|  |  |  |  |                         ogcl.onChange(); | 
			
		
	
		
			
				
					|  |  |  |  |                         init(); | 
			
		
	
		
			
				
					|  |  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |  |                     ToastUtils.showSuccess("分组[" + sb.toString() + "]删除成功!"); | 
			
		
	
		
			
				
					|  |  |  |  |                 }, null, null); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     //显示选择书籍对话框
 | 
			
		
	
		
			
				
					|  |  |  |  |     private void showSelectGroupDia(DialogInterface.OnClickListener onClickListener){ | 
			
		
	
		
			
				
					|  |  |  |  |         MyAlertDialog.build(mMainActivity) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setTitle("选择分组") | 
			
		
	
		
			
				
					|  |  |  |  |                 .setItems(mGroupNames, onClickListener) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setCancelable(false) | 
			
		
	
		
			
				
					|  |  |  |  |                 .setPositiveButton("取消", null) | 
			
		
	
		
			
				
					|  |  |  |  |                 .show(); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     //分组切换监听器
 | 
			
		
	
		
			
				
					|  |  |  |  |     public void addOnGroupChangeListener(MainActivity.OnGroupChangeListener ogcl){ | 
			
		
	
		
			
				
					|  |  |  |  |         this.ogcl = ogcl; | 
			
		
	
	
		
			
				
					|  |  |  | 
 |