package com.maniu.mn_2020_11_26;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.maniu.http.IJsonListenner;
import com.maniu.http.MnHttp;

public class MainActivity extends AppCompatActivity {
    String url = "https://v.juhe.cn/historyWeather/citys";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void sendMessage(View view) {
        for(int x=0;x<100;x++){
            RequestBean requestBean = new RequestBean("2", "'bb52107206585ab074f5e59a8c73875b");
            final int finalX = x;
            MnHttp.sendMessage(url,requestBean, ResponseBean.class, new IJsonListenner<ResponseBean>() {
                @Override
                public void onSuccess(ResponseBean responseBean) {
                    Log.e("MN--------------请求次数："+ finalX,"我成功了"+
                            responseBean.getResultcode()+"------>"+responseBean.getError_code());
                }

                @Override
                public void onFaild() {
                    Log.e("MN--------------失败了"+ finalX,"三次机会都用完了，宣布失败");
                }
            });
        }
    }
}
