private boolean isMeetConditionToMerge() { final long totalRecordSize = calculateAllToMergeRecordSize(); if (totalRecordSize < BackupManager.getInstance().getMaxBackupSizeLimit(this)) { return true; } // 大小超过限制,判断是否付费用户 return isPaidUser(); }
private void init() { mBackupManager = BackupManager.getInstance(); List<IRecord> records = new ArrayList<IRecord>(); // // 将整合备份项加入第一个 mSmartMergedRecord = getMergedRecord(); // if (smartMergedRecord != null) { // records.add(smartMergedRecord); // mMergedRecord = new RecordItem(); // mMergedRecord.record = smartMergedRecord; // mMergedRecord.isSelected = false; // } // 讲定时备份项加入第二个 IRecord scheduleRecord = getScheduleRecord(); if (scheduleRecord != null) { records.add(scheduleRecord); mScheduledRecord = new RecordItem(); mScheduledRecord.record = scheduleRecord; mScheduledRecord.isSelected = false; } List<IRecord> normalRecords = mBackupManager.getAllRestoreRecords(); if (normalRecords != null && normalRecords.size() > 0) { records.addAll(normalRecords); } mAdapter = new RecordItemListAdapter(this, new RecordListAdapter(this, records)); ((RecordItemListAdapter) mAdapter) .setOnItemSelectedListener( new OnItemSelectedListener() { @Override public void onItemSelected(Object item, boolean selected) { updateMergeButton(); updateSelectButton(); } }); mListView.setAdapter(mAdapter); updateMergeButton(); updateSelectButton(); }
private IRecord getScheduleRecord() { List<IRecord> scheduleRecords = mBackupManager.getScheduleRecords(); if (Util.isCollectionEmpty(scheduleRecords)) { return null; } final String preferSdCardPath = Util.getSdRootPathOnPreference(this); for (IRecord record : scheduleRecords) { String recordDir = ((RestorableRecord) record).getRecordRootDir(); if (recordDir.startsWith(preferSdCardPath)) { return record; } } return scheduleRecords.get(0); }