MVP基类
来源:互联网 发布:宝宝学画画软件 编辑:程序博客网 时间:2024/06/05 02:06
public class httputils { public static <T> void GetDataFormService(String url, final CallBackToPresenter callBackToPresenter, final Class<T> t) { RequestParams params = new RequestParams(); params.setUri(url); x.http().get(params, new Callback.CommonCallback<String>() { @Override public void onSuccess(String result) { Gson gson = new Gson(); T t1 = gson.fromJson(result, t); callBackToPresenter.ToPresenter(t1); } @Override public void onError(Throwable ex, boolean isOnCallback) { Log.e("Error", "onError: " + ex.getMessage()); } @Override public void onCancelled(CancelledException cex) { } @Override public void onFinished() { } }); } public interface CallBackToPresenter<T> { void ToPresenter(T t); }}
//
public class BasePresenter<T extends IMvpView> { private T t; public void SetAttachView(T t) { this.t = t; } public T getView() { return t; }}
public <T> void getDataToFrag1View(final Class<T> t) { httputils.GetDataFormService(adress, new httputils.CallBackToPresenter<T>() { @Override public void ToPresenter(T t1) { getView().CallBack(t1); } }, t);}
//
HomePresenter presenter = new HomePresenter();presenter.SetAttachView(this);presenter.getDataToView(HomeBean.class);
阅读全文
0 0
- MVP基类
- mvp基类
- MVP
- MVP
- MVP
- MVP
- MVP
- MVP
- MVP
- MVP
- mvp
- MVP
- MVP
- mvp
- MVP
- MVP
- MVP
- MVP
- apache 配置文件 http.conf解读
- 自定义属性attr的引用
- 每天5道面试题——002
- 判断网络状态
- i++与++i的结果分析
- MVP基类
- 霍尔元件 开关检测电路
- BUG:记MediaBrowserService的onLoadChildren不执行
- thinkphp 缓存数据 S方法
- JS进行人民币大小写转换
- 221. Maximal Square
- find指令常用的命令
- 小小上拉加载更多的DEMO——桃先森_
- (转)Java反射机制应用实践