Search in sources :

Example 1 with BitmapCallback

use of com.zhy.http.okhttp.callback.BitmapCallback in project okhttputils by hongyangAndroid.

the class MainActivity method getImage.

public void getImage(View view) {
    mTv.setText("");
    String url = "http://images.csdn.net/20150817/1.jpg";
    OkHttpUtils.get().url(//
    url).tag(//
    this).build().connTimeOut(20000).readTimeOut(20000).writeTimeOut(20000).execute(new BitmapCallback() {

        @Override
        public void onError(Call call, Exception e, int id) {
            mTv.setText("onError:" + e.getMessage());
        }

        @Override
        public void onResponse(Bitmap bitmap, int id) {
            Log.e("TAG", "onResponseļ¼šcomplete");
            mImageView.setImageBitmap(bitmap);
        }
    });
}
Also used : BitmapCallback(com.zhy.http.okhttp.callback.BitmapCallback) Call(okhttp3.Call) Bitmap(android.graphics.Bitmap)

Aggregations

Bitmap (android.graphics.Bitmap)1 BitmapCallback (com.zhy.http.okhttp.callback.BitmapCallback)1 Call (okhttp3.Call)1