赞
踩
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_new_folder: {
- showCreateOrModifyFolderDialog(true);
- break;
- }
- case R.id.menu_export_text: {
- exportNoteToText();
- break;
- }
- case R.id.menu_sync: {
- if (isSyncMode()) {
- if (TextUtils.equals(item.getTitle(),
- getString(R.string.menu_sync))) {
- GTaskSyncService.startSync(this);
- } else {
- GTaskSyncService.cancelSync(this);
- }
- } else {
- startPreferenceActivity();
- }
- break;
- }
- case R.id.menu_setting: {
- startPreferenceActivity();
- break;
- }
- case R.id.menu_new_note: {
- createNewNote();
- break;
- }
- case R.id.menu_search:
- onSearchRequested();
- break;
- default:
- break;
- }
- return true;
- }
- private void exportNoteToText() {
- final BackupUtils backup = BackupUtils
- .getInstance(NotesListActivity.this);
- new AsyncTask<Void, Void, Integer>() {
-
-
- @Override
- protected Integer doInBackground(Void... unused) {
- return backup.exportToText();
- }
-
-
- @Override
- protected void onPostExecute(Integer result) {
- if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) {
- AlertDialog.Builder builder = new AlertDialog.Builder(
- NotesListActivity.this);
- builder.setTitle(NotesListActivity.this
- .getString(R.string.failed_sdcard_export));
- builder.setMessage(NotesListActivity.this
- .getString(R.string.error_sdcard_unmounted));
- builder.setPositiveButton(android.R.string.ok, null);
- builder.show();
- } else if (result == BackupUtils.STATE_SUCCESS) {
- AlertDialog.Builder builder = new AlertDialog.Builder(
- NotesListActivity.this);
- builder.setTitle(NotesListActivity.this
- .getString(R.string.success_sdcard_export));
- builder.setMessage(NotesListActivity.this.getString(
- R.string.format_exported_file_location,
- backup.getExportedTextFileName(),
- backup.getExportedTextFileDir()));
- builder.setPositiveButton(android.R.string.ok, null);
- builder.show();
- } else if (result == BackupUtils.STATE_SYSTEM_ERROR) {
- AlertDialog.Builder builder = new AlertDialog.Builder(
- NotesListActivity.this);
- builder.setTitle(NotesListActivity.this
- .getString(R.string.failed_sdcard_export));
- builder.setMessage(NotesListActivity.this
- .getString(R.string.error_sdcard_export));
- builder.setPositiveButton(android.R.string.ok, null);
- builder.show();
- }
- }
-
-
- }.execute();
- }
- public int exportToText() {
- return mTextExport.exportToText();
- }
- Cursor folderCursor = mContext.getContentResolver().query(
- Notes.CONTENT_NOTE_URI,
- NOTE_PROJECTION,
- "(" + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + " AND "
- + NoteColumns.PARENT_ID + "<>"
- + Notes.ID_TRASH_FOLER + ") OR " + NoteColumns.ID
- + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null);
- <provider
- android:name="net.micode.notes.data.NotesProvider"
- android:authorities="micode_notes"
- android:multiprocess="true" />
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。