1 package com.yuji.ec.utility;
5 import android.content.Context;
6 import android.database.sqlite.SQLiteDatabase;
8 import com.evernote.edam.notestore.NoteList;
9 import com.yuji.ec.common.CommonUtil;
10 import com.yuji.ec.common.Constant;
11 import com.yuji.ec.db.DatabaseHelper;
12 import com.yuji.ec.db.Note;
13 import com.yuji.ec.db.NoteDao;
14 import com.yuji.ec.utility.EvernoteUtil.Error;
16 public class NoteUpdator {
17 private static NoteUpdator instance = null;
18 private static Object obj = new Object();
20 public static NoteUpdator getInstance() {
21 if (instance == null) {
23 if (instance == null) {
24 instance = new NoteUpdator();
31 private NoteUpdator() {
35 public void update(Context context, int noteItemType, String guid) {
37 EvernoteUtil util = EvernoteUtil.getInstance();
38 //String username = PasswordUtil.getUsername(context);
39 //String password = PasswordUtil.getPassword(context);
40 //if (!CommonUtil.isNull(username) && !CommonUtil.isNull(password)) {
41 // util.setConfig(username, password);
46 List<NoteList> noteListList;
47 switch (noteItemType) {
48 case Constant.NOTE_ITEM_TYPE_NOTE_BOOK:
49 noteListList = util.getNoteListByNotebook(guid);
51 case Constant.NOTE_ITEM_TYPE_TAG:
52 noteListList = util.getNoteListByTag(guid);
55 noteListList = util.getNoteList();
59 if (util.getErrorCode() != Error.NONE) {
63 List<Note> list = util.getNoteContentList(noteListList);
69 DatabaseHelper helper = DatabaseHelper.getInstance();
70 SQLiteDatabase db = helper.getWritableDatabase();
71 NoteDao dao = (NoteDao) NoteDao.getInstance();
74 db.beginTransaction();
77 for (Note note : list) {
80 db.setTransactionSuccessful();
85 } catch (Exception e) {
86 Debug.d(this, null, e);