mirror of
https://github.com/etesync/android
synced 2025-01-10 15:51:08 +00:00
Remove redundant code.
This commit is contained in:
parent
09c932c02c
commit
69b044a444
@ -158,22 +158,6 @@ class App : Application() {
|
||||
private fun update(fromVersion: Int) {
|
||||
Logger.log.info("Updating from version " + fromVersion + " to " + BuildConfig.VERSION_CODE)
|
||||
|
||||
if (fromVersion < 6) {
|
||||
val data = this.data
|
||||
|
||||
val dbHelper = ServiceDB.OpenHelper(this)
|
||||
|
||||
val collections = readCollections(dbHelper)
|
||||
for (info in collections) {
|
||||
val journalEntity = JournalEntity(data, info)
|
||||
data.insert(journalEntity)
|
||||
}
|
||||
|
||||
val db = dbHelper.writableDatabase
|
||||
db.delete(ServiceDB.Collections._TABLE, null, null)
|
||||
db.close()
|
||||
}
|
||||
|
||||
if (fromVersion < 7) {
|
||||
/* Fix all of the etags to be non-null */
|
||||
val am = AccountManager.get(this)
|
||||
@ -234,21 +218,6 @@ class App : Application() {
|
||||
|
||||
}
|
||||
|
||||
private fun readCollections(dbHelper: ServiceDB.OpenHelper): List<CollectionInfo> {
|
||||
val db = dbHelper.writableDatabase
|
||||
val collections = LinkedList<CollectionInfo>()
|
||||
val cursor = db.query(ServiceDB.Collections._TABLE, null, null, null, null, null, null)
|
||||
while (cursor.moveToNext()) {
|
||||
val values = ContentValues()
|
||||
DatabaseUtils.cursorRowToContentValues(cursor, values)
|
||||
collections.add(CollectionInfo.fromDB(values))
|
||||
}
|
||||
|
||||
db.close()
|
||||
cursor.close()
|
||||
return collections
|
||||
}
|
||||
|
||||
fun migrateServices(dbHelper: ServiceDB.OpenHelper) {
|
||||
val db = dbHelper.readableDatabase
|
||||
val data = this.data
|
||||
|
@ -48,23 +48,6 @@ class CollectionInfo : com.etesync.journalmanager.model.CollectionInfo() {
|
||||
return info
|
||||
}
|
||||
|
||||
fun fromDB(values: ContentValues): CollectionInfo {
|
||||
val info = CollectionInfo()
|
||||
info.id = values.getAsLong(Collections.ID)!!
|
||||
info.serviceID = values.getAsInteger(Collections.SERVICE_ID)!!
|
||||
|
||||
info.uid = values.getAsString(Collections.URL)
|
||||
info.displayName = values.getAsString(Collections.DISPLAY_NAME)
|
||||
info.description = values.getAsString(Collections.DESCRIPTION)
|
||||
|
||||
info.color = values.getAsInteger(Collections.COLOR)
|
||||
|
||||
info.timeZone = values.getAsString(Collections.TIME_ZONE)
|
||||
|
||||
info.selected = values.getAsInteger(Collections.SYNC) != 0
|
||||
return info
|
||||
}
|
||||
|
||||
fun fromJson(json: String): CollectionInfo {
|
||||
return GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, CollectionInfo::class.java)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user