|
|
|
@ -30,14 +30,21 @@ import net.micode.notes.tool.DataUtils;
|
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteItemBgResources;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 便签列表项视图,用于在列表中展示便签或文件夹信息
|
|
|
|
|
*/
|
|
|
|
|
public class NotesListItem extends LinearLayout {
|
|
|
|
|
private ImageView mAlert;
|
|
|
|
|
private TextView mTitle;
|
|
|
|
|
private TextView mTime;
|
|
|
|
|
private TextView mCallName;
|
|
|
|
|
private NoteItemData mItemData;
|
|
|
|
|
private CheckBox mCheckBox;
|
|
|
|
|
private ImageView mAlert; // 提醒图标,显示闹钟或通话记录图标
|
|
|
|
|
private TextView mTitle; // 标题文本,显示便签内容或文件夹名称
|
|
|
|
|
private TextView mTime; // 时间文本,显示最后修改时间
|
|
|
|
|
private TextView mCallName; // 通话记录名称,用于显示通话联系人
|
|
|
|
|
private NoteItemData mItemData; // 便签数据对象
|
|
|
|
|
private CheckBox mCheckBox; // 复选框,用于多选操作
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造函数,初始化视图组件
|
|
|
|
|
* @param context 上下文对象
|
|
|
|
|
*/
|
|
|
|
|
public NotesListItem(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
inflate(context, R.layout.note_item, this);
|
|
|
|
@ -48,7 +55,15 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 绑定数据到视图
|
|
|
|
|
* @param context 上下文对象
|
|
|
|
|
* @param data 便签数据
|
|
|
|
|
* @param choiceMode 是否为选择模式
|
|
|
|
|
* @param checked 是否选中
|
|
|
|
|
*/
|
|
|
|
|
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
|
|
|
|
|
// 根据选择模式和便签类型决定是否显示复选框
|
|
|
|
|
if (choiceMode && data.getType() == Notes.TYPE_NOTE) {
|
|
|
|
|
mCheckBox.setVisibility(View.VISIBLE);
|
|
|
|
|
mCheckBox.setChecked(checked);
|
|
|
|
@ -57,6 +72,7 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mItemData = data;
|
|
|
|
|
// 处理通话记录文件夹
|
|
|
|
|
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
mCallName.setVisibility(View.GONE);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
@ -64,17 +80,20 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
mTitle.setText(context.getString(R.string.call_record_folder_name)
|
|
|
|
|
+ context.getString(R.string.format_folder_files_count, data.getNotesCount()));
|
|
|
|
|
mAlert.setImageResource(R.drawable.call_record);
|
|
|
|
|
// 处理通话记录子项
|
|
|
|
|
} else if (data.getParentId() == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
mCallName.setVisibility(View.VISIBLE);
|
|
|
|
|
mCallName.setText(data.getCallName());
|
|
|
|
|
mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem);
|
|
|
|
|
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
|
|
|
|
|
// 显示提醒图标
|
|
|
|
|
if (data.hasAlert()) {
|
|
|
|
|
mAlert.setImageResource(R.drawable.clock);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
mAlert.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
// 处理普通便签和文件夹
|
|
|
|
|
} else {
|
|
|
|
|
mCallName.setVisibility(View.GONE);
|
|
|
|
|
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
|
|
|
|
@ -86,6 +105,7 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
mAlert.setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
|
|
|
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
|
|
|
|
|
// 显示提醒图标
|
|
|
|
|
if (data.hasAlert()) {
|
|
|
|
|
mAlert.setImageResource(R.drawable.clock);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
@ -94,14 +114,21 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设置相对时间显示,如"1小时前"
|
|
|
|
|
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
|
|
|
|
|
|
|
|
|
|
// 设置背景样式
|
|
|
|
|
setBackground(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据便签类型和位置设置背景样式
|
|
|
|
|
* @param data 便签数据
|
|
|
|
|
*/
|
|
|
|
|
private void setBackground(NoteItemData data) {
|
|
|
|
|
int id = data.getBgColorId();
|
|
|
|
|
if (data.getType() == Notes.TYPE_NOTE) {
|
|
|
|
|
// 根据便签在列表中的位置设置不同的背景资源
|
|
|
|
|
if (data.isSingle() || data.isOneFollowingFolder()) {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgSingleRes(id));
|
|
|
|
|
} else if (data.isLast()) {
|
|
|
|
@ -112,11 +139,16 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 文件夹使用特定背景资源
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getFolderBgRes());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取便签数据对象
|
|
|
|
|
* @return 便签数据
|
|
|
|
|
*/
|
|
|
|
|
public NoteItemData getItemData() {
|
|
|
|
|
return mItemData;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|