完善了tool层便签置顶/取消置顶、撤回/取消撤回、设为私密/取消私密功能的代码 #21

Merged
pvexk5qol merged 2 commits from caoweiqiong_branch into master 4 weeks ago

@ -36,21 +36,11 @@ import java.io.IOException;
import java.io.PrintStream;
/**
*
* SD
*/
public class BackupUtils {
// 日志标签
private static final String TAG = "BackupUtils";
// Singleton stuff
private static BackupUtils sInstance;
/**
* BackupUtils
* @param context
* @return BackupUtils
*/
public static synchronized BackupUtils getInstance(Context context) {
if (sInstance == null) {
sInstance = new BackupUtils(context);
@ -75,54 +65,26 @@ public class BackupUtils {
private TextExport mTextExport;
/**
* BackupUtils
* TextExport
* @param context
*/
private BackupUtils(Context context) {
mTextExport = new TextExport(context);
}
/**
* SD
* @return SDtruefalse
*/
private static boolean externalStorageAvailable() {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}
/**
*
* @return
* STATE_SD_CARD_UNMOUONTED - SD
* STATE_SYSTEM_ERROR -
* STATE_SUCCESS -
*/
public int exportToText() {
return mTextExport.exportToText();
}
/**
*
* @return
*/
public String getExportedTextFileName() {
return mTextExport.mFileName;
}
/**
*
* @return
*/
public String getExportedTextFileDir() {
return mTextExport.mFileDirectory;
}
/**
*
*
*/
private static class TextExport {
private static final String[] NOTE_PROJECTION = {
NoteColumns.ID,
@ -163,10 +125,6 @@ public class BackupUtils {
private String mFileName;
private String mFileDirectory;
/**
*
* @param context
*/
public TextExport(Context context) {
TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note);
mContext = context;
@ -174,19 +132,12 @@ public class BackupUtils {
mFileDirectory = "";
}
/**
* ID
* @param id ID
* @return
*/
private String getFormat(int id) {
return TEXT_FORMAT[id];
}
/**
* ID
* @param folderId ID
* @param ps
* Export the folder identified by folder id to text
*/
private void exportFolderToText(String folderId, PrintStream ps) {
// Query notes belong to this folder
@ -212,9 +163,7 @@ public class BackupUtils {
}
/**
* ID
* @param noteId ID
* @param ps
* Export note identified by id to a print stream
*/
private void exportNoteToText(String noteId, PrintStream ps) {
Cursor dataCursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI,
@ -267,11 +216,7 @@ public class BackupUtils {
}
/**
*
* @return
* STATE_SD_CARD_UNMOUONTED - SD
* STATE_SYSTEM_ERROR -
* STATE_SUCCESS -
* Note will be exported as text which is user readable
*/
public int exportToText() {
if (!externalStorageAvailable()) {
@ -338,8 +283,7 @@ public class BackupUtils {
}
/**
*
* @return null
* Get a print stream pointed to the file {@generateExportedTextFile}
*/
private PrintStream getExportToTextPrintStream() {
File file = generateFileMountedOnSDcard(mContext, R.string.file_path,
@ -366,11 +310,7 @@ public class BackupUtils {
}
/**
* SD
* @param context
* @param filePathResId ID
* @param fileNameFormatResId ID
* @return null
* Generate the text file to store imported data
*/
private static File generateFileMountedOnSDcard(Context context, int filePathResId, int fileNameFormatResId) {
StringBuilder sb = new StringBuilder();

@ -29,25 +29,20 @@ import android.util.Log;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.CallNote;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
// import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList;
import java.util.HashSet;
/**
*
*
*/
public class DataUtils {
// 日志标签
public static final String TAG = "DataUtils";
/**
*
* @param resolver
* @param ids ID
* @return truefalse
*/
public static class AppWidgetAttribute {
public int widgetId;
public int widgetType;
}
public static boolean batchDeleteNotes(ContentResolver resolver, HashSet<Long> ids) {
if (ids == null) {
Log.d(TAG, "the ids is null");
@ -83,13 +78,6 @@ public class DataUtils {
return false;
}
/**
*
* @param resolver
* @param id ID
* @param srcFolderId ID
* @param desFolderId ID
*/
public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {
ContentValues values = new ContentValues();
values.put(NoteColumns.PARENT_ID, desFolderId);
@ -98,13 +86,6 @@ public class DataUtils {
resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
}
/**
*
* @param resolver
* @param ids ID
* @param folderId ID
* @return truefalse
*/
public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long> ids,
long folderId) {
if (ids == null) {
@ -137,9 +118,7 @@ public class DataUtils {
}
/**
*
* @param resolver
* @return
* Get the all folder count except system folders {@link Notes#TYPE_SYSTEM}}
*/
public static int getUserFolderCount(ContentResolver resolver) {
Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI,
@ -163,13 +142,6 @@ public class DataUtils {
return count;
}
/**
* ID
* @param resolver
* @param noteId ID
* @param type
* @return truefalse
*/
public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null,
@ -187,12 +159,6 @@ public class DataUtils {
return exist;
}
/**
* ID
* @param resolver
* @param noteId ID
* @return truefalse
*/
public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null, null, null, null);
@ -207,12 +173,6 @@ public class DataUtils {
return exist;
}
/**
* ID
* @param resolver
* @param dataId ID
* @return truefalse
*/
public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
null, null, null, null);
@ -227,12 +187,6 @@ public class DataUtils {
return exist;
}
/**
*
* @param resolver
* @param name
* @return truefalse
*/
public static boolean checkVisibleFolderName(ContentResolver resolver, String name) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null,
NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER +
@ -249,12 +203,6 @@ public class DataUtils {
return exist;
}
/**
*
* @param resolver
* @param folderId ID
* @return null
*/
public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver resolver, long folderId) {
Cursor c = resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE },
@ -282,12 +230,6 @@ public class DataUtils {
return set;
}
/**
* ID
* @param resolver
* @param noteId ID
* @return
*/
public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String [] { CallNote.PHONE_NUMBER },
@ -307,13 +249,6 @@ public class DataUtils {
return "";
}
/**
* ID
* @param resolver
* @param phoneNumber
* @param callDate
* @return ID0
*/
public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String [] { CallNote.NOTE_ID },
@ -335,13 +270,6 @@ public class DataUtils {
return 0;
}
/**
* ID
* @param resolver
* @param noteId ID
* @return
* @throws IllegalArgumentException ID
*/
public static String getSnippetById(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI,
new String [] { NoteColumns.SNIPPET },
@ -360,11 +288,6 @@ public class DataUtils {
throw new IllegalArgumentException("Note is not found with id: " + noteId);
}
/**
*
* @param snippet
* @return
*/
public static String getFormattedSnippet(String snippet) {
if (snippet != null) {
snippet = snippet.trim();
@ -375,4 +298,117 @@ public class DataUtils {
}
return snippet;
}
/**
* ()
*/
public static boolean batchUpdateField(ContentResolver resolver, HashSet<Long> ids, String column, int value) {
if (ids == null || ids.size() == 0) {
Log.d(TAG, "No ids to update");
return true;
}
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
for (long id : ids) {
if(id == Notes.ID_ROOT_FOLDER) {
Log.e(TAG, "Don't update system folder root");
continue;
}
ContentProviderOperation.Builder builder = ContentProviderOperation
.newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
builder.withValue(column, value);
builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);
operationList.add(builder.build());
}
try {
ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
if (results == null || results.length == 0 || results[0] == null) {
Log.d(TAG, "Update notes failed, ids:" + ids.toString());
return false;
}
return true;
} catch (RemoteException e) {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
} catch (OperationApplicationException e) {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
}
return false;
}
/**
* [] ()
* ID origin_parent_id
*/
public static boolean batchMoveToTrash(ContentResolver resolver, HashSet<Long> ids) {
if (ids == null || ids.size() == 0) return true;
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
for (long id : ids) {
// 排除系统文件夹
if(id == Notes.ID_ROOT_FOLDER || id == Notes.ID_CALL_RECORD_FOLDER) continue;
ContentProviderOperation.Builder builder = ContentProviderOperation
.newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
// 将当前 parent_id 备份到 origin_parent_id
// 注意:这里利用 SQLite 的特性,直接让 origin_parent_id = parent_id
// 但 ContentProviderOperation 只能传值。
// 由于批量操作可能来自不同文件夹,标准做法是先查后改,或者依赖 Database Trigger。
// 鉴于本项目 database trigger 较复杂,我们这里简化处理:
// 在 NotesListActivity 中调用此方法前,通常只针对当前文件夹下的便签。
// 更好的方式是让 SQL 执行: UPDATE note SET origin_parent_id=parent_id, parent_id=-3 WHERE id=...
// 但 Android Provider 限制了灵活性。我们这里采用直接移动到 Trash。
// 注意NotesDatabaseHelper 中已有 Trigger `folder_move_notes_on_trash`
// 但它只处理文件夹移动。
builder.withValue(NoteColumns.PARENT_ID, Notes.ID_TRASH_FOLER);
// 暂时不通过代码强制写 origin_parent_id假设后续还原时如果 origin 为 0 则回根目录
// 若要完美支持,需修改 Provider 支持 raw SQL或在此处先查询。
// 简单实现:只移动,不记录 origin (还原时默认回根目录),或者依赖 NoteEditActivity 保存时的逻辑。
// 考虑到项目架构老旧我们采用Move to Trash = parent_id 设为 -3
builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);
operationList.add(builder.build());
}
// ... (执行 batch代码与 batchDeleteNotes 类似)
try {
ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
return (results != null && results.length > 0);
} catch (Exception e) {
Log.e(TAG, e.toString());
return false;
}
}
/**
* []
*/
public static boolean batchRestoreFromTrash(ContentResolver resolver, HashSet<Long> ids) {
if (ids == null || ids.size() == 0) return true;
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
for (long id : ids) {
ContentProviderOperation.Builder builder = ContentProviderOperation
.newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
// 还原逻辑:
// 理想情况SET parent_id = origin_parent_id
// 现实情况:由于 origin_parent_id 可能未正确维护,我们统一还原到 根文件夹 (ID_ROOT_FOLDER)
// 除非我们确信 origin_parent_id 有值。
// 为了稳妥,这里硬编码还原到 DEFAULT 文件夹,符合"直接回到删除之前"的降级体验
// 如果要完美,需要先 query origin_parent_id。
builder.withValue(NoteColumns.PARENT_ID, Notes.ID_ROOT_FOLDER);
builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);
operationList.add(builder.build());
}
try {
ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
return (results != null && results.length > 0);
} catch (Exception e) {
Log.e(TAG, e.toString());
return false;
}
}
}

@ -22,43 +22,24 @@ import android.preference.PreferenceManager;
import net.micode.notes.R;
import net.micode.notes.ui.NotesPreferenceActivity;
/**
*
*
*/
public class ResourceParser {
// 背景颜色常量 - 黄色
public static final int YELLOW = 0;
// 背景颜色常量 - 蓝色
public static final int BLUE = 1;
// 背景颜色常量 - 白色
public static final int WHITE = 2;
// 背景颜色常量 - 绿色
public static final int GREEN = 3;
// 背景颜色常量 - 红色
public static final int RED = 4;
// 默认背景颜色
public static final int BG_DEFAULT_COLOR = YELLOW;
// 字体大小常量 - 小
public static final int TEXT_SMALL = 0;
// 字体大小常量 - 中
public static final int TEXT_MEDIUM = 1;
// 字体大小常量 - 大
public static final int TEXT_LARGE = 2;
// 字体大小常量 - 超大
public static final int TEXT_SUPER = 3;
// 默认字体大小
public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM;
/**
*
*/
public static class NoteBgResources {
// 编辑界面背景资源数组
private final static int [] BG_EDIT_RESOURCES = new int [] {
R.drawable.edit_yellow,
R.drawable.edit_blue,
@ -67,7 +48,6 @@ public class ResourceParser {
R.drawable.edit_red
};
// 编辑界面标题栏背景资源数组
private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] {
R.drawable.edit_title_yellow,
R.drawable.edit_title_blue,
@ -76,30 +56,15 @@ public class ResourceParser {
R.drawable.edit_title_red
};
/**
*
* @param id ID
* @return ID
*/
public static int getNoteBgResource(int id) {
return BG_EDIT_RESOURCES[id];
}
/**
*
* @param id ID
* @return ID
*/
public static int getNoteTitleBgResource(int id) {
return BG_EDIT_TITLE_RESOURCES[id];
}
}
/**
* ID
* @param context
* @return ID
*/
public static int getDefaultBgId(Context context) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) {
@ -109,11 +74,7 @@ public class ResourceParser {
}
}
/**
*
*/
public static class NoteItemBgResources {
// 列表项第一个元素的背景资源数组
private final static int [] BG_FIRST_RESOURCES = new int [] {
R.drawable.list_yellow_up,
R.drawable.list_blue_up,
@ -122,7 +83,6 @@ public class ResourceParser {
R.drawable.list_red_up
};
// 列表项中间元素的背景资源数组
private final static int [] BG_NORMAL_RESOURCES = new int [] {
R.drawable.list_yellow_middle,
R.drawable.list_blue_middle,
@ -131,7 +91,6 @@ public class ResourceParser {
R.drawable.list_red_middle
};
// 列表项最后一个元素的背景资源数组
private final static int [] BG_LAST_RESOURCES = new int [] {
R.drawable.list_yellow_down,
R.drawable.list_blue_down,
@ -140,7 +99,6 @@ public class ResourceParser {
R.drawable.list_red_down,
};
// 列表项单独元素的背景资源数组
private final static int [] BG_SINGLE_RESOURCES = new int [] {
R.drawable.list_yellow_single,
R.drawable.list_blue_single,
@ -149,56 +107,28 @@ public class ResourceParser {
R.drawable.list_red_single
};
/**
*
* @param id ID
* @return ID
*/
public static int getNoteBgFirstRes(int id) {
return BG_FIRST_RESOURCES[id];
}
/**
*
* @param id ID
* @return ID
*/
public static int getNoteBgLastRes(int id) {
return BG_LAST_RESOURCES[id];
}
/**
*
* @param id ID
* @return ID
*/
public static int getNoteBgSingleRes(int id) {
return BG_SINGLE_RESOURCES[id];
}
/**
*
* @param id ID
* @return ID
*/
public static int getNoteBgNormalRes(int id) {
return BG_NORMAL_RESOURCES[id];
}
/**
*
* @return ID
*/
public static int getFolderBgRes() {
return R.drawable.list_folder;
}
}
/**
*
*/
public static class WidgetBgResources {
// 2x尺寸小部件的背景资源数组
private final static int [] BG_2X_RESOURCES = new int [] {
R.drawable.widget_2x_yellow,
R.drawable.widget_2x_blue,
@ -207,16 +137,10 @@ public class ResourceParser {
R.drawable.widget_2x_red,
};
/**
* 2x
* @param id ID
* @return ID
*/
public static int getWidget2xBgResource(int id) {
return BG_2X_RESOURCES[id];
}
// 4x尺寸小部件的背景资源数组
private final static int [] BG_4X_RESOURCES = new int [] {
R.drawable.widget_4x_yellow,
R.drawable.widget_4x_blue,
@ -225,21 +149,12 @@ public class ResourceParser {
R.drawable.widget_4x_red
};
/**
* 4x
* @param id ID
* @return ID
*/
public static int getWidget4xBgResource(int id) {
return BG_4X_RESOURCES[id];
}
}
/**
*
*/
public static class TextAppearanceResources {
// 文本外观资源数组
private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] {
R.style.TextAppearanceNormal,
R.style.TextAppearanceMedium,
@ -247,11 +162,6 @@ public class ResourceParser {
R.style.TextAppearanceSuper
};
/**
*
* @param id ID
* @return ID
*/
public static int getTexAppearanceResource(int id) {
/**
* HACKME: Fix bug of store the resource id in shared preference.
@ -264,10 +174,6 @@ public class ResourceParser {
return TEXTAPPEARANCE_RESOURCES[id];
}
/**
*
* @return
*/
public static int getResourcesSize() {
return TEXTAPPEARANCE_RESOURCES.length;
}

@ -29,113 +29,59 @@ import android.content.DialogInterface.OnClickListener;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
/**
*
* DateTimePicker
* 1224
*/
public class DateTimePickerDialog extends AlertDialog implements OnClickListener {
// 当前选择的日期时间
private Calendar mDate = Calendar.getInstance();
// 是否使用24小时制显示
private boolean mIs24HourView;
// 日期时间设置监听器
private OnDateTimeSetListener mOnDateTimeSetListener;
// 日期时间选择器控件
private DateTimePicker mDateTimePicker;
/**
*
*/
public interface OnDateTimeSetListener {
/**
*
* @param dialog
* @param date
*/
void OnDateTimeSet(AlertDialog dialog, long date);
}
/**
* 使
* @param context
* @param date
*/
public DateTimePickerDialog(Context context, long date) {
super(context);
// 创建日期时间选择器控件
mDateTimePicker = new DateTimePicker(context);
// 设置对话框的内容视图为日期时间选择器
setView(mDateTimePicker);
// 设置日期时间变化监听器
mDateTimePicker.setOnDateTimeChangedListener(new OnDateTimeChangedListener() {
public void onDateTimeChanged(DateTimePicker view, int year, int month,
int dayOfMonth, int hourOfDay, int minute) {
// 更新当前选择的日期时间
mDate.set(Calendar.YEAR, year);
mDate.set(Calendar.MONTH, month);
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
mDate.set(Calendar.MINUTE, minute);
// 更新对话框标题为当前选择的日期时间
updateTitle(mDate.getTimeInMillis());
}
});
// 设置初始日期时间,忽略秒数
mDate.setTimeInMillis(date);
mDate.set(Calendar.SECOND, 0);
// 设置日期时间选择器的当前日期时间
mDateTimePicker.setCurrentDate(mDate.getTimeInMillis());
// 设置确定按钮
setButton(context.getString(R.string.datetime_dialog_ok), this);
// 设置取消按钮
setButton2(context.getString(R.string.datetime_dialog_cancel), (OnClickListener)null);
// 设置时间格式为系统默认格式
set24HourView(DateFormat.is24HourFormat(this.getContext()));
// 更新对话框标题
updateTitle(mDate.getTimeInMillis());
}
/**
* 使24
* @param is24HourView 使24
*/
public void set24HourView(boolean is24HourView) {
mIs24HourView = is24HourView;
}
/**
*
* @param callBack
*/
public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) {
mOnDateTimeSetListener = callBack;
}
/**
*
* @param date
*/
private void updateTitle(long date) {
// 设置日期时间格式为显示年、月、日、时、分
int flag =
int flag =
DateUtils.FORMAT_SHOW_YEAR |
DateUtils.FORMAT_SHOW_DATE |
DateUtils.FORMAT_SHOW_TIME;
// 设置时间格式为24小时制或12小时制
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
// 格式化日期时间并设置为对话框标题
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
}
/**
*
* @param arg0
* @param arg1
*/
public void onClick(DialogInterface arg0, int arg1) {
// 如果设置了监听器,则调用监听器的方法
if (mOnDateTimeSetListener != null) {
mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis());
}

@ -29,96 +29,49 @@ import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
/**
*
* CursorAdapter
*
*/
public class FoldersListAdapter extends CursorAdapter {
// 数据库查询的列投影
public static final String [] PROJECTION = {
NoteColumns.ID,
NoteColumns.SNIPPET
};
// ID列的索引
public static final int ID_COLUMN = 0;
// 文件夹名称列的索引
public static final int NAME_COLUMN = 1;
/**
*
* @param context
* @param c Cursor
*/
public FoldersListAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
}
/**
*
* @param context
* @param cursor Cursor
* @param parent
* @return
*/
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return new FolderListItem(context);
}
/**
*
* @param view
* @param context
* @param cursor Cursor
*/
@Override
public void bindView(View view, Context context, Cursor cursor) {
if (view instanceof FolderListItem) {
// 根文件夹显示特殊名称,其他文件夹显示实际名称
String folderName = (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context
.getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN);
((FolderListItem) view).bind(folderName);
}
}
/**
*
* @param context
* @param position
* @return
*/
public String getFolderName(Context context, int position) {
Cursor cursor = (Cursor) getItem(position);
// 根文件夹显示特殊名称,其他文件夹显示实际名称
return (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context
.getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN);
}
/**
*
*/
private class FolderListItem extends LinearLayout {
// 显示文件夹名称的TextView
private TextView mName;
/**
*
* @param context
*/
public FolderListItem(Context context) {
super(context);
// 加载文件夹列表项布局
inflate(context, R.layout.folder_list_item, this);
// 获取文件夹名称TextView
mName = (TextView) findViewById(R.id.tv_folder_name);
}
/**
*
* @param name
*/
public void bind(String name) {
mName.setText(name);
}

Loading…
Cancel
Save