Search in sources :

Example 6 with ExpansionIndexItem

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;
    }
}
Also used : ExpansionIndexItem(scal.io.liger.model.sqlbrite.ExpansionIndexItem)

Aggregations

ExpansionIndexItem (scal.io.liger.model.sqlbrite.ExpansionIndexItem)6 File (java.io.File)4 InstanceIndexItem (scal.io.liger.model.sqlbrite.InstanceIndexItem)3 ArrayList (java.util.ArrayList)2 BaseIndexItem (scal.io.liger.model.sqlbrite.BaseIndexItem)2 InstalledIndexItem (scal.io.liger.model.sqlbrite.InstalledIndexItem)2 Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 ViewPager (android.support.v4.view.ViewPager)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Cursor (net.sqlcipher.Cursor)1 SQLiteDatabase (net.sqlcipher.database.SQLiteDatabase)1