Skip to content

Commit

Permalink
Использовать ThreadPool для обращение к б/д
Browse files Browse the repository at this point in the history
  • Loading branch information
sadr0b0t committed Oct 4, 2020
1 parent 23a309e commit 7bdc1b8
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class VideoItemPagedListAdapter extends PagedListAdapter<VideoItem, Video
private OnListItemSwitchListener<VideoItem> onItemSwitchListener;
private int orientation = ORIENTATION_VERTICAL;

private ExecutorService dbQueryExecutor = Executors.newFixedThreadPool(10);
private ExecutorService thumbLoaderExecutor = Executors.newFixedThreadPool(10);


Expand Down Expand Up @@ -159,7 +160,7 @@ public void onBindViewHolder(@NonNull final VideoItemViewHolder holder, final in
if(item.getPlaylistInfo() != null) {
holder.playlistTxt.setText(item.getPlaylistInfo().getName());
} else {
new Thread(new Runnable() {
dbQueryExecutor.execute(new Runnable() {
@Override
public void run() {
final VideoDatabase videodb = VideoDatabase.getDb(context);
Expand All @@ -175,7 +176,7 @@ public void run() {
});
}
}
}).start();
});
}
}

Expand Down

0 comments on commit 7bdc1b8

Please sign in to comment.