diff --git a/build.gradle b/build.gradle index ebe239c..82cfeed 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ buildscript { maven { url 'https://jitpack.io' } } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0-alpha03' + classpath 'com.android.tools.build:gradle:3.2.0-alpha16' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Additional libraries diff --git a/dbsession/src/main/java/com/github/deckyfx/dbsession/DBSession.java b/dbsession/src/main/java/com/github/deckyfx/dbsession/DBSession.java index e7c386c..e8227de 100644 --- a/dbsession/src/main/java/com/github/deckyfx/dbsession/DBSession.java +++ b/dbsession/src/main/java/com/github/deckyfx/dbsession/DBSession.java @@ -69,18 +69,24 @@ public String getRaw(){ return "{}"; } - public T get(){ + public T get(){ T session = this.getOrNull(); if (session == null) { - return (T) new BaseItem(); + try { + session = this.mSessionClass.newInstance(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } } return session; } - public T getOrNull(){ + public T getOrNull(){ T session = null; try { - session = (T) BaseItem.fromJson(this.getRaw(), this.mSessionClass); + session = T.fromJson(this.getRaw(), this.mSessionClass); } catch (Exception e) { e.printStackTrace(); } @@ -91,7 +97,7 @@ public void set(String config) throws JSONException { this.set(new JSONObject(config)); } - public void set(JSONObject config) throws JSONException { + public void set(JSONObject config) { List session_list = this.getEntity(DB_SESSION.DAO_NAME) .queryBuilder().limit(1) .orderAsc(this.DbSessionIdProperty).list(); @@ -108,7 +114,7 @@ public void set(JSONObject config) throws JSONException { this.getEntity(DB_SESSION.DAO_NAME).insertOrReplace(session); } - public void set(BaseItem session) throws Exception { + public void set(T session) throws Exception { this.set(BaseItem.toJson(session)); } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9f79488..7638e03 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Aug 02 12:34:20 WIB 2017 +#Tue Jun 05 16:03:35 WIB 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip