ããã§ã¯ããã¡ã€ã³ã¢ãã«ãã·ã³ã°ã«ãã³ããªããžããªãã¶ã€ã³ãã¿ãŒã³ãè¡åé§åéçºïŒBDDïŒã¢ãããŒããããã³ããã°ã©ã ã§ã®ãããã®äœ¿çšæ¹æ³ã«ã€ããŠèª¬æããŸãã
ãã¡ã€ã³ã¢ãã«ãã³ãã¬ãŒãã¯ãéçºããµããžã§ã¯ããšãªã¢ããè¡ãããå Žåã«äœ¿çšãããŸãããã®ãããªå Žåãæ確ãªãµããžã§ã¯ããšãªã¢ãããããã®çšèªã¯åã«ãã€ãã§å ·äœåãããŸãã
ããšãã°ãç§ã®ããã°ã©ã ã§ã¯ããµããžã§ã¯ãé åã¯è€æ°ã®ã¢ã©ãŒã ã®åœ¢åŒã§èšå®ãããã¹ã±ãžã¥ãŒã«ããŒã¿ã§æ§æãããŠããŸããã¢ã©ãŒã ã®å Žåãææ¥ãšæå»ãããã³ãã¢ã©ãŒã ããªã³ããšããèšå·ãèšå®ã§ããŸãã ããšãã°ã次ã«æ©èœããã¢ã©ãŒã ãšãããªã¬ãŒãããæ¥æãååŸããããã®ã¢ã«ãŽãªãºã ãããã€ããããŸãã ã¢ã©ãŒã ã¯ã¹ããŒãºã§ãããããã¹ããŒãºãã¿ã³ã䜿çšã§ããªããªã£ãå Žåã1ã€ã®ã¢ã©ãŒã ã«ã¯ç°ãªãã¢ã¯ã·ã§ã³ã®ããªã¬ãŒãããã€ãããããšãããããŸããæåã®ã¢ã©ãŒã ãã¹ããŒãºãæåŸã®ã¹ããŒãºã§ãã ãããã£ãŠãæãè¿ã絶察æéãšåäœãæããããã®ã¢ã«ãŽãªãºã ããããŸãã
æ°ããç®èŠãŸãæèšãäœæããæ¢åã®ãã®ãç·šé/åé€ããããã®ã¢ã«ãŽãªãºã ããããŸãã
ã€ãŸããç§ã®ãµããžã§ã¯ããšãªã¢ã«ã¯ããµããžã§ã¯ããšãªã¢ã®ããžãã¯ãå®è£ ããããã€ãã®ã¢ã©ãŒã ãšã¢ã«ãŽãªãºã ã®åœ¢åŒã®ããŒã¿ããããŸãã
ãªããã®ãã¶ã€ã³ãã¿ãŒã³ã䜿çšããããšã«ããã®ã§ããããã ãŸãã¯ãã¢ã©ãŒã ãäœæ/ç·šéããŠããŒã¿ããŒã¹ã«ä¿åããå¥ã®ã¯ã©ã¹ãäœæããæãè¿ãã¢ã©ãŒã ãèšç®ããã¢ã«ãŽãªãºã ãå¥ã®ã¯ã©ã¹ã§äœæããããšãã§ããŸãã
æåã«ããµããžã§ã¯ãé åã«é¢ããŠã1ã€ã®ã¢ã©ãŒã ã®ãªã¹ããæäœããããã«æ°ããã¢ã©ãŒã ãè¿œå ããŠãã©ã®ã¢ã©ãŒã æèšã次ã«æ¥ãããå°ããŸãã ã€ãŸããããŒã¿ãšã¢ã«ãŽãªãºã ãã«ãã»ã«åãããšããç¹ã§äŸ¿å©ã«èŠããŸãã ãã®ãããªã¢ãã«ã¯ã人éã®ç¥èŠã«ãšã£ãŠãã䟿å©ã§ãã
次ã«ããã®å Žåãã¢ãã«ããã¹ããããšãã«ãéåžžã®ãŠãŒã¶ãŒã®åäœããã¹ãã§ããŸãã ããšãã°ãã¢ã©ãŒã ãäœæããã¹ã±ãžã¥ãŒã«ãèšå®ãã次ã«ã¢ãã«ãæ£ãã衚瀺ãããããšã確èªããŠãããæ°ããã¢ã©ãŒã ãè¿œå ããå€ãã¢ã©ãŒã ããªãã«ããŠãä»åã¯æ¬¡ã®ã¢ã©ãŒã ãæ£ããããšã確èªããŸãã
ãã®ã¢ãããŒãã¯ãè¡åé§åéçºãšåŒã°ããŸãã ãã®å©ç¹ã¯ããµããžã§ã¯ãé åã®èŠ³ç¹ããã¢ãã«ããã¹ãã§ããããšã§ããã€ãŸãããŠããããã¹ãã§ã¯ãŠãŒã¶ãŒã®éåžžã®åäœãæš¡å£ããŸãã ããã¯åäœãã¹ãã¡ã«ããºã ãä»ããŠå®è£ ãããŠãããããåãªãªãŒã¹ã®åã«ãããã®ãã¹ããå®è¡ããããã°ã©ã ããã°ã©ã ãåºæ¬çãªãŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãæ£åžžã«å®è¡ã§ããããšã確èªã§ããŸãã
ã¢ã©ãŒã ã®ç·šé/ä¿åã«åå¥ã®ã¯ã©ã¹ã䜿çšããæãè¿ãã¢ã©ãŒã ãèšç®ããããã«åå¥ã®ã¯ã©ã¹ã䜿çšããå Žåãããããåå¥ã«ãã¹ãããããšã¯ç¢ºãã§ãããäžç·ã«ãã§ãã¯ããããšã¯ã§ããããŠãŒã¶ãŒã®åºæ¬ã¢ã¯ã·ã§ã³ããã§ãã¯ããããšã¯ã§ããŸããã§ããã
ã¢ãã«ãšãã®ã€ã³ã¿ãŒãã§ãŒã¹
ãµããžã§ã¯ãé åãå®è£ ãããšããã¢ã©ãŒã ãæ ŒçŽãããããã®ã¢ã«ãŽãªãºã ãå®è£ ããAlarmListModelã¯ã©ã¹ã®åœ¢åŒã§ã¢ãã«ãå®è£ ããŸããã ã¢ãã«ã¯ããŒã¿ããŒã¹ãžã®ä¿åã«ã€ããŠäœãç¥ããªãããšã匷調ããããšæããŸãã ã¢ãã«ã®ä¿åã¯ãªããžããªã«ãã£ãŠè¡ãããŸãããããã«ã€ããŠã¯ä»¥äžã§èª¬æããŸãã
ã¢ãã«ã«ã¯ã¢ã©ãŒã ã®ãªã¹ããããã次ã®ã¢ã©ãŒã ã®èšç®æãŸãã¯ç·šéæã«äœ¿çšãããŸãã ã€ãŸããã¢ãã«ã¯ããŒã¿ãä¿åããã¢ã«ãŽãªãºã ãå®è£ ããŸãã åœç¶ããããã®ã¢ã«ãŽãªãºã ãã¢ã©ãŒã ã¯ã©ã¹ã«å®è£ ããããšã¯ã§ããŸããã次åã«èšç®ãã人ã¯å«ãŸãããã¹ãŠã®ã¢ã©ãŒã ã«ã€ããŠç¥ã£ãŠããå¿ èŠããããã¢ã©ãŒã ãªããžã§ã¯ãã¯èªåèªèº«ã«ã€ããŠããç¥ã£ãŠããªãããã§ãã ãããã£ãŠãç§ã®ç®èŠãŸãæèšã¯ãããŒã¿ãåããã¢ã«ãŽãªãºã ã®ãªãåçŽãªæ§é ã§ãã
ã¢ãã«ã¯2ã€ã®ã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããŸãã
IAlarmListModel-ãµããžã§ã¯ãé åã«é¢é£ããã¡ãœãããå®è£ ããŸããããšãã°ãæ°ããç®èŠãŸãæèšãäœæãã次ã®æäœã®æå»ãèŠã€ããŸãã
IListModelData-ããŒã¿ããŒã¹ã«ã¢ãã«ãä¿åããããããŒã¿ããŒã¹ããèªã¿èŸŒãã ãããããã«ãªããžããªã䜿çšããã€ã³ã¿ãŒãã§ã€ã¹ã
ãªããžããªå šäœããããŒã¿ããŒã¹ãããã¹ãŠã®ããŒã¿ãèªã¿åãããã¹ãŠã®ã¢ã©ãŒã ã®ã¹ã±ãžã¥ãŒã«ãèªã¿åãããšã«æ³šæããŠãã ããã ããã¯ãããããã®ããŒã¿ããŒã¹ã«ç»ãã¢ã©ãŒã ãããã»ã©å€ããªããšããäºå®ãšã次ã®ã¢ã©ãŒã ãèšç®ããããã«å«ãŸãããã¹ãŠã®ã¢ã©ãŒã ãå¿ èŠã§ããããªã¹ãã«è¡šç€ºããããã«äžè¬çã«ãã¹ãŠã®ã¢ã©ãŒã ãå¿ èŠã§ãããšããäºå®ã«ãããã®ã§ãã
ã¢ãã«ãšã€ã³ã¿ãŒãã§ã€ã¹ã®äž»ãªãœãŒã¹ã¯æ¬¡ã®ãšããã§ãã
public interface IAlarmListModel { IDisplayAlarm getNextDisplayAlarm(Date curTime); IDisplayAlarm createAlarm(); void updateAlarm(IDisplayAlarm iDisplayAlarm); void addAlarm(IDisplayAlarm iDisplayAlarm); void deleteAlarm(IDisplayAlarm item); void takeAlarmForEdit(int alarmID); IDisplayAlarm getEditingAlarm(); void saveEditingAlarm(boolean stayEditing); }
takeAlarmForEditïŒïŒããã³saveEditingAlarmïŒïŒã¡ãœããã¯ãç·šéã®ããã«ã¢ã©ãŒã ãè€è£œãããŠãŒã¶ãŒãããã£ã³ã»ã«ããã¯ãªãã¯ããå Žåã«è¡ã£ãå€æŽãç Žæ£ã§ããããã«ããããã«å¿ èŠã§ãã ãããã®ã¡ãœããã¯ãããŒã¿ããŒã¹ã«ã¯äœãä¿åãããã¢ã©ãŒã ã®å éšãªã¹ãã«ã®ã¿ä¿åããŸãã
public interface IListModelData<T> { ArrayList<T> getItemList(); ArrayList<T> getDeletedItemList(); }
ãã®ã€ã³ã¿ãŒãã§ã€ã¹ã¯ããªããžããªã䜿çšããŠã¢ãã«å ã®å éšã¢ã©ãŒã ãªã¹ãã«ã¢ã¯ã»ã¹ããŸãã ã芧ã®ãšããããªã¢ãŒãã¢ã©ãŒã ã®ãªã¹ãããããŸãã ããã«ã¯ããŠãŒã¶ãŒãåé€ããããšã決å®ããã¢ã©ãŒã ãå«ãŸãããªããžããªã¯ãã®ãªã¹ããã¹ãã£ã³ããããŒã¿ããŒã¹ããã¢ã©ãŒã ãåé€ããŸãã
public class AlarmListModel implements IAlarmListModel, IListModelData<AlarmItem> { private ArrayList<AlarmItem> alarmArray = new ArrayList<AlarmItem>(); private ArrayList<AlarmItem> alarmArrayDeleted = new ArrayList<AlarmItem>(); @Override public synchronized IDisplayAlarm getNextDisplayAlarm(Date curTime) { // , . } @Override public synchronized AlarmItem createAlarm() { AlarmItem alarm = new AlarmItem(); alarm.setId(0); // , , // ID alarm.setState(EntityState.ADDED); alarm.setName("New alarm");// alarm.setIssue(8, 0, false);//8 alarm.setEnable(true);// // // false , alarm.setDay(Calendar.MONDAY, true, false); alarm.setDay(Calendar.TUESDAY, true, false); alarm.setDay(Calendar.WEDNESDAY,true, false); alarm.setDay(Calendar.THURSDAY, true, false); alarm.setDay(Calendar.FRIDAY, true, false); alarm.setDay(Calendar.SATURDAY, false, false); alarm.setDay(Calendar.SUNDAY, false, false); return alarm; } @Override public synchronized void addAlarm(IDisplayAlarm item) { AlarmItem alarm = (AlarmItem)item; if(item.getId() > 0) { ex = new Exception(" "); } alarm.setState(EntityState.ADDED); alarmArray.add(alarm); } @Override public synchronized void updateAlarm(IDisplayAlarm item) { AlarmItem alarm = (AlarmItem)item; alarmArray.set(getPositionByID(item.getId()), alarm); } @Override public synchronized void deleteAlarm(IDisplayAlarm item) { AlarmItem alarm = (AlarmItem)item; alarmArray.remove(alarm); alarm.setState(EntityState.DELETED); alarmArrayDeleted.add(alarm); } public synchronized void takeAlarmForEdit(int alarmID) { if(alarmID > 0) editAlarm = ((AlarmItem)getDisplayAlarmByID(alarmID)).clone(); else editAlarm = createAlarm(); } @Override public synchronized AlarmItem getEditingAlarm() { return editAlarm; } @Override public synchronized void saveEditingAlarm(boolean stayEditing) { if(editAlarm == null)return; if(editAlarm.getId() > 0) updateAlarm(editAlarm); else addAlarm(editAlarm); if(!stayEditing)editAlarm = null; } @Override public synchronized ArrayList<AlarmItem> getItemList() { return alarmArray; } @Override public synchronized ArrayList<AlarmItem> getDeletedItemList() { return alarmArrayDeleted; } }
ããã§ã¯ãã¢ãã«ã®äžèº«ãèŠãŠã¿ãŸãããã ãªããžããªã«é¢ããã»ã¯ã·ã§ã³ã§ãã¹ãŠã®ã¡ãœãããåæèªã¿åããšããŠããŒã¯ãããŠããçç±ã
createAlarmïŒïŒã¡ãœããã䜿çšããã«ã¯ãã¢ãã«ãç®èŠãŸãæèšãã¡ã¯ããªã«ããå¿ èŠããããŸãã ãã¡ã¯ããªã¯ãäœæããããªããžã§ã¯ããã¢ã©ãŒã ã®å éšãªã¹ãã«è¿œå ããªãããšã«æ³šæããŠãã ããaddAlarmïŒïŒã¡ãœããããããŸã
ã¢ã©ãŒã ã®å éšãªã¹ããæäœããã«ã¯ãaddAlarmïŒïŒãupdateAlarmïŒïŒãdeleteAlarmïŒïŒã¡ãœãããå¿ èŠã§ãã æ¢ã«ãæ°ä»ãã®ããã«ãAlarmItemã¯ã©ã¹ã«ã¯ç¶æ ãç£èŠããããã®ã¡ãœãããããããããã®ç¶æ ã¯ããŒã¿ããŒã¹ã«é¢é£ããã¬ã³ãŒãã®ç¶æ ã瀺ããŸãã
public enum EntityState { ADDED, NOT_CHANGED, CHANGED, DELETED }
ããã¯ãORMãšã³ãžã³ã§äœ¿çšãããæšæºçãªææ³ã§ãããããããŒã¿ããŒã¹ãšåæãããšãã«ãããŒã¿ããŒã¹ãžã®åŒã³åºãã®æ°ãæžãããå€æŽãããã¬ã³ãŒãã®ã¿ãå€æŽããŸãã
ãç解ã®ãšããããã¹ãŠã®ã»ãã¿ãŒã®AlarmItemã¯ã©ã¹ã¯ãã¬ã³ãŒããå€æŽãããã¹ããŒã¿ã¹ãèšå®ããŸãã ãªããžããªã¯ãããã®ç¶æ ãåæããŠãããŒã¿ããŒã¹ã§æŽæ°ããå¿ èŠããããã®ãšããã§ãªããã®ã決å®ããŸãã
addAlarmã¡ãœããã§ã¯ã1ã€ã®ããªãã¯ã䜿çšããŠããŸãã ééã£ãç®èŠãŸãæèšãã³ã¬ã¯ã·ã§ã³ã«è¿œå ããããšãã«äŸå€ãçºçããå ŽåãäŸå€ãã¹ããŒããŸãããããã®äŸå€ããã£ãŒã«ãã«éãã«ä¿åããŸãã
ex = new Exception(" ");
ãã®ãã£ãŒã«ãã¯ç§ã®ãã¹ãã§ãã§ãã¯ãããŠããŸãã ãã¹ããå®äºãããšããã®ãã£ãŒã«ãã¯ãã«ã«ãªããŸããããã§ãªãå Žåããã¹ãã¯å€±æããŸãã ãã¡ãããAssertã䜿çšããããäŸå€ãå®å šã«ã¹ããŒã§ããŸãããäŸå€ãã¹ããŒã§ããªãå ŽåããããŸãã ããšãã°ãã¯ã©ã¹ãã€ã³ã¿ãŒãã§ã€ã¹ãå®è£ ããã¡ãœããã§äŸå€ãçºçããã€ã³ã¿ãŒãã§ã€ã¹ã§ãã®ã¡ãœããããäŸå€ãã¹ããŒã§ããªãå Žåã ãã®äŸå€ããã£ããããããã«ããã¹ãããã¯ã©ã¹ã®ãã£ãŒã«ãã«å ¥ããŠããã¹ãã®æåŸã«ãã§ãã¯ããŸãã
ãã®åé¡ã«ã¯ãã£ãšãšã¬ã¬ã³ããªè§£æ±ºçããããšæããŸããããŸã èŠã€ãããŸããã
ã¡ãœããtakeAlarmForEditïŒïŒãgetEditingAlarmïŒïŒãsaveEditingAlarmïŒïŒã¯ãäž»ã«ç®èŠãŸãæèšã®ç·šéãã©ãŒã ã«å¿ èŠã§ãã åè¿°ããããã«ãã¢ã©ãŒã ã®ã¯ããŒã³ãäœæããŠå€æŽããå¿ èŠã«å¿ããŠå€æŽãç Žæ£ããããã«å¿ èŠã§ãã
ãªããžããªã«äŒã
ãªããžããªã«ã¯ãã¢ãã«ã®ä¿åãšèªã¿åãã®2ã€ã®ã¡ãœãããããããŸããã
public interface IAlarmRepository { public abstract void load(); public abstract void save(); }
ã芧ã®ãšãããã¢ãã«ã«ã€ããŠã¯èšåãããŠããŸããã ç§ã®ã¢ãã«ã¯ã·ã³ã°ã«ãã³ãã³ãã¬ãŒããšããŠå®è£ ãããŸããã€ãŸããããã°ã©ã å šäœã§ã¢ãã«ã®ã€ã³ã¹ã¿ã³ã¹ã¯1ã€ã ãã§ãããããã°ã©ã ã®äžéšïŒUIãªã©ïŒãã¢ãã«å ã®äœããå€æŽããä»ã®éšåïŒãµãŒããŒããªããžããªãªã©ïŒãåãã€ã³ã¹ã¿ã³ã¹ããããŒã¿ãèªã¿åãå Žåã¢ãã«ã¯ããã«ææ°ã®å€æŽãåãåããŸãã ã¢ããªã±ãŒã·ã§ã³ã®ããŒãéã§æ¢åã®ãªããžã§ã¯ãã®ã¿ã転éããå¿ èŠãããå Žåã«éåžžã«äŸ¿å©ã§ãã
ã·ã³ã°ã«ãã³ãã³ãã¬ãŒãã«ã¯å€ãã®æ¬ ç¹ããããŸãããã®ãããã¢ãããåãããã¢ã³ããã¿ãŒã³ãšåŒã°ããŠããŸãã éåžžãSingletonã¯éçã¯ã©ã¹ãä»ããŠå®è£ ãããããããã¹ãã§æš¡å£ã§ããªããšããäºå®ãšãäžéšã®ã¯ã©ã¹ãSingletonã䜿çšããå Žåãã¯ã©ã¹èªäœã®å®£èšããã¯èŠããªããšããäºå®ã«ã€ãªãããŸãã
ãŸããã·ã³ã°ã«ãã³ãããç¶æ ããå¥ã®ç¶æ ã«è»¢éããã®ã«2ã€ã®åŒã³åºããå¿ èŠãªå Žåãã·ã³ã°ã«ãã³ãåžžã«æ£ããç¶æ ã«ããããšã確èªããå¿ èŠããããšããåé¡ããããŸããééã£ãç¶æ ã§ã誀ã£ãçµæã«ã€ãªããå¯èœæ§ããããŸãã
ããã§ããã®å Žåã¯ã¢ãã«ãã¡ã¯ããªãŒã§ããRoboGuiceã䜿çšããŠãããšããäºå®ã«ãããéçã¯ã©ã¹ã®åé¡ã解決ããŸããã RoboGuiceã䜿çšãããšãã¯ã©ã¹ãã·ã³ã°ã«ãã³ã䜿çšããŠããããšã瀺ãããšãã§ããRoboGuiceã䜿çšããŠããã¹ãã§ã·ã³ã°ã«ãã³ãã·ãã¥ã¬ãŒã·ã§ã³ã«çœ®ãæããããšãã§ããŸãã
æ£ããç¶æ ã®åé¡ã¯ãã¢ãã«ã«å¯Ÿãããã¹ãŠã®å€æŽãã¡ãœãããžã®1åã®åŒã³åºãã§è¡ããããã¹ãŠã®ã¡ãœãããåæãšããŠããŒã¯ããããããåæã«ã¢ãã«ãžã®2ã€ã®åŒã³åºããè¡ãããªããšããäºå®ã«ãã£ãŠè§£æ±ºãããŸãã
ãã®ãããSingletonã¯éåžžã«äŸ¿å©ã§ã:)ã ç§ã®ã¢ãã«ã¯ããŒã¿ããŒã¹ããäžåºŠããŒãããããããããã°ã©ã ã®å®è¡äžã¯ããã©ãŒã ãŸãã¯ãµãŒãã¹ã§ãã£ãŠããåã¢ã¯ãã£ããã£ã§ã®ã¢ãã«ã®ããŒãã«ãªãœãŒã¹ãè²»ããå¿ èŠã¯ãããŸããã ããã¢ã¯ãã£ããã£ããå¥ã®ã¢ã¯ãã£ããã£ã«ããŒã¿ã転éããæ¹æ³ã«ã€ããŠèããªãã§ãã ããã ããšãã°ãç·šéã¢ã¯ãã£ããã£ã§ã¯ãã¢ãã«ã§å¿ èŠãªã¢ã©ãŒã ãèŠã€ããããã®IDã®ã¿ãæž¡ããŸãã
ã·ã³ã°ã«ãã³ãé©åã«èª¿çããæ¹æ³ãåŠã³ãŸãããã
ãªããžããªã³ãŒãã¯æ¬¡ã®ãšããã§ãã
public class AlarmRepository implements IAlarmRepository { // Singleton . //, Singleton RoboGuice @Inject private IAlarmListModel alarmListModel; @Inject Context context; @Inject public AlarmRepository() { db = (new DBHelper(context)).getWritableDatabase(); } @Override public synchronized void load() { IListModelData<AlarmItem> res = (IListModelData<AlarmItem>)alarmListModel; res.getItemList().clear(); res.getDeletedItemList().clear(); Cursor c = db.query(DBHelper.TABLE_NAME, projection, null, null, null, null, DBHelper.A_ID); c.moveToNext(); AlarmItem alarm = null; while(!c.isAfterLast()) { alarm = cvToAlarm(c); res.getItemList().add(alarm); c.moveToNext(); } c.close(); alarmListModel.setLoaded(true); } @Override public synchronized void save() { IListModelData<AlarmItem> model = (IListModelData<AlarmItem>)alarmListModel; ContentValues v = null; for(AlarmItem item : model.getItemList()) { switch(item.getState()) { case CHANGED: v = alarmToCV(item); int retVal = db.update(DBHelper.TABLE_NAME, v, DBHelper.A_ID + "=" + item.getId(), null); break; case ADDED: v = alarmToCV(item); int id = (int)db.insert(DBHelper.TABLE_NAME, null, v); item.setId(id); break; case DELETED: ex = new Exception(" DELETED "); break; } item.setState(EntityState.NOT_CHANGED); } for(AlarmItem item : model.getDeletedItemList()) switch(item.getState()) { case CHANGED: ex = new Exception(" CHANGED "); break; case ADDED: ex = new Exception(" ADDED "); break; case DELETED: int retVal = db.delete(DBHelper.TABLE_NAME, DBHelper.A_ID + "=" + item.getId(), null); break; } model.getDeletedItemList().clear(); } }
cvToAlarmïŒïŒã¡ãœãããšalarmToCVïŒïŒã¡ãœããã¯ãã¢ã©ãŒã ãã£ãŒã«ããããŒã¿ããŒã¹ããŒãã«ã®ãã£ãŒã«ãã«ãããã³ã°ãããããã®éãè¡ã£ããããã ãã§ãèšäºãç ©éã«ããããããŸããã
ããã§ããContenãããã€ããŒãšã®é£æºæ¹æ³ã«ã€ããŠã¯æ€èšããŸããã ãããã£ãŠãããããçš®é¡ã®db.updateïŒïŒããã³db.insertïŒïŒã®æå³ã«ã€ããŠã¯ãSDKãåç §ããŠãã ããã
ããã§ã¯ããªããžããªã®ãã¶ã€ã³ãã¿ãŒã³ã«ã€ããŠèª¬æããŸãã åæã¡ãœããã®å®£èšãšãã圢ã®äºæ¬¡æ©èœã§ç解ããŠããããã«ãç§ã®ãªããžããªãã·ã³ã°ã«ãã³ã§ãã
ãªããžããªã¯ãã¢ãã«ãã¹ãã¬ãŒãžã«ä¿åããããã«ã®ã¿å¿ èŠã§ãã ãªããžããªã¯ãã€ã³ã¿ãŒãããäžã®ãã¡ã€ã«ãããŒã¿ããŒã¹ããŸãã¯ãµãŒãã¹ã§ãã ãã®çµæãä¿ç®¡æ¹æ³ãã¢ãã«ããåé¢ããå¿ èŠã«å¿ããŠäº€æããããšãã§ããŸãã
ãªããžããªã¯ã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããããããã¹ãã§ã¯ç°¡åã«æš¡å£ã«çœ®ãæããããšãã§ããŸãã ãã®çµæã1ã€ã®ã¯ã©ã¹ã®ã¿ããã¹ãããããã¹ãŠã®äŸåéšåãæš¡å£ã«çœ®ãæãããããšãã«åçŽãªåäœãã¹ããå®è¡ã§ããã ãã§ãªããæ©èœãã¹ããå®è¡ã§ããŸãã æ©èœãã¹ãã§ã¯ãããã€ãã®ã¯ã©ã¹ãäžåºŠã«ãã¹ããããŸãã ååãšããŠã圌ãã¯Presenterãã¢ãã«ããã³å¿ èŠãªä»ã®è£å©ã¯ã©ã¹ãåããPresenterã®äžã®ãã¹ãŠãæš¡å£ã«çœ®ãæããŸãã ã¡ã€ã³ã®ãŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãæ£åžžã«åŠçãããããšã確èªããããã«ãBDDææ³ã䜿çšããŠã¢ããªã±ãŒã·ã§ã³ããã¹ãã§ããããšãããããŸããã
ã芧ã®ãšãããloadïŒïŒã¡ãœããã¯ã¢ã©ãŒã ããŒãã«å šäœãèªã¿åããã¢ãã«ã«è»¢éããŸãã ãŸããsaveïŒïŒã¡ãœããã¯ãã¢ãã«ã«ä¿åããå¿ èŠããããã®ã調ã¹ãå€æŽãããããŒã¿ã®ã¿ãä¿åããŸãã
PS
ãã®èšäºã¯éåžžã«å€§ããªãã®ã§ããããšãå€æãããããã¢ãã«ãšãªããžããªã®ãã¹ãã衚瀺ãå§ããŸããã§ããã Presenterã®ãã¹ããšæ¯èŒããŠãæ ¹æ¬çã«æ°ãããã®ã¯ãããŸããã ãŸãããã¹ãã§ãã¹ãæžã¿ã¯ã©ã¹ã®ã€ã³ã¹ã¿ã³ã¹ãäœæããRoboGuiceã䜿çšããŠäŸåé¢ä¿ãã·ãã¥ã¬ãŒã·ã§ã³ã«çœ®ãæããçµæã®æ»äœããã¹ãããŸãã
ä»ã®èšäºãèªã
- ã¯ããã«
-MVPããã³åäœãã¹ãã ãžã§ãã€ã»ãŠã§ã€
- ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ããã¹ããAndroidMock
-ããŒã¿ã®ä¿åã ãã¡ã€ã³ã¢ãã«ããªããžããªãã·ã³ã°ã«ãã³ããã³BDD
-ãµãŒããŒåŽã®å®è£ ãRoboGuiceããã¹ã
-å°ããªã¿ã¹ã¯ãèšå®ããã®ã³ã°ãProGuard