Skip to content

Gradle upgrade #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.4.0-rc03'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -14,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
26 changes: 15 additions & 11 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
compileSdkVersion 28
buildToolsVersion '29.0.0 rc2'
defaultConfig {
applicationId "com.basilgregory.onamsample"
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -17,17 +17,21 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':onam')
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
implementation project(':onam')
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,9 @@ public void onLongClick(View view, int position) {

}

View.OnClickListener removeAllPosts = new View.OnClickListener() {
@Override
public void onClick(View v) {
Post.truncate(Post.class);
}
};
View.OnClickListener removeAllPosts = v -> Post.truncate(Post.class);

View.OnClickListener addNewPlan = new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(AllPostsActivity.this,AddPostActivity.class));
}
};
View.OnClickListener addNewPlan = v -> startActivity(new Intent(AllPostsActivity.this,AddPostActivity.class));

private void fetchAllPosts(){
postList = Post.findAll(Post.class);
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 28 17:03:32 IST 2017
#Thu Apr 11 11:15:57 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
19 changes: 12 additions & 7 deletions onam/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
compileSdkVersion 28
buildToolsVersion '29.0.0 rc2'

defaultConfig {
minSdkVersion 14
targetSdkVersion 25
targetSdkVersion 28
versionCode 2
versionName "2.1"

Expand All @@ -19,14 +19,19 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:28.0.0'

}
10 changes: 4 additions & 6 deletions onam/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<manifest package="com.basilgregory.onam"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:android="http://schemas.android.com/apk/res/android"
>
package="com.basilgregory.onam">

<application
android:label="@string/app_name"
android:supportsRtl="true"
>
android:label="@string/app_name"
android:supportsRtl="true">

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DBExecutor extends SQLiteOpenHelper {
Storage storage;
String dbName;
private static DBExecutor instance = null;
private static Map<String,DBExecutor> instances = new HashMap<String,DBExecutor>();
private static Map<String,DBExecutor> instances = new HashMap<>();
public static DBExecutor getInstance(Context context, String dbName, int version) {
if (instances.containsKey(dbName)) instance = instances.get(dbName);
instance = instance == null ?
Expand Down Expand Up @@ -248,7 +248,7 @@ private void findAndSetByReferenceByRowId(Entity entity, long id) {


private List<Entity> convertToEntityAndFetchFirstDegreeRelatedEntity(Cursor cursor,Class<Entity> entityClass){
List<Entity> entities = new ArrayList<Entity>();
List<Entity> entities = new ArrayList<>();
if (cursor != null && cursor.getCount() > 0 ) {
cursor.moveToFirst();
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class DDLBuilder {

static String createMappingTables(String tableName,Class fromClass,Class targetClass){
StringBuffer ddlCreate = new StringBuffer();
StringBuilder ddlCreate = new StringBuilder();
//This pattern "table [] ( " is used in #{DbUtil.extractNameOfTableFromDdl} cross check when making a change.
ddlCreate.append("create table ").append(tableName).append(" ( ");
ddlCreate.append(DbUtil.getMappingForeignColumnNameClass(fromClass)).append(" integer,");
Expand All @@ -32,7 +32,7 @@ static String createMappingTables(String tableName,Class fromClass,Class targetC

static HashMap<String,String> createTables(List<Class> curatedClassList){

HashMap<String,String> ddls = new HashMap<String,String>(curatedClassList.size());
HashMap<String,String> ddls = new HashMap<>(curatedClassList.size());

for(Class cls:curatedClassList) {
if (cls == null || cls.getAnnotation(Table.class) == null) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static HashMap<String,String> curateAndDropTables(List<String> tableNamesAlready
}

private static HashMap<String,String> dropTables(List<String> tableNames){
HashMap<String,String> dmls = new HashMap<String,String>(tableNames.size());
HashMap<String,String> dmls = new HashMap<>(tableNames.size());
for(String tableName:tableNames) {
dmls.put(tableName,dropTable(tableName));
}
Expand All @@ -45,7 +45,7 @@ private static String dropTable(String tableName){
}

static HashMap<String,String> renameTables(Class[] classes){
HashMap<String,String> dmls = new HashMap<String,String>(classes.length);
HashMap<String,String> dmls = new HashMap<>(classes.length);
for(Class cls:classes) {
if (cls == null) continue;
Table table = (Table)cls.getAnnotation(Table.class);
Expand All @@ -60,7 +60,7 @@ static HashMap<String,String> renameTables(Class[] classes){
}

static HashMap<String,String> addColumns(HashMap<Class,List<String>> classColumnNamePairs){
HashMap<String,String> dmls = new HashMap<String,String>(classColumnNamePairs.size());
HashMap<String,String> dmls = new HashMap<>(classColumnNamePairs.size());
for(Class cls : classColumnNamePairs.keySet()) {
if (cls == null || cls.getAnnotation(Table.class) == null) continue;
String tableName = DbUtil.getTableName(cls);
Expand All @@ -78,7 +78,7 @@ private static String renameTable(String tableName , String oldName){
}

private static List<String> addColumns(List<String> existingTableColumns, Class newTableClass){
List<String> addColumnsDml = new ArrayList<String>();
List<String> addColumnsDml = new ArrayList<>();
if (existingTableColumns == null || newTableClass == null) return addColumnsDml;
Field[] declaredFields = newTableClass.getDeclaredFields();
for (Field field : declaredFields) {
Expand Down
14 changes: 6 additions & 8 deletions onam/src/main/java/com/basilgregory/onam/android/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
* Created by donpeter on 8/28/17.
*/

import android.app.Activity;
import android.support.v7.app.*;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.*;

import java.io.Serializable;
import java.util.List;
import java.io.*;
import java.util.*;

/**
* This class will act as the base class for all Entity POJOs.
Expand Down Expand Up @@ -118,11 +116,11 @@ protected <E extends Entity> List<E> fetch(List<E> relatedEntityList, Object ho
*
* @param activityObject - Current class object or preferably Acitivty object (ex. Activity.this).
*/
public static void init(Activity activityObject, Object classWithDBAnnotation){
public static void init(AppCompatActivity activityObject, Object classWithDBAnnotation){
DBExecutor.init(activityObject.getApplicationContext(),classWithDBAnnotation);
}

public static void init(Activity activityObject){
public static void init(AppCompatActivity activityObject){
DBExecutor.init(activityObject.getApplicationContext(),activityObject);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static String findByProperty(Class<Entity> cls,String columnName,Object value,In

static String findByProperty(Class<Entity> cls,String columnName,Object value,String orderByColumn, boolean descending, Integer startIndex,Integer pageSize){
value = FieldType.isStringType(value) ? "'"+value+"'" : value;
StringBuffer orderByCondition = new StringBuffer(orderByColumn)
StringBuilder orderByCondition = new StringBuilder(orderByColumn)
.append(" ").append(descending ? "DESC" : "ASC");
return selectQuery(DbUtil.getTableName(cls),columnName+" = "+value,null,orderByCondition.toString(),startIndex,pageSize);
}
Expand All @@ -67,7 +67,7 @@ static String findAll(Class<Entity> cls,String whereClause,Integer startIndex,In
}

static String findAll(Class<Entity> cls,String whereClause,String orderByColumn,boolean descending,Integer startIndex,Integer pageSize){
StringBuffer orderByCondition = new StringBuffer(orderByColumn)
StringBuilder orderByCondition = new StringBuilder(orderByColumn)
.append(" ").append(descending ? "DESC" : "ASC");
return selectQuery(DbUtil.getTableName(cls),whereClause,null,orderByCondition.toString(),startIndex,pageSize);
}
Expand All @@ -86,7 +86,7 @@ static String selectQuery(String tableName,String whereClause,String groupBy,Str
whereClause = whereClause == null? "" : " where "+ whereClause;
groupBy = groupBy == null? "" : " group by "+ groupBy;
orderBy = orderBy == null? "" : " order by "+orderBy;
StringBuffer selectQuery = new StringBuffer("select * from ").append(tableName)
StringBuilder selectQuery = new StringBuilder("select * from ").append(tableName)
.append(whereClause).append(groupBy).append(orderBy);
if (pageSize != null)
selectQuery.append(" LIMIT ").append(startIndex == null? 0 : startIndex).append(",").append(pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void storeCurrentDbMeta(String databaseName,DbMetaData dbMetaData) throws Except
"database_meta", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(databaseName, DB.toString(dbMetaData));
editor.commit();
editor.apply();
}

DbMetaData getCurrentDbMeta(String databaseName) throws Exception{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ONAMException() {
}

public String toString () {
StringBuffer sb = new StringBuffer(this.code).append(": ").append(this.getMessage());
StringBuilder sb = new StringBuilder(this.code).append(": ").append(this.getMessage());
if (entity != null) sb.append("\n Entity").append(entity.getClass().getSimpleName());
if (query != null) sb.append("\n Query").append(query);
if (field != null) sb.append("\n Field").append(field.getName());
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':demo', ':onam'
include ':onam', ':demo'