Skip to content

Commit

Permalink
去掉第三方工具包,自建工具包utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao authored and Tao committed Dec 27, 2019
1 parent 66be5f8 commit 6e6cc7d
Show file tree
Hide file tree
Showing 36 changed files with 650 additions and 83 deletions.
8 changes: 2 additions & 6 deletions annotation/src/main/java/com/catchpig/annotation/TimeLog.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.catchpig.annotation

import com.catchpig.annotation.enums.LEVEL

/**
* 创建时间:2019/10/20 0020<br/>
* 创建人: 李涛<br/>
Expand All @@ -15,9 +17,3 @@ annotation class TimeLog(
*/
val value:LEVEL = LEVEL.D
)
/**
* 日志等级
*/
enum class LEVEL{
V, D, I, W, E
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.catchpig.annotation.enums

/**
* 日志等级
*/
enum class LEVEL {
V, D, I, W, E
}
3 changes: 1 addition & 2 deletions aop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$core_ktx_version"
api project(path: ':annotation')
api project(path: ':utils')
//aspectj
api "org.aspectj:aspectjrt:$aspectj_version"
api "luyao.util.ktx:AndroidUtilKTX:$AndroidUtilKTX_version"

}
2 changes: 1 addition & 1 deletion aop/src/main/java/com/catchpig/aop/LifecycleLogAspectJ.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.catchpig.aop

import luyao.util.ktx.ext.logd
import com.catchpig.utils.ext.logd
import org.aspectj.lang.JoinPoint
import org.aspectj.lang.annotation.*

Expand Down
27 changes: 3 additions & 24 deletions aop/src/main/java/com/catchpig/aop/TimeLogAspectJ.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.catchpig.aop

import android.util.Log
import com.catchpig.annotation.LEVEL
import com.catchpig.annotation.TimeLog
import luyao.util.ktx.ext.*
import com.catchpig.utils.ext.log
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
Expand Down Expand Up @@ -49,26 +47,7 @@ class TimeLogAspectJ {
}
params.delete(0,1)
val time = afterTimeOfMethod-beforeTimeOfMethod
log(timeLog.value,TAG,"${className}.${method}(${params})耗时:${time}毫秒")
}

