Skip to content

Commit

Permalink
更新版本号、修改了异常处理
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxPara authored and LinuxPara committed Dec 9, 2019
1 parent 546b39b commit 7576f7f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MVP-Plugin/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>com.mvp.plugin</id>
<name>MVP_Plugin</name>
<version>1.2.8</version>
<version>1.3.0</version>
<vendor email="[email protected]" url="">陈占洋</vendor>

<description>一款MVP框架代码生成插件。帮助使用者管理V、P层的关系,取消V层继承框架内的类。</description>
Expand Down
24 changes: 19 additions & 5 deletions MvpPluginTest/MvpPluginDependent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ android {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation 'androidx.appcompat:appcompat:1.1.0'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test:runner:1.2.0'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}


task cleanJar(type: Delete) {
delete 'build/outputs/jar/MvpPluginDependent.jar'
}

task buildJar(type: Jar) {
from zipTree(file('build/intermediates/packaged-classes/release/classes.jar'))
from fileTree(dir: 'src/main', includes: ['res/**'])
baseName = 'MvpPluginDependent'
destinationDir = file('build/outputs/jar')
}

buildJar.dependsOn(cleanJar, build)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mvp.plugin.dependent.delegate;

import android.util.Log;

import com.mvp.plugin.dependent.annotation.ExecuteOn;
import com.mvp.plugin.dependent.thread.ThreadTool;

Expand Down Expand Up @@ -76,8 +78,28 @@ private Object invokeMethod(Method method, Object target, Object[] args) {
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
String exception = filterException(e);
throw new RuntimeException(exception.replace("java.lang.RuntimeException:", ""));
}
return null;
}

private String filterException(Exception e) {
StringBuffer sb = new StringBuffer();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
e.printStackTrace(pw);
} finally {
pw.close();
}
String[] exceptions = sw.toString().split("Caused by: ");
for (int i = 0; i < exceptions.length; i++) {
if (exceptions[i].startsWith("java.lang.RuntimeException:") &&
!exceptions[i].startsWith("java.lang.RuntimeException: java.lang.reflect.InvocationTargetException")) {
sb.append(exceptions[i]);
}
}
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onCreate(Bundle savedInstanceState) {
mPresenter.login("Test", "123456");
}

@ExecuteOn(thread = ThreadMode.MAIN)
// @ExecuteOn(thread = ThreadMode.MAIN)
@MVP_Itr
public void showLoginSuccess(String name) {
Log.e("chen_zhanyang", "view showLoginSuccess: thread-name:" + Thread.currentThread().getName());
Expand Down

0 comments on commit 7576f7f

Please sign in to comment.