Fixed a threading bug in ImageDownloadTask
This commit is contained in:
parent
3643a92499
commit
5711421784
@ -10,6 +10,8 @@ import android.support.annotation.NonNull;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import com.anthonycr.bonsai.Schedulers;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -146,17 +148,12 @@ public class ImageDownloadTask extends AsyncTask<Void, Void, Bitmap> {
|
|||||||
final Bitmap fav = Utils.padFavicon(bitmap);
|
final Bitmap fav = Utils.padFavicon(bitmap);
|
||||||
final ImageView view = mFaviconImage.get();
|
final ImageView view = mFaviconImage.get();
|
||||||
if (view != null && view.getTag().equals(mWeb.getUrl().hashCode())) {
|
if (view != null && view.getTag().equals(mWeb.getUrl().hashCode())) {
|
||||||
Context context = view.getContext();
|
Schedulers.main().execute(new Runnable() {
|
||||||
if (context instanceof Activity) {
|
@Override
|
||||||
((Activity) context).runOnUiThread(new Runnable() {
|
public void run() {
|
||||||
@Override
|
view.setImageBitmap(fav);
|
||||||
public void run() {
|
}
|
||||||
view.setImageBitmap(fav);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
view.setImageBitmap(fav);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mWeb.setBitmap(fav);
|
mWeb.setBitmap(fav);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user