diff --git a/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NotesListActivity.java index e843aec..e559d8b 100644 --- a/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/01src/XiaoMiNotes/MyApplication/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -331,6 +331,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt public void onClick(DialogInterface dialog, int which) { batchDelete(); + //Notesback(); } }); builder.setNegativeButton(android.R.string.cancel, null); @@ -505,6 +506,32 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } }.execute(); } + private void Notesback(){ + new AsyncTask>() { + protected HashSet doInBackground(Void... unused) { + HashSet widgets = mNotesListAdapter.getSelectedWidget(); + + if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter + .getSelectedItemIds(), Notes.ID_ROOT_FOLDER)) { + Log.e(TAG, "Move notes to trash folder error, should not happens"); + } + return widgets; + } + @Override + protected void onPostExecute(HashSet widgets) { + if (widgets != null) { + for (AppWidgetAttribute widget : widgets) { + if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID + && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) { + updateWidget(widget.widgetId, widget.widgetType); + } + } + } + mModeCallBack.finishActionMode(); + } + }.execute(); + //DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter.getSelectedItemIds(),Notes.ID_ROOT_FOLDER); + } private void deleteFolder(long folderId) { if (folderId == Notes.ID_ROOT_FOLDER) { @@ -579,6 +606,74 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } + + private void showTimeGet() {//获取倒计时时间 + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("请输入倒计时时间");//标题 + View view = LayoutInflater.from(this).inflate(R.layout.get_time, null); + final EditText hour = (EditText) view.findViewById(R.id.hour); + final EditText min = (EditText) view.findViewById(R.id.min); + final EditText sec = (EditText) view.findViewById(R.id.sec); + showSoftInput();//打开键盘 + builder.setPositiveButton(android.R.string.ok, null);// 确认(逻辑在下方) + builder.setNegativeButton(android.R.string.cancel, null); + final Dialog dialog = builder.setView(view).show();//显示 + + final Button positive = (Button) dialog.findViewById(android.R.id.button1); + positive.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(v.getContext(), net.micode.notes.timer.CountDown.class); + long h=Long.parseLong(hour.getText().toString()); + intent.putExtra("hour",h); + long m=Long.parseLong(min.getText().toString()); + intent.putExtra("min",m); + long s=Long.parseLong(sec.getText().toString()); + intent.putExtra("sec",s); + Toast.makeText(v.getContext(), "正在跳转", Toast.LENGTH_SHORT).show(); + startActivity(intent);//跳转页面到倒计时 + + dialog.dismiss(); + } + }); + + + //后面全是监听器 + if (TextUtils.isEmpty(hour.getText())) { + positive.setEnabled(false); + } + hour.addTextChangedListener(new TextWatcher() {//监听器 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (!TextUtils.isEmpty(hour.getText())&&!TextUtils.isEmpty(min.getText()) + &&!TextUtils.isEmpty(sec.getText())) + {positive.setEnabled(true);} + else{positive.setEnabled(false);} + } + public void afterTextChanged(Editable s) {} + }); + min.addTextChangedListener(new TextWatcher() {//监听器 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (!TextUtils.isEmpty(hour.getText())&&!TextUtils.isEmpty(min.getText()) + &&!TextUtils.isEmpty(sec.getText())) + {positive.setEnabled(true);} + else{positive.setEnabled(false);} + } + public void afterTextChanged(Editable s) {} + }); + sec.addTextChangedListener(new TextWatcher() {//监听器 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (!TextUtils.isEmpty(hour.getText())&&!TextUtils.isEmpty(min.getText()) + &&!TextUtils.isEmpty(sec.getText())) + {positive.setEnabled(true);} + else{positive.setEnabled(false);} + } + public void afterTextChanged(Editable s) {} + }); + } + private void showCreateOrModifyFolderDialog(final boolean create) { final AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); @@ -812,6 +907,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt case R.id.menu_search: onSearchRequested(); break; + case R.id.menu_countdown: + showTimeGet(); + break; default: break; } diff --git a/01src/XiaoMiNotes/MyApplication/app/src/main/res/menu/note_list.xml b/01src/XiaoMiNotes/MyApplication/app/src/main/res/menu/note_list.xml index 42ea736..2545414 100644 --- a/01src/XiaoMiNotes/MyApplication/app/src/main/res/menu/note_list.xml +++ b/01src/XiaoMiNotes/MyApplication/app/src/main/res/menu/note_list.xml @@ -15,7 +15,7 @@ limitations under the License. --> - + android:title="@string/menu_search" /> +