package com.bbitcn.silk.ui.activity;

import android.app.Application;

import androidx.annotation.NonNull;

import com.bbitcn.silk.base.BasePresenter;
import com.bbitcn.silk.model.net.AllType;
import com.bbitcn.silk.utils.database.AllTypeDataBase;
import com.bbitcn.silk.utils.network.Url;
import com.bbitcn.silk.utils.network.XHttpManager;
import com.bbitcn.silk.utils.network.XHttpShorthand;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * @Author DuanKaiji
 * @CreateTime 2024年3月28日 10:06:01
 */
public class KindsActivityPresenter extends BasePresenter {

    public KindsActivityPresenter(@NonNull Application application) {
        super(application);
    }

    /**
     * 查询所有收购类型
     */
    public void getAllType() {
        showLoadingDialog("正在获取所有茧别");
        RequestParams params = XHttpManager.getInstance().getRequestParams(Url.getAllType);
        x.http().get(params, new XHttpShorthand<AllType>() {
            @Override
            public void success(AllType model) {
                if (model.getResult()) {
                    AllTypeDataBase.setAllType(model.getData());
                } else {
                    errorTips(model.getMsg());
                }
            }

            @Override
            public void error(Throwable e) {

            }

            @Override
            public void myFinish() {
                super.myFinish();
                hideLoadingDialog();
            }
        });
    }
}
