From 2c14c45d7829621c14ba938def00bc819d6376a3 Mon Sep 17 00:00:00 2001 From: biezhihua Date: Thu, 7 Mar 2019 23:49:21 +0800 Subject: [PATCH] feat: Upgrade Depend Version --- app/build.gradle | 13 +++--- .../main/java/com/bzh/dytt/base/BasicApp.kt | 1 + .../main/java/com/bzh/dytt/di/AppComponent.kt | 3 +- .../bzh/dytt/repository/DelayRunnableQueue.kt | 4 +- lintrules/.gitignore | 1 - lintrules/build.gradle | 23 ---------- .../java/com/bzh/dytt/lint/LogDetector.java | 42 ------------------- .../com/bzh/dytt/lint/MyIssueRegistry.java | 19 --------- 8 files changed, 11 insertions(+), 95 deletions(-) delete mode 100644 lintrules/.gitignore delete mode 100644 lintrules/build.gradle delete mode 100644 lintrules/src/main/java/com/bzh/dytt/lint/LogDetector.java delete mode 100644 lintrules/src/main/java/com/bzh/dytt/lint/MyIssueRegistry.java diff --git a/app/build.gradle b/app/build.gradle index 0e39b9f3..b7248a85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,9 +50,9 @@ android { abortOnError false } -// lintOptions { -// lintConfig rootProject.file('lint.xml') -// } + lintOptions { + lintConfig rootProject.file('lint.xml') + } dataBinding { enabled = true @@ -133,9 +133,9 @@ dependencies { implementation 'com.squareup.retrofit2:converter-gson:2.3.0' // - implementation 'com.google.dagger:dagger:2.15' - implementation 'com.google.dagger:dagger-android:2.15' - implementation 'com.google.dagger:dagger-android-support:2.15' + implementation 'com.google.dagger:dagger:2.17' + implementation 'com.google.dagger:dagger-android:2.17' + implementation 'com.google.dagger:dagger-android-support:2.17' implementation 'com.github.bumptech.glide:glide:4.9.0' @@ -151,7 +151,6 @@ dependencies { implementation "android.arch.navigation:navigation-ui:1.0.0-rc02" // use -ktx for Kotlin // java - testImplementation 'com.android.tools.lint:lint-api:26.3.1' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.22.0' testImplementation 'org.hamcrest:hamcrest-all:1.3' diff --git a/app/src/main/java/com/bzh/dytt/base/BasicApp.kt b/app/src/main/java/com/bzh/dytt/base/BasicApp.kt index e659f854..2ab2d92a 100644 --- a/app/src/main/java/com/bzh/dytt/base/BasicApp.kt +++ b/app/src/main/java/com/bzh/dytt/base/BasicApp.kt @@ -32,6 +32,7 @@ class BasicApp : Application(), HasActivityInjector { Log.d(TAG, "onCreate() called ${getSignature(this)}") } + @Suppress("DEPRECATION") @SuppressLint("WrongConstant", "PackageManagerGetSignatures") private fun getSignature(context: Context): String = if (Build.VERSION.SDK_INT >= 28) { val packageInfo = context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_SIGNING_CERTIFICATES) diff --git a/app/src/main/java/com/bzh/dytt/di/AppComponent.kt b/app/src/main/java/com/bzh/dytt/di/AppComponent.kt index c1cd191b..8676f91b 100644 --- a/app/src/main/java/com/bzh/dytt/di/AppComponent.kt +++ b/app/src/main/java/com/bzh/dytt/di/AppComponent.kt @@ -5,6 +5,7 @@ import com.bzh.dytt.base.BasicApp import dagger.BindsInstance import dagger.Component import dagger.android.AndroidInjectionModule +import dagger.android.support.AndroidSupportInjectionModule import javax.inject.Singleton @@ -16,7 +17,7 @@ import javax.inject.Singleton * http://a.codekk.com/detail/Android/%E6%89%94%E7%89%A9%E7%BA%BF/Dagger%20%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90 */ @Singleton -@Component(modules = [AndroidInjectionModule::class, MainActivityModule::class, AppModule::class]) +@Component(modules = [AndroidSupportInjectionModule::class, MainActivityModule::class, AppModule::class]) interface AppComponent { fun inject(basicApp: BasicApp) diff --git a/app/src/main/java/com/bzh/dytt/repository/DelayRunnableQueue.kt b/app/src/main/java/com/bzh/dytt/repository/DelayRunnableQueue.kt index f94a04c3..b25f578b 100644 --- a/app/src/main/java/com/bzh/dytt/repository/DelayRunnableQueue.kt +++ b/app/src/main/java/com/bzh/dytt/repository/DelayRunnableQueue.kt @@ -21,8 +21,8 @@ class DelayObject(val flag: F, val data: E? = null) : Delayed { return unit.convert(diff, TimeUnit.MILLISECONDS) } - override fun compareTo(o: Delayed): Int { - return saturatedCast(this.startTimeMillis - (o as DelayObject<*, *>).startTimeMillis) + override fun compareTo(other: Delayed): Int { + return saturatedCast(this.startTimeMillis - (other as DelayObject<*, *>).startTimeMillis) } override fun equals(other: Any?): Boolean { diff --git a/lintrules/.gitignore b/lintrules/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/lintrules/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/lintrules/build.gradle b/lintrules/build.gradle deleted file mode 100644 index 5ef029ad..00000000 --- a/lintrules/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -apply plugin: 'java-library' - -repositories { - jcenter() - mavenCentral() -} - -dependencies { - compileOnly 'com.android.tools.lint:lint-api:26.1.2' - compileOnly 'com.android.tools.lint:lint-checks:26.1.2' - testCompile "junit:junit:4.12" - testCompile "com.android.tools.lint:lint:26.1.2" - testCompile "com.android.tools.lint:lint-tests:26.1.2" - testCompile "com.android.tools:testutils:26.1.2" -} - -jar { - manifest { - // Only use the "-v2" key here if your checks have been updated to the - // new 3.0 APIs (including UAST) - attributes("Lint-Registry-v2": "com.bzh.dytt.lint.MyIssueRegistry") - } -} diff --git a/lintrules/src/main/java/com/bzh/dytt/lint/LogDetector.java b/lintrules/src/main/java/com/bzh/dytt/lint/LogDetector.java deleted file mode 100644 index 3a2f73b1..00000000 --- a/lintrules/src/main/java/com/bzh/dytt/lint/LogDetector.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.bzh.dytt.lint; - -import com.android.tools.lint.detector.api.Category; -import com.android.tools.lint.detector.api.Detector; -import com.android.tools.lint.detector.api.Implementation; -import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.JavaContext; -import com.android.tools.lint.detector.api.Scope; -import com.android.tools.lint.detector.api.Severity; -import com.android.tools.lint.detector.api.SourceCodeScanner; -import com.android.tools.lint.detector.api.TextFormat; -import com.intellij.psi.PsiMethod; - -import org.jetbrains.uast.UCallExpression; - -import java.util.Arrays; -import java.util.List; - -public class LogDetector extends Detector implements SourceCodeScanner { - - public static final Issue ISSUE = Issue.create( - "LogUsage", - "Avoid director user android.util.Log", - "Avoid director user android.util.Logļ¼Œplease use Logger.d/e/i/v/wtf()", - Category.SECURITY, 5, Severity.ERROR, - new Implementation(LogDetector.class, Scope.JAVA_FILE_SCOPE)); - - @Override - public List getApplicableMethodNames() { - return Arrays.asList("v", "d", "i", "w", "e", "wtf"); - } - - @Override - public void visitMethod(JavaContext context, UCallExpression node, PsiMethod method) { - super.visitMethod(context, node, method); - if (!context.getEvaluator().isMemberInClass(method, "android.util.Log")) { - return; - } - context.report(ISSUE, node, context.getCallLocation(node, true, true), ISSUE.getExplanation(TextFormat.TEXT)); - } - -} diff --git a/lintrules/src/main/java/com/bzh/dytt/lint/MyIssueRegistry.java b/lintrules/src/main/java/com/bzh/dytt/lint/MyIssueRegistry.java deleted file mode 100644 index c0a31d14..00000000 --- a/lintrules/src/main/java/com/bzh/dytt/lint/MyIssueRegistry.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.bzh.dytt.lint; - -import com.android.tools.lint.client.api.IssueRegistry; -import com.android.tools.lint.detector.api.Issue; - -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; - -public class MyIssueRegistry extends IssueRegistry { - - @NotNull - @Override - public List getIssues() { -// return Collections.singletonList(LogDetector.ISSUE); - return Collections.emptyList(); - } -}