private fun log(level: LEVEL, tag:String, msg:String){
when (level) {
LEVEL.I -> {
Log.i(tag,msg)
}
LEVEL.W -> {
Log.w(tag,msg)
}
LEVEL.E -> {
Log.e(tag,msg)
}
LEVEL.V -> {
Log.v(tag,msg)
}
LEVEL.D -> {
Log.d(tag,msg)
}
}
val level = timeLog.value
log(level,TAG,"${className}.${method}(${params})耗时:${time}毫秒")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import com.catchpig.kotlin_mvp.mvp.main.presenter.MainPresenter
import com.catchpig.kotlin_mvp.mvp.recycle.RecycleActivity
import com.catchpig.kotlin_mvp.mvp.transparent.TransparentActivity
import com.catchpig.annotation.ClickGap
import com.catchpig.annotation.LEVEL
import com.catchpig.annotation.StatusBar
import com.catchpig.annotation.TimeLog
import com.catchpig.aop.TimeLogAspectJ
import com.catchpig.annotation.enums.LEVEL
import com.catchpig.mvp.base.activity.BasePresenterActivity
import com.catchpig.utils.ext.startKtActivity

@StatusBar(enabled = true)
class MainActivity : BasePresenterActivity<MainPresenter>(),MainContract.View {
Expand All @@ -37,23 +37,21 @@ class MainActivity : BasePresenterActivity<MainPresenter>(),MainContract.View {
}
@ClickGap(2000)
fun openChild(v:View){
var intent = Intent()
when (v.id) {
R.id.is_title -> {
intent.setClass(this,ChildActivity::class.java)
startKtActivity<ChildActivity>()
}
R.id.transparent -> {
intent.setClass(this,TransparentActivity::class.java)
startKtActivity<TransparentActivity>()
}
R.id.full_screen -> {
intent.setClass(this,FullScreenActivity::class.java)
startKtActivity<FullScreenActivity>()
}
R.id.recycle -> {
intent.setClass(this,RecycleActivity::class.java)
startKtActivity<RecycleActivity>()
}
else -> {
}
}
startActivity(intent)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.catchpig.annotation.TimeLog
import com.catchpig.kotlin_mvp.R
import com.catchpig.mvp.base.activity.BaseActivity
import com.catchpig.mvp.widget.refresh.OnRefreshListener
import com.catchpig.utils.ext.logd
import com.google.android.material.appbar.AppBarLayout
import com.gyf.immersionbar.ktx.immersionBar
import com.scwang.smart.refresh.layout.api.RefreshLayout
Expand All @@ -16,8 +17,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.subscribers.ResourceSubscriber
import kotlinx.android.synthetic.main.activity_recycle.*
import kotlinx.android.synthetic.main.layout_header.view.*
import luyao.util.ktx.ext.logd
import luyao.util.ktx.ext.longToast
import java.util.*
import java.util.concurrent.TimeUnit
import kotlin.collections.ArrayList
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.50'
buildscript {
ext.kotlin_version = '1.3.60'

ext{
ext {
compileSdkVersion = 29
buildToolsVersion = '29.0.2'
minSdkVersion = 19
Expand All @@ -22,7 +22,6 @@ buildscript {
rxandroid_version = '2.1.1'
gson_version = '2.8.5'
glide_version = '4.9.0'
AndroidUtilKTX_version = '0.0.5'
photoview_version = '2.0.0'
chart_version = 'v3.1.0'
viewpagerlayoutmanager_version = '2.0.22'
Expand Down
13 changes: 5 additions & 8 deletions mvp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.catch-pig'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion


defaultConfig {
minSdkVersion 19
targetSdkVersion 29
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"

Expand All @@ -43,7 +43,7 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

implementation 'androidx.recyclerview:recyclerview:1.0.0'
api 'androidx.recyclerview:recyclerview:1.0.0'
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$core_ktx_version"
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand All @@ -70,10 +70,7 @@ dependencies {
api "io.reactivex.rxjava2:rxjava:$rxjava_version"
api "io.reactivex.rxjava2:rxandroid:$rxandroid_version"

//gson
api "com.google.code.gson:gson:$gson_version"

api "luyao.util.ktx:AndroidUtilKTX:$AndroidUtilKTX_version"

api "com.github.catch-pig:LoadingView:$loading_version"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.catchpig.mvp.apt

import com.catchpig.mvp.base.activity.BaseActivity
import luyao.util.ktx.ext.logd
import com.catchpig.utils.ext.logd

/**
* 创建时间:2019/10/17 0017<br/>
Expand Down
1 change: 0 additions & 1 deletion mvp/src/main/java/com/catchpig/mvp/apt/MvpCompiler.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.catchpig.mvp.apt

import android.view.ViewStub
import com.catchpig.mvp.base.activity.BaseActivity

/**
Expand Down
10 changes: 0 additions & 10 deletions mvp/src/main/java/com/catchpig/mvp/base/BasePresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import io.reactivex.Flowable
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.subscribers.ResourceSubscriber
import luyao.util.ktx.ext.logd


/**
Expand All @@ -18,15 +17,6 @@ import luyao.util.ktx.ext.logd
* 描述:
*/
open class BasePresenter: BaseContract.Presenter {
companion object {
const val TAG = "BasePresenter"
const val ON_CREATE = "onCreate"
const val ON_START = "onStart"
const val ON_RESUME = "onResume"
const val ON_PAUSE = "onPause"
const val ON_STOP = "onStop"
const val ON_DESTROY = "onDestroy"
}
private var mCompositeDisposable: CompositeDisposable = CompositeDisposable()
@CallSuper
override fun onCreate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import com.catchpig.mvp.R
import com.catchpig.mvp.apt.KotlinMvpCompiler
import com.catchpig.mvp.base.BaseContract
import com.catchpig.mvp.controller.LoadingViewController
import com.catchpig.utils.ext.longToast
import kotlinx.android.synthetic.main.view_root.*
import luyao.util.ktx.ext.longToast

/**
* 创建时间:2019/4/4 00:09<br></br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.annotation.Nullable
import androidx.fragment.app.Fragment
import com.catchpig.mvp.base.BaseContract
import com.catchpig.mvp.base.activity.BaseActivity
import luyao.util.ktx.ext.longToast

/**
* 创建时间:2019/4/4 23:14<br></br>
Expand Down
3 changes: 1 addition & 2 deletions mvp/src/main/java/com/catchpig/mvp/di/module/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package com.catchpig.mvp.di.module
import android.app.Application
import com.catchpig.mvp.config.Config
import com.catchpig.mvp.gson.DateJsonDeserializer
import com.catchpig.utils.ext.logd
import com.google.gson.*
import dagger.Module
import dagger.Provides
import luyao.util.ktx.ext.logd
import okhttp3.logging.HttpLoggingInterceptor
import java.lang.reflect.Type
import java.util.*
import javax.inject.Singleton

Expand Down
2 changes: 1 addition & 1 deletion mvp/src/main/java/com/catchpig/mvp/ext/ContextExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.annotation.DrawableRes
import androidx.annotation.LayoutRes
import androidx.core.content.ContextCompat
import com.catchpig.mvp.R
import luyao.util.ktx.ext.logd
import com.catchpig.utils.ext.logd

/**
* 创建时间:2019/8/19 0019<br/>
Expand Down
10 changes: 0 additions & 10 deletions mvp/src/main/java/com/catchpig/mvp/manager/KTActivityManager.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.catchpig.mvp.manager

import android.app.Activity
import android.content.Intent
import java.util.*

object KTActivityManager {
Expand All @@ -26,15 +25,6 @@ object KTActivityManager {
fun getTopActivity():Activity{
return activities.last()
}

/**
* 打开activity
*/
inline fun <reified A : Activity> startActivity(){
var activity = getTopActivity()
var intent = Intent(activity,A::class.java)
activity.startActivity(intent)
}
/**
* 删除除最上层之外的所有activity
*/
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app', ':mvp', ':annotation', ':compiler', ':aop'
include ':app', ':mvp', ':annotation', ':compiler', ':aop', ':utils'
1 change: 1 addition & 0 deletions utils/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions utils/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.github.catch-pig'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion


defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$core_ktx_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api project(path: ':annotation')
//gson
api "com.google.code.gson:gson:$gson_version"
}
Empty file added utils/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions utils/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Loading

0 comments on commit 6e6cc7d

Please sign in to comment.