package com.example.administrator.zhapp.activity.ydckgl;

import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.WindowManager;

import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.utils.HttpListener;
import com.example.administrator.zhapp.utils.NohttpUtils;
import com.yolanda.nohttp.NoHttp;
import com.yolanda.nohttp.rest.Request;
import com.yolanda.nohttp.rest.Response;
import uk.co.senab.photoview.PhotoView;

public class CKPhotoActivity extends AppCompatActivity {

    PhotoView photoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置全屏显示
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_ckphoto);
        photoView = findViewById(R.id.photoView);
        requestImage();

    }

    private void requestImage() {

        String url = getIntent().getStringExtra("url");

        Request<Bitmap> bitmapRequest = NoHttp.createImageRequest(url);
        NohttpUtils.getInstance().add(CKPhotoActivity.this, 2, bitmapRequest, new HttpListener<Bitmap>() {
            @Override
            public void onSucceed(int what, Response<Bitmap> response) {

                Bitmap bitmap = response.get();
                if (bitmap != null) {
                    photoView.setImageBitmap(bitmap);
                }
            }

            @Override
            public void onFailed(int what, Response<Bitmap> response) {

            }
        }, true, true, "加载图片中...");
    }
}
