package com.tjzhxx.union.system;


import android.text.TextUtils;
import android.view.View;

import androidx.fragment.app.Fragment;

import com.google.android.material.snackbar.Snackbar;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

/**
 * 描述:
 *
 * @author yanghuaxiong
 * @create 2018/4/10 上午11:32
 */
public abstract class BaseFragment extends Fragment {

//    @Nullable
//    @BindView(R.id.ll_entity)
//    LinearLayout llEntity;
//    @Nullable
//    @BindView(R.id.tv_empty)
//    TextView tv_empty;

    public void showSnackBar(View topView, String msg) {
        if (null != msg && !TextUtils.isEmpty(msg)) {
            Snackbar.make(topView, msg, Snackbar.LENGTH_SHORT).show();
        }
    }

    public void showSnackBar(String msg) {
        if (null != msg && !TextUtils.isEmpty(msg)) {
            Snackbar.make(getActivity().getWindow().getDecorView(), msg, Snackbar.LENGTH_SHORT).show();
        }
    }

    public void showProgressBar(String message) {

        HodingView.build().setContext(getActivity()).show(message);
    }

    public void hideProgressBar() {
        HodingView.build().hide();
    }


    //刷新完成以后刷新处理  防止以后改动
    public void refreshComplete(SmartRefreshLayout refreshLayout, Boolean isHasMore) {
        if (refreshLayout.isRefreshing()) {
            refreshLayout.finishRefresh();
        } else if (refreshLayout.isLoading()) {
            if (isHasMore) {
                refreshLayout.finishLoadMore();
            }
        }
        if (isHasMore) {
            refreshLayout.setNoMoreData(false);
        } else {
            refreshLayout.finishLoadMoreWithNoMoreData();
        }
    }

    public void refreshError(SmartRefreshLayout refreshLayout) {
        if (refreshLayout.isRefreshing()) {
            refreshLayout.finishRefresh();
        } else if (refreshLayout.isLoading()) {
            refreshLayout.finishLoadMore();
        }
    }
//
//    //设置空页面
//    public void setEntityView(LinearLayout cotent,Boolean isEntity) {
//        if (isEntity) {
//            if (llEntity != null && cotent != null) {
//                cotent.setVisibility(View.GONE);
//                llEntity.setVisibility(View.VISIBLE);
//            }
//
//        } else {
//            if (llEntity != null && cotent != null) {
//                cotent.setVisibility(View.VISIBLE);
//                llEntity.setVisibility(View.GONE);
//            }
//
//        }
//    }
//
//    //设置空页面
//    public void setEntityView(SmartRefreshLayout refreshLayout, Boolean isEntity) {
//        if (isEntity) {
//            if (refreshLayout != null && llEntity != null) {
//                refreshLayout.setVisibility(View.GONE);
//                llEntity.setVisibility(View.VISIBLE);
//            }
//        } else {
//
//            if (refreshLayout != null && llEntity != null) {
//                refreshLayout.setVisibility(View.VISIBLE);
//                llEntity.setVisibility(View.GONE);
//            }
//        }
//    }
//
//    //设置空页面
//    public void setEntityView(SmartRefreshLayout refreshLayout, String tvEntity, Boolean isEntity) {
//        if (isEntity) {
//            if (refreshLayout != null && llEntity != null) {
//                refreshLayout.setVisibility(View.GONE);
//                llEntity.setVisibility(View.VISIBLE);
//                tv_empty.setText(tvEntity);
//            }
//        } else {
//
//            if (refreshLayout != null && llEntity != null) {
//                refreshLayout.setVisibility(View.VISIBLE);
//                llEntity.setVisibility(View.GONE);
//            }
//        }
//    }
}
