|
|
|
@ -5,7 +5,7 @@
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
* <url id="d0s4nev37oq8u4isp1r0" type="url" status="parsed" title="Apache License, Version 2.0" wc="10467">http://www.apache.org/licenses/LICENSE-2.0</url>
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
@ -31,77 +31,86 @@ 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; // 复选框
|
|
|
|
|
|
|
|
|
|
public NotesListItem(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
inflate(context, R.layout.note_item, this);
|
|
|
|
|
mAlert = (ImageView) findViewById(R.id.iv_alert_icon);
|
|
|
|
|
mTitle = (TextView) findViewById(R.id.tv_title);
|
|
|
|
|
mTime = (TextView) findViewById(R.id.tv_time);
|
|
|
|
|
mCallName = (TextView) findViewById(R.id.tv_name);
|
|
|
|
|
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
|
|
|
|
|
inflate(context, R.layout.note_item, this); // 加载布局文件
|
|
|
|
|
mAlert = (ImageView) findViewById(R.id.iv_alert_icon); // 获取提醒图标
|
|
|
|
|
mTitle = (TextView) findViewById(R.id.tv_title); // 获取标题文本视图
|
|
|
|
|
mTime = (TextView) findViewById(R.id.tv_time); // 获取时间文本视图
|
|
|
|
|
mCallName = (TextView) findViewById(R.id.tv_name); // 获取通话名称文本视图
|
|
|
|
|
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox); // 获取复选框
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
} else {
|
|
|
|
|
mCheckBox.setVisibility(View.GONE);
|
|
|
|
|
mCheckBox.setVisibility(View.GONE); // 隐藏复选框
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mItemData = data;
|
|
|
|
|
mItemData = data; // 保存笔记项数据
|
|
|
|
|
// 处理通话记录文件夹
|
|
|
|
|
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
|
|
|
|
|
mCallName.setVisibility(View.GONE);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
|
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
|
|
|
|
|
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()));
|
|
|
|
|
mCallName.setVisibility(View.GONE); // 隐藏通话名称
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE); // 显示提醒图标
|
|
|
|
|
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); // 设置标题文本外观
|
|
|
|
|
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);
|
|
|
|
|
mAlert.setVisibility(View.GONE); // 隐藏提醒图标
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
mCallName.setVisibility(View.GONE);
|
|
|
|
|
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 处理其他类型的笔记或文件夹
|
|
|
|
|
else {
|
|
|
|
|
mCallName.setVisibility(View.GONE); // 隐藏通话名称
|
|
|
|
|
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); // 设置标题文本外观
|
|
|
|
|
// 如果是文件夹类型
|
|
|
|
|
if (data.getType() == Notes.TYPE_FOLDER) {
|
|
|
|
|
mTitle.setText(data.getSnippet()
|
|
|
|
|
+ context.getString(R.string.format_folder_files_count,
|
|
|
|
|
data.getNotesCount()));
|
|
|
|
|
mAlert.setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
|
|
|
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
|
|
|
|
|
mTitle.setText(data.getSnippet() + context.getString(R.string.format_folder_files_count, data.getNotesCount())); // 设置标题文本
|
|
|
|
|
mAlert.setVisibility(View.GONE); // 隐藏提醒图标
|
|
|
|
|
}
|
|
|
|
|
// 如果是笔记类型
|
|
|
|
|
else {
|
|
|
|
|
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet())); // 设置标题文本
|
|
|
|
|
// 如果有提醒,则显示提醒图标
|
|
|
|
|
if (data.hasAlert()) {
|
|
|
|
|
mAlert.setImageResource(R.drawable.clock);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
mAlert.setVisibility(View.GONE);
|
|
|
|
|
mAlert.setVisibility(View.GONE); // 隐藏提醒图标
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
|
|
|
|
|
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate())); // 设置时间文本
|
|
|
|
|
|
|
|
|
|
setBackground(data);
|
|
|
|
|
setBackground(data); // 设置背景
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setBackground(NoteItemData data) {
|
|
|
|
|
int id = data.getBgColorId();
|
|
|
|
|
int id = data.getBgColorId(); // 获取背景颜色 ID
|
|
|
|
|
// 如果是笔记类型
|
|
|
|
|
if (data.getType() == Notes.TYPE_NOTE) {
|
|
|
|
|
// 根据笔记的状态设置不同的背景资源
|
|
|
|
|
if (data.isSingle() || data.isOneFollowingFolder()) {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgSingleRes(id));
|
|
|
|
|
} else if (data.isLast()) {
|
|
|
|
@ -111,12 +120,14 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
} else {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
// 如果是文件夹类型
|
|
|
|
|
else {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getFolderBgRes());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NoteItemData getItemData() {
|
|
|
|
|
return mItemData;
|
|
|
|
|
return mItemData; // 返回笔记项数据
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|