Skip to content

Commit

Permalink
增加Http动态代理示例,项目集成第三方网络库示例
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZhousf committed Nov 2, 2017
1 parent 1292e29 commit f00a06b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/base/http/HttpInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
*/
public interface HttpInterface {

//同步get
HttpEntity doGetSync(HttpEntity httpEntity);

//异步get
void doGetAsync(HttpEntity httpEntity,HttpCallback callback);

//同步post
HttpEntity doPostSync(HttpEntity httpEntity);

//异步post
void doPostAsync(HttpEntity httpEntity,HttpCallback callback);


Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/base/http/HttpProxyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ HttpInterface getProxy(Object targetObject) {

@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//执行前操作
doBefore(args);
Object result = method.invoke(obj, args);
//异步请求时result为空
if(result != null){
//执行后操作
doAfter((HttpEntity) result);
}
return result;
Expand Down

0 comments on commit f00a06b

Please sign in to comment.