1 18 19 package sync4j.syncclient.blackberry.listener; 20 21 import javax.microedition.pim.Contact; 22 import javax.microedition.pim.Event; 23 import javax.microedition.pim.PIMItem; 24 import net.rim.blackberry.api.pdap.PIMListListener; 25 26 import sync4j.syncclient.sps.EventDataStore; 27 28 36 public class Sync4jEventListener implements PIMListListener{ 37 38 public static final char RECORD_STATE_DELETED = 'D' ; 39 40 private EventDataStore eventDataStore ; 42 43 50 public Sync4jEventListener() { 51 this.eventDataStore = new EventDataStore(); 52 } 53 54 59 public void itemAdded(PIMItem item) { 60 storeRecord(item, EventDataStore.RECORD_STATE_NEW); 61 } 62 63 69 public void itemUpdated(PIMItem oldItem, PIMItem newItem) { 70 storeRecord(newItem, EventDataStore.RECORD_STATE_UPDATED); 71 } 72 73 78 public void itemRemoved(PIMItem item) { 79 80 86 } 87 88 96 private void storeRecord(PIMItem item, char state) { 97 98 Event event = (Event) item ; 99 String uid = null ; 100 101 try { 102 103 uid = event.getString(Event.UID, 0); 104 105 eventDataStore.addRecord(uid, state, event); 106 107 } catch(Exception e){ 108 e.printStackTrace(); 109 } 110 111 } 112 } 113 | Popular Tags |