Skip to content

Commit fca39e7

Browse files
committed
网络取消操作测试
1 parent 8de2a9a commit fca39e7

File tree

2 files changed

+139
-76
lines changed

2 files changed

+139
-76
lines changed

app/src/main/java/org/yh/yhframe/MainActivity.java

Lines changed: 92 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,17 @@
1010
import android.widget.ImageView;
1111

1212
import org.yh.library.YHGlide;
13-
import org.yh.library.okhttp.YHRequestFactory;
14-
import org.yh.library.okhttp.callback.HttpCallBack;
1513
import org.yh.library.ui.BindView;
1614
import org.yh.library.ui.I_PermissionListener;
1715
import org.yh.library.ui.YHViewInject;
1816
import org.yh.library.utils.Constants;
1917
import org.yh.library.utils.FileUtils;
20-
import org.yh.library.utils.JsonUitl;
21-
import org.yh.library.utils.LogUtils;
2218
import org.yh.yhframe.app.MyApplication;
2319
import org.yh.yhframe.base.BaseActiciy;
24-
import org.yh.yhframe.bean.JsonLoginModel;
2520
import org.yh.yhframe.service.MyIntentService;
2621
import org.yh.yhframe.service.MyService;
2722

28-
import java.util.HashMap;
2923
import java.util.List;
30-
import java.util.Map;
3124

3225

3326
public class MainActivity extends BaseActiciy
@@ -194,79 +187,102 @@ public void initData()
194187
// }
195188
// }, TAG);
196189

197-
YHRequestFactory.getRequestManger().get("", "http://116.196.82.249:8181/login?name=youhao&pass=123456", null, new HttpCallBack()
198-
{
199-
@Override
200-
public void onSuccess(String t)
201-
{
202-
super.onSuccess(t);
203-
JsonLoginModel jsonMenuModel = JsonUitl.stringToTObject(t, JsonLoginModel.class);
204-
LogUtils.e(TAG, jsonMenuModel + "");
205-
}
206-
207-
@Override
208-
public void onFailure(int errorNo, String strMsg)
209-
{
210-
super.onFailure(errorNo, strMsg);
211-
LogUtils.e(TAG, strMsg + errorNo);
212-
}
213-
214-
@Override
215-
public void onFinish()
216-
{
217-
super.onFinish();
218-
LogUtils.e(TAG, "onFinish()");
219-
}
220-
}, TAG);
221-
222-
223-
Map<String, String> parms1 = new HashMap<>();
224-
parms1.put("code", "admin");
225-
parms1.put("password", "7c4a8d09ca3762af61e59520943dc26494f8941b");
226-
YHRequestFactory.getRequestManger().post("", "http://192.168.0.129:8181/login", null, parms1, new HttpCallBack()
227-
{
228-
@Override
229-
public void onSuccess(String t)
230-
{
231-
super.onSuccess(t);
232-
}
233-
234-
@Override
235-
public void onFailure(int errorNo, String strMsg)
236-
{
237-
super.onFailure(errorNo, strMsg);
238-
LogUtils.e(TAG, strMsg + errorNo);
239-
}
240-
241-
@Override
242-
public void onFinish()
243-
{
244-
super.onFinish();
245-
LogUtils.e(TAG, "onFinish()");
246-
}
247-
}, TAG+"1");
190+
// YHRequestFactory.getRequestManger().get("", "http://116.196.82.249:8181/login?name=youhao&pass=123456", null, new HttpCallBack()
191+
// {
192+
// @Override
193+
// public void onSuccess(String t)
194+
// {
195+
// super.onSuccess(t);
196+
// JsonLoginModel jsonMenuModel = JsonUitl.stringToTObject(t, JsonLoginModel.class);
197+
// LogUtils.e(TAG, jsonMenuModel + "");
198+
// }
199+
//
200+
// @Override
201+
// public void onFailure(int errorNo, String strMsg)
202+
// {
203+
// super.onFailure(errorNo, strMsg);
204+
// LogUtils.e(TAG, strMsg + errorNo);
205+
// }
206+
//
207+
// @Override
208+
// public void onFinish()
209+
// {
210+
// super.onFinish();
211+
// LogUtils.e(TAG, "onFinish()");
212+
// }
213+
// }, TAG);
248214

249215

