allow games to load in parallel, and when another async task is

running. This is fairly high-risk -- Google runs one AsyncTask at a
time because people get themselves in trouble otherwise -- but without
it the games don't load until the initial dict-fetch task finishes.
This commit is contained in:
Eric House 2015-06-03 07:49:52 -07:00
parent 22add3fefd
commit 23e6f97778

View file

@ -27,10 +27,10 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.View;
import java.util.concurrent.LinkedBlockingQueue;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -39,6 +39,7 @@ import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.concurrent.LinkedBlockingQueue;
import junit.framework.Assert;
@ -121,7 +122,14 @@ public class GameListItem extends LinearLayout
// AsyncTask, so let it complete, but drop the results as soon
// as we're back on the UI thread.
++m_loadingCount;
new LoadItemTask().execute();
LoadItemTask task = new LoadItemTask();
if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
// Actually run these in parallel if the OS supports it
task.executeOnExecutor( AsyncTask.THREAD_POOL_EXECUTOR );
} else {
task.execute();
}
}
public void invalName()