package com.android.chmo.ui.fragment.home;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.android.chmo.R;
import com.android.chmo.base.BaseFragment;
import com.android.chmo.http.HttpApi;
import com.android.chmo.utils.XUtilsImage;
import com.github.chrisbanes.photoview.PhotoView;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/8/22.
 */

public class ShowImageFragment extends BaseFragment {
    @BindView(R.id.image)
    PhotoView imageView;



    private View.OnClickListener clickListener;

    private String url;



    @Override
    public int getLayoutRes() {
        return R.layout.page_show_image;
    }

    @Override
    public void initView() {
        Bundle args = getArguments();
        if (null != args) {
            url = args.getString("url");
        }

        if (null != url) {
            XUtilsImage.display(imageView, HttpApi.getImgUrl(url), ImageView.ScaleType.CENTER, R.mipmap.def_img2);
        }
        if (null != clickListener) {
            imageView.setOnClickListener(clickListener);
        }
    }

    public void setClickListener(View.OnClickListener listener) {
        clickListener = listener;
        if (null != imageView) {
            imageView.setOnClickListener(clickListener);
        }
    }

}
