|
|
|
@ -30,17 +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; //✔框
|
|
|
|
|
|
|
|
|
|
//初始化
|
|
|
|
|
public NotesListItem(Context context) {
|
|
|
|
|
//调整调用父类构造函数的顺序
|
|
|
|
|
super(context);
|
|
|
|
|
inflate(context, R.layout.note_item, this);
|
|
|
|
|
//findViewById 查找现有试图
|
|
|
|
|
mAlert = (ImageView) findViewById(R.id.iv_alert_icon);
|
|
|
|
|
mTitle = (TextView) findViewById(R.id.tv_title);
|
|
|
|
|
mTime = (TextView) findViewById(R.id.tv_time);
|
|
|
|
@ -48,18 +52,23 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据data的属性对各个控件的属性的控制,主要是可见性Visibility,内容setText,格式setTextAppearance
|
|
|
|
|
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.VISIBLE); //设置为可见
|
|
|
|
|
mCheckBox.setChecked(checked); //打勾
|
|
|
|
|
} else {//否则被隐藏
|
|
|
|
|
mCheckBox.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据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()));
|
|
|
|
@ -70,7 +79,7 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem);
|
|
|
|
|
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
|
|
|
|
|
if (data.hasAlert()) {
|
|
|
|
|
mAlert.setImageResource(R.drawable.clock);
|
|
|
|
|
mAlert.setImageResource(R.drawable.clock);
|
|
|
|
|
mAlert.setVisibility(View.VISIBLE);
|
|
|
|
|
} else {
|
|
|
|
|
mAlert.setVisibility(View.GONE);
|
|
|
|
@ -94,24 +103,29 @@ public class NotesListItem extends LinearLayout {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//设置内容,获取相关时间,从data里编辑的日期中获取
|
|
|
|
|
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
|
|
|
|
|
|
|
|
|
|
setBackground(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//传入data设置背景
|
|
|
|
|
private void setBackground(NoteItemData data) {
|
|
|
|
|
int id = data.getBgColorId();
|
|
|
|
|
//如果是Notes.TYPE_NOTE
|
|
|
|
|
if (data.getType() == Notes.TYPE_NOTE) {
|
|
|
|
|
//如果是单个且只有一个文件夹
|
|
|
|
|
if (data.isSingle() || data.isOneFollowingFolder()) {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgSingleRes(id));
|
|
|
|
|
} else if (data.isLast()) {
|
|
|
|
|
} else if (data.isLast()) { //如果是最后一个数据
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgLastRes(id));
|
|
|
|
|
} else if (data.isFirst() || data.isMultiFollowingFolder()) {
|
|
|
|
|
} else if (data.isFirst() || data.isMultiFollowingFolder()) { //如果是一个数据且有多个子文件夹
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgFirstRes(id));
|
|
|
|
|
} else {
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//若非note则获取文件夹背景来源
|
|
|
|
|
setBackgroundResource(NoteItemBgResources.getFolderBgRes());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|