use of com.litingzhe.justandroid.designMode.mvp.presenter.NotePresenter in project JustAndroid by chinaltz.
the class MvpGreenDaoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_note);
ButterKnife.bind(this);
navBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
presenter = new NotePresenter(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) {
showAddNoteDialog();
}
});
refreshList();
listView.setAdapter(adapter);
//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
presenter.deleteNote(noteList.get(position));
break;
}
return false;
}
});
}
Aggregations