如何使用 Retrofit 库处理 onResponse 方法?

How to handle onResponse method by using Retrofit library?

我正在使用改造 library.I 创建了一个 class,我在其中从其他 class 获取特定 ID 的值,我想获取该 ID 的特定列表但在 onResponse() 方法中出现错误。我以 json 格式签入了邮递员列表正在获取......但不是在这里!

public class Main2Activity extends AppCompatActivity implements Callback<MailChimpEmailResponse> {

    public String idReceived;
    List<MailChimpEmailResponseSecond> emailList = new ArrayList<>();
    private RecyclerView recyclerViewSecond;

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

        Call<MailChimpEmailResponse> call = MailChimpAPIClient.getClient().fetchMembers(idReceived,"efb918ee88a3a8a77-us15" );
        call.enqueue(this);

    }
    @Override
    public void onResponse(Call<MailChimpEmailResponse> call, Response<MailChimpEmailResponse> response) {
    Log.d("ashu", "null response");
        Intent intent = getIntent();
        idReceived = intent.getStringExtra("id_value");
        Log.d("ashu", "id received is: " + idReceived);

        MailChimpEmailResponse listResponse = response.body();

        for (MailChimpEmailResponseSecond list : listResponse.emailLists) {

            Log.d("ashu", list.getEmailListName());
            this.emailList = listResponse.emailLists;

        }

        recyclerViewSecond = (RecyclerView) findViewById(R.id.my_recycler_view_second);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerViewSecond.setLayoutManager(linearLayoutManager);
        EmailAdapter adapter = new EmailAdapter(this.emailList);
        recyclerViewSecond.setAdapter(adapter);
        adapter.notifyDataSetChanged();

    }

    @Override
    public void onFailure(Call<MailChimpEmailResponse> call, Throwable t) {

    }
}

我的apiclass:

public interface MailChimpApi {


    @GET("lists")
    public Call<MailChimpListResponse> fetchLists(@Query("apikey") String apikey, @Query("offset") int offset, @Query("count") int count);


    @GET("lists/{list_id}/members")
   public Call<MailChimpEmailResponse> fetchMembers(@Path("list_id") String listId,@Query("apikey") String apikey);
}

我的json:

{
  "members": [
    {
      "id": "04d80020e78edd86a79eda",
      "email_address": "ashuingh.02046547@gmail.com",
      "unique_email_id": "784c772918",
      "email_type": "html",
      "status": "subscribed",
      "merge_fields": {
        "FNAME": "Ashsdjssh",
        "LNAME": "kudjskjar"
      },

我认为下面这行应该在 onCreate 方法而不是 onResponse 中,

idReceived = intent.getStringExtra("id_value");