Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Fix incompatibility with old prefs-libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
erikeelde committed Jan 3, 2018
1 parent 3ab0839 commit 7bfac41
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ public Uri insert(@NonNull Uri uri, ContentValues values) {
case CURRENT_CONFIGURATIONS: {
Bolt bolt = Bolt.fromContentValues(values);

bolt = fixRCTypes(bolt);

WrenchConfiguration wrenchConfiguration = configurationDao.getWrenchConfiguration(callingApplication.id(), bolt.getKey());

if (wrenchConfiguration == null) {
Expand Down Expand Up @@ -290,6 +292,23 @@ public Uri insert(@NonNull Uri uri, ContentValues values) {
return ContentUris.withAppendedId(uri, insertId);
}

private Bolt fixRCTypes(Bolt bolt) {
switch (bolt.getType()) {
case "java.lang.String":
return bolt.copy(bolt.getId(), Bolt.TYPE.STRING, bolt.getKey(), bolt.getValue());
case "java.lang.Integer":
return bolt.copy(bolt.getId(), Bolt.TYPE.INTEGER, bolt.getKey(), bolt.getValue());
case "java.lang.Enum":
return bolt.copy(bolt.getId(), Bolt.TYPE.ENUM, bolt.getKey(), bolt.getValue());
case "java.lang.Boolean":
return bolt.copy(bolt.getId(), Bolt.TYPE.BOOLEAN, bolt.getKey(), bolt.getValue());
default: {
return bolt;
}

}
}

@Override
public int bulkInsert(@NonNull Uri uri, @NonNull ContentValues[] values) {
WrenchApplication callingApplication = getCallingApplication(getContext(), applicationDao);
Expand Down

0 comments on commit 7bfac41

Please sign in to comment.