我最近开始使用改造库..长话短说,我的UI正在冻结,直到所有改装调用完成..
如果您使用异步任务,那么在改造的地方要注意那么UI没有问题就没有冻结......
我试着在背景中调用改造方法,没有变化...... 也尝试在线程中调用它..没有变化..
ui之间的包含一个自定义进度条,应该继续运行..
那么如何消除滞后? 改造代码
public static ApiClientInterface mainUrl() {
if (apiClientInterface == null) {
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(
"http://projects.quinoid.com").build();
// common.php?&status=
apiClientInterface = restAdapter.create(ApiClientInterface.class);
}
public interface ApiClientInterface {
@GET("/LTFoods/json/common.php")
void getCategories(@Query("status") String status,
@Query("viewset") String viewset,
@Query("currentdate") String date,
Callback<CategoriesModel> callback);
}
这是最终代码..使用线程..
private void threads(String date, String login,
Context activityContext){
final String currentDate = date;
final String loginOne = login;
final Context activityContexT = activityContext;
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.Categories(currentDate, activityContexT, false);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.Directors(activityContexT, currentDate);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.CorporateAddress(activityContexT, currentDate);
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
URL_Retrofit.DistributorDetails(activityContexT, loginOne,
currentDate);
}
}).start();
}