/** aggiunge una pagina al diario passato */ public static Diary addPageToDiary(Diary mDiary, Page mPage) { mCurrentDiary = mDiary; Hashtable<Long, Page> mPages = mCurrentDiary.getDiaryPages(); int mPageNumber = mPages.size(); mPage.setPageNumber(mPageNumber); mPage.setDiaryID(mCurrentDiary.getDiaryID()); mPages.put(mPage.getPageID(), mPage); return mCurrentDiary; }
/** * Inizializza un nuovo Diario con tutte le proprietà necessarie * * <p>* */ public static Diary initNewDiary(int template) { mCurrentDiary = new Diary(); // Repository mReposotory = new Repository(mContext); long mDiaryID = 0; Date mDate = new Date(); SimpleDateFormat oDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); try { mDiaryID = Long.parseLong(oDateFormat.format(mDate)); } catch (NumberFormatException e) { Log.e(DiaryHelper.class.getCanonicalName(), "Number Format Error "); System.exit(1); } mCurrentDiary.setDiaryID(mDiaryID); mCurrentDiary.setDiaryTemplate(template); mCurrentDiary.setDiaryDTCreation(mDate); mCurrentDiary.setDiaryDTModify(mDate); mCurrentDiary.setDiaryPages(newPagesBuilder()); return mCurrentDiary; }
/** * inizializza una pagina vuota del Nuovo Diario * * <p>* */ private static Hashtable<Long, Page> newPagesBuilder() { Date mDate = new Date(); SimpleDateFormat oDateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); long mPageID = 0; try { mPageID = Long.parseLong(oDateFormat.format(mDate)); } catch (NumberFormatException e) { mPageID = 0; } Hashtable<Long, Page> mPages = new Hashtable<Long, Page>(); Page mPage = new Page(); mPage.setDiaryID(mCurrentDiary.getDiaryID()); mPage.setPageID(mPageID); mPage.setPageDTCreation(new Date()); mPage.setPageNumber(1); mPage.setDiaryImage(newImagesBuilder()); mPage.setPageRows(newRowsBuilder()); mPages.put(mPageID, mPage); return mPages; }