我的线程代码有问题
我想从 TMDB 加载一些具有不同 id 的图像,我正在使用 Asynctask
在我的代码中加载图像:
void updateFavorite(){
try{
cursor = db.rawQuery("SELECT * FROM favorit ORDER BY _id ASC", null);
while(cursor.moveToNext()){
progressBar.setVisibility(View.VISIBLE);
String _id=cursor.getString(cursor.getColumnIndex("id_Movie"));
request = new MovieDBAsyncTask();
final String link = mv.URL+"/"+_id+"?&api_key="+mv.API_KEY;
new Thread(new Runnable() {
public void run() {
try {
request.execute(link).get(10000, TimeUnit.MILLISECONDS);
} catch (TimeoutException | ExecutionException | InterruptedException | CancellationException e) {
request.cancel(true);
test = false;
if (conn != null)
conn.disconnect();
}
}
}).start();
}
}catch (Exception e){
e.printStackTrace();
}
}