public List<ListQuadRowItem> generateDisplayList() { List<Plan> lplans = Plan.getAllPlans(); Collections.sort( lplans, new Comparator<Plan>() { public int compare(Plan s1, Plan s2) { return (s1.getPriority() - s2.getPriority()); } }); updateTotals(lplans); ArrayList<ListQuadRowItem> result = new ArrayList<ListQuadRowItem>(); for (Plan plan : lplans) { Piece piece = new Piece(plan.getPieceId()); Composer composer = new Composer(piece.getComposerId()); ListQuadRowItem item = new ListQuadRowItem(); item.setReference(plan.getMyid()); item.setTopLeft(plan.getPriority() + "." + piece.getName()); item.setBottomLeft(composer.getName()); item.setTopRight(plan.getDays()); item.setBottomRight(MyTime.minutesToString(plan.getMinutes())); result.add(item); } ListQuadRowItem item = new ListQuadRowItem(); item.setReference(-1); result.add(item); return result; }
/** Describe <code>onStart</code> method here. */ public final void onStart() { super.onStart(); MyLogger.logE(CLASS_TAG, "onStart():mParentFolderPath:" + mParentFolderPath); if (getCount() > 0) { File path = new File(mParentFolderPath + File.separator + mStoragePath); if (!path.exists()) { path.mkdirs(); } File file = new File(path.getAbsolutePath() + File.separator + mStorageName); if (!file.exists()) { try { file.createNewFile(); } catch (Exception e) { MyLogger.logE(CLASS_TAG, "onStart():file:" + file.getAbsolutePath()); MyLogger.logE(CLASS_TAG, "onStart():create file failed"); } } try { mWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))); } catch (Exception e) { MyLogger.logE(CLASS_TAG, "new BufferedWriter failed"); } } }
/** Describe <code>onEnd</code> method here. */ public final void onEnd() { super.onEnd(); try { MyLogger.logD(CLASS_TAG, "SmsBackupComposer onEnd"); if (mWriter != null) { MyLogger.logE(CLASS_TAG, "mWriter.close()"); mWriter.close(); } } catch (Exception e) { MyLogger.logE(CLASS_TAG, "mWriter.close() failed"); } for (Cursor cur : mSmsCursorArray) { if (cur != null) { cur.close(); cur = null; } } }
/** * Composes the target information output string. * * @param index of the target in the collection. * @param collection the target containing collection. * @throws IllegalArgumentException if either {@code target} or {@code collection} is {@code * null}. */ protected String composeTargetOutInfoString( final int index, final TargetCollection<Target> collection) { Utils.nonNull(collection, "the collection cannot be null"); Utils.validIndex(index, collection.targetCount()); return composer.apply(index, collection); }