update 优化下写法

This commit is contained in:
2024-04-22 13:14:11 +08:00
parent 0d65df5271
commit be685a3745
4 changed files with 45 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.yutou.netlibs.http.HttpBody;
import com.yutou.netlibs.http.HttpCallback;
import java.util.List;
@@ -21,25 +22,25 @@ public class MainActivity extends AppCompatActivity {
findViewById(R.id.button)
.setOnClickListener(v -> {
Api.getInstance().getList("")
.enqueue(new Callback<HttpBody<List<Password>>>() {
.enqueue(new HttpCallback<List<Password>>() {
@Override
public void onResponse(Call<HttpBody<List<Password>>> call, Response<HttpBody<List<Password>>> response) {
System.out.println("response = " + response.body().getData());
public void onResponse(int code, String status, List<Password> response) {
System.out.println("code = " + code + ", status = " + status + ", response = " + response);
}
@Override
public void onFailure(Call<HttpBody<List<Password>>> call, Throwable t) {
public void onFailure(Throwable throwable) {
}
});
Api.getInstance().getVersion().enqueue(new Callback<HttpBody<Bean>>() {
Api.getInstance().getVersion().enqueue(new HttpCallback<Bean>() {
@Override
public void onResponse(Call<HttpBody<Bean>> call, Response<HttpBody<Bean>> response) {
System.out.println("response = " + response.body().getData());
public void onResponse(int code, String status, Bean response) {
System.out.println("code = " + code + ", status = " + status + ", response = " + response);
}
@Override
public void onFailure(Call<HttpBody<Bean>> call, Throwable t) {
public void onFailure(Throwable throwable) {
}
});