package com.wisewoods.eduandroid.ui;

import android.os.Bundle;

import com.azhon.appupdate.config.UpdateConfiguration;
import com.azhon.appupdate.manager.DownloadManager;
import com.blankj.utilcode.util.AppUtils;
import com.wisewoods.base.base.BaseActivity;
import com.wisewoods.base.bean.VersionInfo;
import com.wisewoods.base.net.ApiService;
import com.wisewoods.base.net.JDCallback;
import com.wisewoods.base.utils.$;
import com.wisewoods.eduandroid.R;
import com.wisewoods.eduandroid.app.App;
import com.wisewoods.eduandroid.databinding.ActivityVersionBinding;
import com.wisewoods.eduandroid.view.AppUpdateUtils;

import retrofit2.Response;

public class VersionActivity extends BaseActivity<ActivityVersionBinding> {
    private VersionInfo.DataBean data;

    @Override
    protected void initData(Bundle savedInstanceState) {
        showBarBack(binding.bar.tvTitle, "版本信息", binding.bar.ivBack);
        binding.llVersion.setOnClickListener(v -> compareVersion());
        binding.tvVersion.setText(AppUtils.getAppVersionName());
        getData();
    }

    private void compareVersion() {
        AppUpdateUtils.compareVersion(data);
    }

    private void getData() {
        App.api.getAppInfo(ApiService.APPID).enqueue(new JDCallback<VersionInfo>() {


            @Override
            public void onS(Response<VersionInfo> response, VersionInfo versionInfo) {
                data = versionInfo.data;
                binding.tvBasicInfo.setText(versionInfo.data.basicInfo);
                binding.tvTechnical.setText(versionInfo.data.technicalSupport);
                binding.tvVersionInfo.setText(versionInfo.data.versionInfo);
            }
        });

    }
}
