package com.sxyz.rfid.presenter.imp;

import androidx.fragment.app.Fragment;

import com.sxyz.rfid.presenter.IDictPresenter;
import com.sxyz.rfid.presenter.model.DictModel;
import com.sxyz.rfid.presenter.view.IDictView;
import com.sxyz.rfid.retrofit.config.Transformer;
import com.sxyz.rfid.retrofit.http.RetrofitUtils;
import com.sxyz.rfid.widgets.CustomProgressDialog;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @Description: 字典实现类
 * @Project: rfid-app
 * @Package: com.sxyz.rfid.ui.out
 * @author: chunyuanwu
 * @date: 2025年12月29日 16:00:58
 * @version: 1.0.0
 */
public class DictPresenterImpl implements IDictPresenter {

    private IDictView view;

    public DictPresenterImpl(IDictView view) {
        this.view = view;
    }

    @Override
    public void doDict(Fragment activity, String dictType) {
        RetrofitUtils.getInstance().getApiService().getDict(1000000000, 1, dictType).compose(Transformer.switchSchedulers(CustomProgressDialog.createLoadingDialog(activity.getActivity(), ""))).subscribe(new Observer<DictModel>() {

            @Override
            public void onSubscribe(Disposable d) {

            }

            @Override
            public void onNext(DictModel model) {
                view.dictSuccess(model);
            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
