• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProxyBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.dx.stock.ProxyBuilder的典型用法代码示例。如果您正苦于以下问题:Java ProxyBuilder类的具体用法?Java ProxyBuilder怎么用?Java ProxyBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProxyBuilder类属于com.android.dx.stock包,在下文中一共展示了ProxyBuilder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
/**
 * 生成代理
 *
 * @return
 */
public T create() {
    ProxyBuilder<T> proxy = ProxyBuilder.forClass(superClazz);
    if (constructorArgTypes != null && constructorArgValues != null && constructorArgValues.length == constructorArgTypes.length) {
        proxy.constructorArgTypes(constructorArgTypes).constructorArgValues(constructorArgValues);
    }
    proxy.handler(this);
    proxy.dexCache(mCacheDir);
    try {
        return proxy.build();
    } catch (IOException e) {
        Logger.i("app", "error" + e.getClass() + "");
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:DIY-green,项目名称:AndroidStudyDemo,代码行数:21,代码来源:Enhancer.java


示例2: stub

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
private static Object stub(Class klass) {
  try {
    InvocationHandler handler =
        new InvocationHandler() {
          @Override
          public Object invoke(Object project, Method method, Object[] args) {
            return null;
          }
        };

    if (klass.isInterface()) {
      return Proxy.newProxyInstance(klass.getClassLoader(), new Class[] {klass}, handler);
    } else {
      return ProxyBuilder.forClass(klass).handler(handler).build();
    }
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:facebook,项目名称:screenshot-tests-for-android,代码行数:20,代码来源:WindowAttachment.java


示例3: invoke

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    try {
        // 忽略方法,则直接调用原来的方法
        for (Method m : ignoreMethods) {
            if (m.equals(method)) {
                return ProxyBuilder.callSuper(proxy, method, args);
            }
        }

        if (proxy instanceof BasePresenter) {
            final IView v = ((BasePresenter) proxy).mView;
            if (v == null) {
                Log.w(TAG, "view didn't attach or has detached");
                return null;
            }
        }

        return ProxyBuilder.callSuper(proxy, method, args);
    } catch (NullPointerException e) {
        // 忽略因为耗时操作之后对已回收 view 进行调用而产生的空指针异常
        if (proxy instanceof BasePresenter) {
            if (((BasePresenter) proxy).mView == null) {
                Log.w(TAG, "please stop background task when view has detached. ignore this exception");
                return null;
            }
        }

        // 其他原因的空指针异常,正常抛出
        throw e;
    }
}
 
开发者ID:JeremyHe-cn,项目名称:Mvp,代码行数:33,代码来源:PresenterFactory.java


示例4: invoke

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (filter == null) {
        return null;
    }
    int accept = filter.accept(method);
    if (accept >= callBacks.length) {
        return null;
    }
    if (method.getName().equals("hashCode") || method.getName().equals("toString")) {
        return ProxyBuilder.callSuper(proxy, method, args);
    }
    return callBacks[accept].intercept(proxy, method, args);
}
 
开发者ID:DIY-green,项目名称:AndroidStudyDemo,代码行数:15,代码来源:Enhancer.java


示例5: callRealMethod

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
@Override
public Object callRealMethod() throws Throwable {
    if (Modifier.isAbstract(method.getModifiers())) {
        throw cannotCallAbstractRealMethod();
    }
    return ProxyBuilder.callSuper(proxy, method, rawArgs);
}
 
开发者ID:linkedin,项目名称:dexmaker,代码行数:8,代码来源:InvocationHandlerAdapter.java


示例6: intercept

import com.android.dx.stock.ProxyBuilder; //导入依赖的package包/类
@Override
public Object intercept(final Object proxy, final Method method, final Object[] args) throws Throwable {
    final AsyncMethod asyncMethod = method.getAnnotation(AsyncMethod.class);

    if (asyncMethod != null) {
        switch (asyncMethod.methodType()) {
            case atom:
                if (methodHashSet.contains(method.getName())) {
                    return null;
                } else {
                    methodHashSet.add(method.getName());
                }
            default:
                break;
        }

        if (asyncMethod.withDialog()) {
            mMethodCallBack.showDialog();
        }
        if (asyncMethod.withCancelableDialog()) {
            mMethodCallBack.showCancelableDialog();
        }

        pool.execute(new Runnable() {
            @Override
            public void run() {
                Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
                try {
                    dealWithResult(getResult());
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }

            private Object getResult() throws Throwable {
                Object obj = null;
                switch (asyncMethod.methodType()) {
                    case normal:
                        obj = ProxyBuilder.callSuper(proxy, method, args);
                        break;
                    case atom:
                        obj = ProxyBuilder.callSuper(proxy, method, args);
                        methodHashSet.remove(method.getName());
                        break;
                    default:
                        break;
                }
                return obj;
            }

            private void dealWithResult(Object result) {
                if (asyncMethod.withDialog() || asyncMethod.withCancelableDialog()) {
                    mMethodCallBack.hideDialog();
                }

                if (result != null && result.getClass() == Message.class) {
                    Message msg = (Message) result;
                    switch (msg.arg1) {
                        case MessageArg.ARG1.TOAST_MESSAGE:
                            break;
                        case MessageArg.ARG1.CALL_BACK_METHOD:
                            if (msg.obj == null || !(msg.obj instanceof String) || "".equals(msg.obj.toString().trim())) {
                                msg.obj = method.getName() + "CallBack";
                            }
                        default:
                            break;
                    }
                    mMethodCallBack.sendMessage(msg);
                }
            }

        });
        return null;
    } else {
        return ProxyBuilder.callSuper(proxy, method, args);
    }
}
 
开发者ID:DIY-green,项目名称:AndroidStudyDemo,代码行数:78,代码来源:AsyncMethodAtomInterceptor.java



注:本文中的com.android.dx.stock.ProxyBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PsiPackageManager类代码示例发布时间:2022-05-22
下一篇:
Java LogisticRegressionWithSGD类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap