use of scal.io.liger.model.sqlbrite.ExpansionIndexItem in project storymaker by StoryMaker.
the class StorymakerDownloadHelper method updateItem.
// need to be able to check/download a single file (currently only supports content packs)
public static ExpansionIndexItem updateItem(Context context, ExpansionIndexItem installedItem, ExpansionIndexItem availableItem) {
boolean itemUpdated = false;
if ((installedItem.getExpansionFileVersion() != null) && (availableItem.getExpansionFileVersion() != null) && (Integer.parseInt(availableItem.getExpansionFileVersion()) > Integer.parseInt(installedItem.getExpansionFileVersion()))) {
Timber.d("FOUND NEWER VERSION OF MAIN EXPANSION ITEM " + installedItem.getExpansionId() + " (" + availableItem.getExpansionFileVersion() + " vs. " + installedItem.getExpansionFileVersion() + ") UPDATING");
installedItem.setExpansionFileVersion(availableItem.getExpansionFileVersion());
itemUpdated = true;
}
// need to account for case where installed item has no defined patch version
if (availableItem.getPatchFileVersion() != null) {
if (installedItem.getPatchFileVersion() != null) {
if (Integer.parseInt(availableItem.getPatchFileVersion()) > Integer.parseInt(installedItem.getPatchFileVersion())) {
Timber.d("FOUND NEWER VERSION OF PATCH EXPANSION ITEM " + installedItem.getExpansionId() + " (" + availableItem.getPatchFileVersion() + " vs. " + installedItem.getPatchFileVersion() + ") UPDATING");
installedItem.setPatchFileVersion(availableItem.getPatchFileVersion());
itemUpdated = true;
}
} else {
Timber.d("FOUND NEWER VERSION OF PATCH EXPANSION ITEM " + installedItem.getExpansionId() + " (" + availableItem.getPatchFileVersion() + " vs. " + installedItem.getPatchFileVersion() + ") UPDATING");
installedItem.setPatchFileVersion(availableItem.getPatchFileVersion());
itemUpdated = true;
}
}
ExpansionIndexItem tempItem = fixStats(installedItem, availableItem);
if (tempItem != null) {
Timber.d("FOUND UPDATED STATS FOR EXPANSION ITEM " + installedItem.getExpansionId() + " UPDATING");
installedItem = tempItem;
itemUpdated = true;
}
if (itemUpdated) {
return installedItem;
} else {
return null;
}
}
Aggregations