Skip to content
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
22 changes: 11 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
apply plugin: 'android-aspectjx'

android {
compileSdkVersion 22
buildToolsVersion "26.0.2"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "com.hujiang.library.demo"
minSdkVersion 14
targetSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
Expand Down Expand Up @@ -64,16 +64,16 @@ aspectjx {
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile project(':library')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation project(':library')


androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.android.support.test:runner:0.5'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:22.0.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
implementation 'com.android.support.test:runner:0.5'
implementation 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
testImplementation 'junit:junit:4.12'
}
11 changes: 6 additions & 5 deletions app/src/main/kotlin/com/hujiang/library/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.hujiang.library.demo
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.hujiang.library.aspect.TraceDelay

@TraceDelay
Expand All @@ -12,14 +13,14 @@ open class MainActivity : Activity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

findViewById(R.id.aop_ability).setOnClickListener { startActivity(Intent(this@MainActivity, AOPAbilityActivity::class.java)) }
findViewById(R.id.aop_activity).setOnClickListener {
findViewById<View>(R.id.aop_ability).setOnClickListener { startActivity(Intent(this@MainActivity, AOPAbilityActivity::class.java)) }
findViewById<View>(R.id.aop_activity).setOnClickListener {
startActivity(Intent(this@MainActivity, AOPActivity::class.java)) }
findViewById(R.id.aop_fragment).setOnClickListener {
findViewById<View>(R.id.aop_fragment).setOnClickListener {
startActivity(Intent(this@MainActivity, FragmentActivity::class.java)) }
findViewById(R.id.aop_kotlin).setOnClickListener {
findViewById<View>(R.id.aop_kotlin).setOnClickListener {
Greeter().greet() }
findViewById(R.id.aop_normal_class).setOnClickListener {
findViewById<View>(R.id.aop_normal_class).setOnClickListener {
NormalClass("normalClass").work() }

// var img : ImageView = findViewById(R.id.img_t) as ImageView
Expand Down
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "26.0.2"
buildToolsVersion '27.0.3'

defaultConfig {
minSdkVersion 14
Expand All @@ -24,8 +24,8 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'org.aspectj:aspectjrt:1.8.9'
implementation 'com.android.support:appcompat-v7:22.0.0'
implementation 'org.aspectj:aspectjrt:1.8.9'

testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,44 @@

package com.hujiang.library.aspect;

import android.util.Log;
import android.widget.Button;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

/**
* class description here
*
* @author simon
* @author Elad Ben David
* @version 1.0.0
* @since 2016-03-04
* @since 2018-09-13
*/
@Aspect
public class ViewClickAspect {


final static String TAG = ViewClickAspect.class.getSimpleName();
final static String onclickExpression = "execution(void **onClick**(..))";

@After(onclickExpression)
public void afterOnClickMethod(JoinPoint joinPoint) throws Throwable {
Log.i(TAG, "afterOnClickMethod:::" + joinPoint.getSignature());
printButtonText(joinPoint);
}

@Before(onclickExpression)
public void beforeOnClickMethod(JoinPoint joinPoint) throws Throwable {
Log.i(TAG, "beforeOnClickMethod:::" + joinPoint.getSignature());
printButtonText(joinPoint);
}

private void printButtonText(JoinPoint joinPoint){
if(joinPoint != null && joinPoint.getArgs() != null &&
joinPoint.getArgs().length == 1 && joinPoint.getArgs()[0] instanceof Button) {
Log.i(TAG, "ButtonText:::" + ((Button) joinPoint.getArgs()[0]).getText());
}
}
}