/** * Returns the timestamp at the first install of this app that Apptentive was aware of. */ public Apptentive.DateTime getTimeAtInstallTotal() { // Simply return the first item's timestamp, if there is one. if (versionHistoryItems.size() > 0) { return new Apptentive.DateTime(versionHistoryItems.get(0).getTimestamp()); } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
/** * Returns the timestamp at the first install of the current versionCode of this app that Apptentive was aware of. */ public Apptentive.DateTime getTimeAtInstallForVersionCode(int versionCode) { for (VersionHistoryItem item : versionHistoryItems) { if (item.getVersionCode() == versionCode) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
/** * Returns the timestamp at the first install of the current versionName of this app that Apptentive was aware of. */ public Apptentive.DateTime getTimeAtInstallForVersionName(String versionName) { for (VersionHistoryItem item : versionHistoryItems) { Apptentive.Version entryVersionName = new Apptentive.Version(); Apptentive.Version currentVersionName = new Apptentive.Version(); entryVersionName.setVersion(item.getVersionName()); currentVersionName.setVersion(versionName); if (entryVersionName.equals(currentVersionName)) { return new Apptentive.DateTime(item.getTimestamp()); } } return new Apptentive.DateTime(Util.currentTimeSeconds()); }
@Test public void testVersionHistoryStoreGetLatestVersion() { VersionHistory versionHistory = new VersionHistory(); versionHistory.updateVersionHistory(1.472853954087E9d, 1, "3.3.0"); versionHistory.updateVersionHistory(1.472854098019E9d, 2, "3.3.1"); VersionHistoryItem latestEntry = versionHistory.getLastVersionSeen(); assertNotNull(latestEntry); assertEquals(1.472854098019E9d, latestEntry.getTimestamp(), .000001d); assertEquals(2, latestEntry.getVersionCode()); assertEquals("3.3.1", latestEntry.getVersionName()); }