From f1dbe4969105a7e82804c7ead92c2a840cd6b643 Mon Sep 17 00:00:00 2001 From: egarcia Date: Mon, 17 Jun 2019 18:04:38 -0300 Subject: [PATCH 1/6] cleaning unnecesary injections within MainActivity --- .../main/java/com/codepath/daggerexample/MainActivity.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/java/com/codepath/daggerexample/MainActivity.java b/app/src/main/java/com/codepath/daggerexample/MainActivity.java index 48b3840..6756b11 100644 --- a/app/src/main/java/com/codepath/daggerexample/MainActivity.java +++ b/app/src/main/java/com/codepath/daggerexample/MainActivity.java @@ -25,12 +25,6 @@ public class MainActivity extends AppCompatActivity { - @Inject - SharedPreferences mSharedPreferences; - - @Inject - Retrofit mRetrofit; - @Inject GitHubApiInterface mGitHubApiInterface; From d3d2c7c8dbc1fe086b5dd096740489c4abb81540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Garc=C3=ADa?= Date: Tue, 18 Jun 2019 11:11:15 -0300 Subject: [PATCH 2/6] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddda23a..7897a0a 100755 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,11 @@ language: android sudo: false android: components: - - build-tools-23.0.1 + - build-tools-23.0.3 - android-23 - extra-android-m2repository - extra-google-m2repository licenses: - android-sdk-license-.+ script: -- "./gradlew build check --daemon" \ No newline at end of file +- "./gradlew build check --daemon" From b42c3adacf7e873cefc04dba61760731f854ca32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Garc=C3=ADa?= Date: Tue, 18 Jun 2019 11:18:32 -0300 Subject: [PATCH 3/6] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7897a0a..defa49d 100755 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: android sudo: false android: components: + - platform-tools + - tools - build-tools-23.0.3 - android-23 - extra-android-m2repository From e374354ffb9c8dbc64448b2010bf9621600a1bc5 Mon Sep 17 00:00:00 2001 From: egarcia Date: Thu, 20 Jun 2019 13:28:53 -0300 Subject: [PATCH 4/6] updating build-tools, dependencies and so on --- .travis.yml | 4 +-- app/build.gradle | 32 ++++++++++--------- app/src/main/AndroidManifest.xml | 2 ++ .../codepath/daggerexample/MainActivity.java | 5 ++- build.gradle | 11 +++++-- gradle/wrapper/gradle-wrapper.properties | 4 +-- 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index defa49d..8aa8f92 100755 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ android: components: - platform-tools - tools - - build-tools-23.0.3 - - android-23 + - build-tools-28.0.3 + - android-28 - extra-android-m2repository - extra-google-m2repository licenses: diff --git a/app/build.gradle b/app/build.gradle index 5c5d87b..30a687a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,13 @@ apply plugin: 'com.android.application' -apply plugin: 'com.neenbedankt.android-apt' android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" + compileSdkVersion 28 + buildToolsVersion '28.0.3' defaultConfig { applicationId "codepath.com.daggerexample" minSdkVersion 16 - targetSdkVersion 23 + targetSdkVersion 28 versionCode 1 versionName "1.0" } @@ -21,15 +20,18 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.1.0' - compile 'com.android.support:design:23.1.0' - compile 'com.google.dagger:dagger:2.0' - provided 'com.google.dagger:dagger-compiler:2.0' - provided 'org.glassfish:javax.annotation:10.0-b28' - compile 'com.google.code.gson:gson:2.4' - compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' - compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' - compile 'com.squareup.okhttp:okhttp:2.4.0' + implementation fileTree(dir: 'libs', include: ['*.jar']) + testImplementation 'junit:junit:4.12' + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support:design:28.0.0' + + implementation 'com.google.dagger:dagger:2.17' + compileOnly 'com.google.dagger:dagger-compiler:2.17' + annotationProcessor 'com.google.dagger:dagger-compiler:2.17' + + compileOnly 'org.glassfish:javax.annotation:10.0-b28' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2' + implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2' + implementation 'com.squareup.okhttp:okhttp:2.5.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c6983e6..a28a777 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,6 +7,7 @@ + diff --git a/app/src/main/java/com/codepath/daggerexample/MainActivity.java b/app/src/main/java/com/codepath/daggerexample/MainActivity.java index 6756b11..017b9c6 100644 --- a/app/src/main/java/com/codepath/daggerexample/MainActivity.java +++ b/app/src/main/java/com/codepath/daggerexample/MainActivity.java @@ -3,7 +3,6 @@ import com.codepath.daggerexample.models.Repository; import com.codepath.daggerexample.network.interfaces.GitHubApiInterface; -import android.content.SharedPreferences; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; @@ -32,10 +31,10 @@ public class MainActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { diff --git a/build.gradle b/build.gradle index cc19335..f122ff2 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,13 @@ buildscript { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } dependencies { - classpath 'com.android.tools.build:gradle:2.1.0' - classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' + classpath 'com.android.tools.build:gradle:3.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -16,6 +19,10 @@ buildscript { allprojects { repositories { jcenter() + maven { + url 'https://maven.google.com/' + name 'Google' + } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6db98b3..6c966c5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun May 08 23:09:38 BST 2016 +#Thu Jun 20 13:04:22 BRT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip From 8e11c9838b507e92438c7351e389d21cd73f21ac Mon Sep 17 00:00:00 2001 From: egarcia Date: Thu, 20 Jun 2019 13:37:24 -0300 Subject: [PATCH 5/6] refactoring for better visibility modifiers --- .../com/codepath/daggerexample/di/modules/AppModule.java | 2 +- .../codepath/daggerexample/di/modules/GitHubModule.java | 2 +- .../com/codepath/daggerexample/di/modules/NetModule.java | 8 +++----- .../com/codepath/daggerexample/models/Repository.java | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/codepath/daggerexample/di/modules/AppModule.java b/app/src/main/java/com/codepath/daggerexample/di/modules/AppModule.java index 59a6052..44b4add 100644 --- a/app/src/main/java/com/codepath/daggerexample/di/modules/AppModule.java +++ b/app/src/main/java/com/codepath/daggerexample/di/modules/AppModule.java @@ -10,7 +10,7 @@ @Module public class AppModule { - Application mApplication; + private Application mApplication; public AppModule(Application application) { mApplication = application; diff --git a/app/src/main/java/com/codepath/daggerexample/di/modules/GitHubModule.java b/app/src/main/java/com/codepath/daggerexample/di/modules/GitHubModule.java index a2ad4c3..2943ff5 100644 --- a/app/src/main/java/com/codepath/daggerexample/di/modules/GitHubModule.java +++ b/app/src/main/java/com/codepath/daggerexample/di/modules/GitHubModule.java @@ -12,7 +12,7 @@ public class GitHubModule { @Provides @UserScope - public GitHubApiInterface providesGitHubInterface(Retrofit retrofit) { + GitHubApiInterface providesGitHubInterface(Retrofit retrofit) { return retrofit.create(GitHubApiInterface.class); } } diff --git a/app/src/main/java/com/codepath/daggerexample/di/modules/NetModule.java b/app/src/main/java/com/codepath/daggerexample/di/modules/NetModule.java index ce73b84..3e88706 100644 --- a/app/src/main/java/com/codepath/daggerexample/di/modules/NetModule.java +++ b/app/src/main/java/com/codepath/daggerexample/di/modules/NetModule.java @@ -21,7 +21,7 @@ @Module public class NetModule { - String mBaseUrl; + private String mBaseUrl; public NetModule(String baseUrl) { this.mBaseUrl = baseUrl; @@ -37,8 +37,7 @@ SharedPreferences providesSharedPreferences(Application application) { @Singleton Cache provideOkHttpCache(Application application) { int cacheSize = 10 * 1024 * 1024; // 10 MiB - Cache cache = new Cache(application.getCacheDir(), cacheSize); - return cache; + return new Cache(application.getCacheDir(), cacheSize); } @@ -61,11 +60,10 @@ OkHttpClient provideOkHttpClient(Cache cache) { @Provides @Singleton Retrofit provideRetrofit(Gson gson, OkHttpClient okHttpClient) { - Retrofit retrofit = new Retrofit.Builder() + return new Retrofit.Builder() .addConverterFactory(GsonConverterFactory.create(gson)) .baseUrl(mBaseUrl) .client(okHttpClient) .build(); - return retrofit; } } diff --git a/app/src/main/java/com/codepath/daggerexample/models/Repository.java b/app/src/main/java/com/codepath/daggerexample/models/Repository.java index b9ab476..9cbd09c 100644 --- a/app/src/main/java/com/codepath/daggerexample/models/Repository.java +++ b/app/src/main/java/com/codepath/daggerexample/models/Repository.java @@ -2,9 +2,9 @@ public class Repository { - String name; - String fullName; - String description; + private String name; + private String fullName; + private String description; public String getName() { return name; From b1e33a5b4f11f184227741d8d32593267cbb4c73 Mon Sep 17 00:00:00 2001 From: egarcia Date: Mon, 24 Jun 2019 15:29:15 -0300 Subject: [PATCH 6/6] #7 using google() function in build.gradle --- app/build.gradle | 1 - build.gradle | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 30a687a..c1db12f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,6 @@ apply plugin: 'com.android.application' android { compileSdkVersion 28 buildToolsVersion '28.0.3' - defaultConfig { applicationId "codepath.com.daggerexample" minSdkVersion 16 diff --git a/build.gradle b/build.gradle index f122ff2..5ea9881 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,7 @@ buildscript { repositories { jcenter() - maven { - url 'https://maven.google.com/' - name 'Google' - } + google() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' @@ -19,10 +16,7 @@ buildscript { allprojects { repositories { jcenter() - maven { - url 'https://maven.google.com/' - name 'Google' - } + google() } }