use of com.litingzhe.justandroid.netdb.db.model.Note in project JustAndroid by chinaltz.
the class MvpNoteAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_list_note, null);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Note note = data.get(position);
viewHolder.contentText.setText(note.getNoteContent());
viewHolder.titleText.setText(note.getNoteTitle());
viewHolder.dateText.setText(AbDateUtil.getStringByFormat(note.getCreatDate(), AbDateUtil.dateFormatYMDHM));
return convertView;
}
use of com.litingzhe.justandroid.netdb.db.model.Note in project JustAndroid by chinaltz.
the class MvvmGreenDaoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note);
ButterKnife.bind(this);
noteDao = MyApplication.getInstance().getDaoSession().getNoteDao();
navBack.setVisibility(View.VISIBLE);
navTitle.setText("简单笔记本");
navRight.setVisibility(View.VISIBLE);
navRightText.setText("添加");
noteList = new ArrayList<>();
adapter = new MvvmNoteAdapter(mContext, noteList);
navBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
navRight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View view = LayoutInflater.from(mContext).inflate(R.layout.view_add_note, null);
final EditText titleText = (EditText) view.findViewById(R.id.titleText);
final EditText contentText = (EditText) view.findViewById(R.id.contentText);
Button commitButton = (Button) view.findViewById(R.id.commitButton);
AbDialogUtil.showDialog(view, Gravity.CENTER);
commitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = titleText.getText().toString();
String content = contentText.getText().toString();
if (AbStrUtil.isEmpty(title)) {
AbDialogUtil.removeDialog(mContext);
return;
}
if (AbStrUtil.isEmpty(content)) {
AbDialogUtil.removeDialog(mContext);
return;
}
Note note = new Note();
note.setCreatDate(new Date());
note.setNoteTitle(title);
note.setFavFlag(0);
note.setNoteContent(content);
noteDao.insert(note);
AbDialogUtil.removeDialog(mContext);
refreshNoteList();
}
});
}
});
listView.setAdapter(adapter);
refreshNoteList();
//1.创建侧滑按钮菜单
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "open" item
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
// set item width
deleteItem.setWidth(150);
// set a icon
deleteItem.setIcon(R.drawable.ic_delete);
// add to menu
menu.addMenuItem(deleteItem);
}
};
// 设置 MenuCreator
listView.setMenuCreator(creator);
// 2. 设置侧滑按钮 监听事件
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch(index) {
case 0:
// delete
noteDao.delete(noteList.get(position));
refreshNoteList();
break;
}
return false;
}
});
}
use of com.litingzhe.justandroid.netdb.db.model.Note in project JustAndroid by chinaltz.
the class MvpGreenDaoActivity method showAddNoteDialog.
@Override
public void showAddNoteDialog() {
View view = LayoutInflater.from(mContext).inflate(R.layout.view_add_note, null);
final EditText titleText = (EditText) view.findViewById(R.id.titleText);
final EditText contentText = (EditText) view.findViewById(R.id.contentText);
Button commitButton = (Button) view.findViewById(R.id.commitButton);
AbDialogUtil.showDialog(view, Gravity.CENTER);
commitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = titleText.getText().toString();
String content = contentText.getText().toString();
if (AbStrUtil.isEmpty(title)) {
// disMissDialog();
showMsg("请输入记事本标题");
return;
}
if (AbStrUtil.isEmpty(content)) {
// disMissDialog();
showMsg("请输入记事本内容");
return;
}
Note note = new Note();
note.setCreatDate(new Date());
note.setNoteTitle(title);
note.setFavFlag(0);
note.setNoteContent(content);
presenter.addNote(note);
}
});
}
use of com.litingzhe.justandroid.netdb.db.model.Note in project JustAndroid by chinaltz.
the class GreenDaoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note);
ButterKnife.bind(this);
noteDao = MyApplication.getInstance().getDaoSession().getNoteDao();
navBack.setVisibility(View.VISIBLE);
navTitle.setText("简单笔记本");
navRight.setVisibility(View.VISIBLE);
navRightText.setText("添加");
noteList = new ArrayList<>();
adapter = new NoteAdapter(mContext, noteList);
navRight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
View view = LayoutInflater.from(mContext).inflate(R.layout.view_add_note, null);
final EditText titleText = (EditText) view.findViewById(R.id.titleText);
final EditText contentText = (EditText) view.findViewById(R.id.contentText);
Button commitButton = (Button) view.findViewById(R.id.commitButton);
AbDialogUtil.showDialog(view, Gravity.CENTER);
commitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String title = titleText.getText().toString();
String content = contentText.getText().toString();
if (AbStrUtil.isEmpty(title)) {
AbDialogUtil.removeDialog(mContext);
return;
}
if (AbStrUtil.isEmpty(content)) {
AbDialogUtil.removeDialog(mContext);
return;
}
Note note = new Note();
note.setCreatDate(new Date());
note.setNoteTitle(title);
note.setFavFlag(0);
note.setNoteContent(content);
noteDao.insert(note);
AbDialogUtil.removeDialog(mContext);
refreshNoteList();
}
});
}
});
listView.setAdapter(adapter);
refreshNoteList();
//1.创建侧滑按钮菜单
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
// create "open" item
// create "delete" item
SwipeMenuItem deleteItem = new SwipeMenuItem(getApplicationContext());
// set item background
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
// set item width
deleteItem.setWidth(150);
// set a icon
deleteItem.setIcon(R.drawable.ic_delete);
// add to menu
menu.addMenuItem(deleteItem);
}
};
// 设置 MenuCreator
listView.setMenuCreator(creator);
// 2. 设置侧滑按钮 监听事件
listView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch(index) {
case 0:
// delete
noteDao.insert(noteList.get(position));
refreshNoteList();
break;
}
return false;
}
});
}
use of com.litingzhe.justandroid.netdb.db.model.Note in project JustAndroid by chinaltz.
the class NoteAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_list_note, null);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Note note = data.get(position);
viewHolder.contentText.setText(note.getNoteContent());
viewHolder.titleText.setText(note.getNoteTitle());
viewHolder.dateText.setText(AbDateUtil.getStringByFormat(note.getCreatDate(), AbDateUtil.dateFormatYMDHM));
return convertView;
}
Aggregations