public class InfoLoadPresenterImpl implements InfoLoadPresenter {
private InfoLoadView ilv;
private Handler handler;
@SuppressLint("HandlerLeak")
@Override
public void infoLoad() {
ilv.infoLoadStart();
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what)
{
case 1:
ilv.infoLoadSuccess((Customer) msg.obj);
break;
}
}
};
new Thread(new Runnable() {
@Override
public void run() {
String str;
try {
... ...
} catch (Exception e) {
e.printStackTrace();
}
Message message = new Message();
Gson gson = App.getGson();
Customer customer = gson.fromJson(body.toString(),Customer.class);
message.what = 1;
message.obj = customer;
handler.sendMessage(message);
}
}).start();
}
}
//需要理解 代码区 静态变量区 堆区 栈区 和 java引用才能理解的代码
转载于:https://www.cnblogs.com/l-h-h/p/10335826.html