use of com.shizhefei.mvc.RequestHandle in project MVCHelper by LuckyJayce.
the class TestCaseFragment method getTestCaseDatas.
@Override
protected List<TestCaseData> getTestCaseDatas() {
List<TestCaseData> datas = new ArrayList<TestCaseData>();
TestCaseData caseData = new TestCaseData("测试登录", new LoginAsyncTask("LuckyJayce", "111"));
caseData.addParamGet(new String[] { "name", "password" }, new IAsyncTask<Map<String, String>>() {
@Override
public RequestHandle execute(ResponseSender<Map<String, String>> sender) throws Exception {
Map<String, String> map = new ArrayListMap<String, String>();
map.put("name", "nnnnn");
map.put("password", "ppppp");
sender.sendData(map);
return new RequestHandle() {
@Override
public boolean isRunning() {
return false;
}
@Override
public void cancle() {
}
};
}
});
datas.add(caseData);
datas.add(new TestCaseData("测试详情页", new BookDetailDataSource()));
datas.add(new TestCaseData("测试搜索文章", new SearchBookDataSource("Java")));
datas.add(new TestCaseData("测试文章列表", new BooksOkHttpNormal_DataSource()));
return datas;
}
use of com.shizhefei.mvc.RequestHandle in project MVCHelper by LuckyJayce.
the class MovieAmountTask2 method execute.
@Override
public RequestHandle execute(final ResponseSender<MovieAmount> sender) throws Exception {
final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
Thread.sleep(2000);
Random random = new Random();
int commentCount = random.nextInt(100);
int playCount = random.nextInt(1000) + 10;
long updateTime = System.currentTimeMillis();
sender.sendData(new MovieAmount(name, commentCount, playCount, name + " " + DateFormat.format("dd kk:mm:ss", updateTime)));
} catch (Exception e) {
e.printStackTrace();
sender.sendError(e);
}
return null;
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
asyncTask.execute();
}
return new RequestHandle() {
@Override
public void cancle() {
asyncTask.cancel(true);
}
@Override
public boolean isRunning() {
return false;
}
};
}
Aggregations