ImageLoader.Class
{
BitmapDisplayer bd=new BitmapDisplayer(bmp, photoToLoad);
Activity a=(Activity)photoToLoad.imageView.getContext();
a.runOnUiThread(bd);
}
class BitmapDisplayer implements Runnable
{
Bitmap bitmap;
PhotoToLoad photoToLoad;
public BitmapDisplayer(Bitmap b, PhotoToLoad p){bitmap=b;photoToLoad=p;}
public void run()
{
if(imageViewReused(photoToLoad)) {
Log.d("A","Returning");
return;
}
if(bitmap!=null) {
Log.d("A","Setting Image");
photoToLoad.imageView.setImageBitmap(bitmap);
}
else {
Log.d("A","Setting ICON");
photoToLoad.imageView.setImageResource(stub_id);
}
Log.d("A","we are in ui thread");
}
}
MainActivity.class
public class Main_Menu_Activity extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener{
}
但是当我在MainActivity中通过“扩展活动”替换“扩展APPCOMPACTACTIVTY”时,THREAD - “BitmapDisplayer”执行得很精细。