250-
YHRequestFactory.getRequestManger().postString("", "http://115.159.123.101:8085/interface/terminal_profile", null, "{\"sns\":\"123456789012345\"}", new HttpCallBack()
251-
{
252-
@Override
253-
public void onSuccess(String t)
254-
{
255-
super.onSuccess(t);
256-
}
216+
// Map<String, String> parms1 = new HashMap<>();
217+
// parms1.put("code", "admin");
218+
// parms1.put("password", "7c4a8d09ca3762af61e59520943dc26494f8941b");
219+
// YHRequestFactory.getRequestManger().post("", "http://192.168.0.129:8181/login", null, parms1, new HttpCallBack()
220+
// {
221+
// @Override
222+
// public void onSuccess(String t)
223+
// {
224+
// super.onSuccess(t);
225+
// }
226+
//
227+
// @Override
228+
// public void onFailure(int errorNo, String strMsg)
229+
// {
230+
// super.onFailure(errorNo, strMsg);
231+
// LogUtils.e(TAG, strMsg + errorNo);
232+
// }
233+
//
234+
// @Override
235+
// public void onFinish()
236+
// {
237+
// super.onFinish();
238+
// LogUtils.e(TAG, "onFinish()");
239+
// }
240+
// }, TAG+"1");
257241

258-
@Override
259-
public void onFailure(int errorNo, String strMsg)
260-
{
261-
super.onFailure(errorNo, strMsg);
262-
}
263242

264-
@Override
265-
public void onFinish()
266-
{
267-
super.onFinish();
268-
}
269-
},TAG);
243+
// YHRequestFactory.getRequestManger().postString("", "http://115.159.123.101:8085/interface/terminal_profile", null, "{\"sns\":\"123456789012345\"}", new HttpCallBack()
244+
// {
245+
// @Override
246+
// public void onSuccess(String t)
247+
// {
248+
// super.onSuccess(t);
249+
// }
250+
//
251+
// @Override
252+
// public void onFailure(int errorNo, String strMsg)
253+
// {
254+
// super.onFailure(errorNo, strMsg);
255+
// }
256+
//
257+
// @Override
258+
// public void onFinish()
259+
// {
260+
// super.onFinish();
261+
// }
262+
// },TAG);
263+
// YHRequestFactory.getRequestManger().get("", "http://192.168.0.129:8181/patient/info?patient_id=802040&department_id=125", null, new HttpCallBack()
264+
// {
265+
// @Override
266+
// public void onSuccess(String t)
267+
// {
268+
// super.onSuccess(t);
269+
// LogUtils.e(TAG,t);
270+
// }
271+
//
272+
// @Override
273+
// public void onFailure(int errorNo, String strMsg)
274+
// {
275+
// super.onFailure(errorNo, strMsg);
276+
// LogUtils.e(TAG,errorNo + " " + strMsg);
277+
// }
278+
//
279+
// @Override
280+
// public void onFinish()
281+
// {
282+
// super.onFinish();
283+
// LogUtils.e(TAG,"onFinish()");
284+
// }
285+
// },TAG);
270286
}
271287

272288
public String convert(String utfString)

app/src/main/java/org/yh/yhframe/OneFragment.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import android.view.ViewGroup;
88
import android.widget.TextView;
99

10+
import org.yh.library.okhttp.OkHttpUtils;
11+
import org.yh.library.okhttp.YHRequestFactory;
12+
import org.yh.library.okhttp.callback.HttpCallBack;
1013
import org.yh.library.ui.BindView;
1114
import org.yh.library.ui.YHViewInject;
1215
import org.yh.library.utils.LogUtils;
@@ -54,6 +57,43 @@ protected void initData()
5457
shadeColors = new int[]{
5558
Color.argb(100, 255, 86, 86), Color.argb(15, 255, 86, 86),
5659
Color.argb(0, 255, 86, 86)};
60+
61+
YHRequestFactory.getRequestManger().get("", "http://192.168.0.129:8181/patient/info?patient_id=802040&department_id=125", null, new HttpCallBack()
62+
{
63+
@Override
64+
public void onSuccess(String t)
65+
{
66+
super.onSuccess(t);
67+
LogUtils.e(TAG,t);
68+
}
69+
70+
@Override
71+
public void onFailure(int errorNo, String strMsg)
72+
{
73+
super.onFailure(errorNo, strMsg);
74+
LogUtils.e(TAG,errorNo + " " + strMsg);
75+
}
76+
77+
@Override
78+
public void onFinish()
79+
{
80+
super.onFinish();
81+
LogUtils.e(TAG,"onFinish()");
82+
outsideAty.runOnUiThread(new Runnable()
83+
{
84+
@Override
85+
public void run()
86+
{
87+
// 设置折线数据
88+
mLineChartView.setItems(mItems);
89+
// 设置渐变颜色
90+
mLineChartView.setShadeColors(shadeColors);
91+
// 开启动画
92+
mLineChartView.startAnim(mLineChartView, 2000);
93+
}
94+
});
95+
}
96+
},TAG);
5797
}
5898

5999
@Override
@@ -104,4 +144,11 @@ protected void onMenuClick()
104144
super.onMenuClick();
105145
YHViewInject.create().showTips("菜单键");
106146
}
147+
148+
@Override
149+
public void onDestroyView()
150+
{
151+
super.onDestroyView();
152+
OkHttpUtils.getInstance().cancelTag(TAG);
153+
}
107154
}

0 commit comments

Comments
 (0)