@FormUrlEncoded
@POST("api/sponsors")
Call<List<SponsorsResult>> getStatesAndDistrict(
@Field("xyz") String field1
);
Call <List<SponsorsResult>> call = service.getSponsorsValue();
call.enqueue(new Callback<List<SponsorsResult>>() {
@Override
public void onResponse(Call<List<SponsorsResult>> call, Response<List<SponsorsResult>> response) {
List<SponsorsResult> rs = response.body();
}
@Override
public void onFailure(Call<List<SponsorsResult>> call, Throwable t) {
}
});
class SponsorsResult {
@SerializedName("sponsors")
private List<SponsorsValue> sponsors;
public List<SponsorsValue> getSponsors() {
return sponsors;
}
}
class SponsorsValue{
@SerializedName("leg_id")
@Expose
private String legId;
@SerializedName("type")
@Expose
private String type;
@SerializedName("name")
@Expose
private String name;
public String getLegId() {
return legId;
}
public void setLegId(String legId) {
this.legId = legId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Với những ai đã sử dụng Kotlin để phát triển ứng dụng, chắc hẳn đã không ít lần sử dụng các standard functions run, with, let, also và apply. Để hiểu và sử dụng thành thục chúng không phải là dễ. Và dưới đây là những điều đúc kết lại được. https://viblo.asia/p/su-khac-nhau-giua-let-apply-with-run-va-also-trong-kotlin-RQqKLNdml7z Scoping functions Có thể hiểu đơn giản, scoping function là phạm vi ảnh hưởng nhất định của một hàm. Nó là điều cốt lõi để phân biệt giữa các scoping functions: run, with, T.run, T.let, T.also và T.apply. Dưới đây là minh hoạ phạm vi của hàm run: fun test ( ) { var mood = "I am sad" run { val mood = "I am happy" println ( mood ) // I am happy } println ( mood ) // I am sad } Ở trên, ta có thể thấy rõ ràng trong phạm vi của hàm run, biến mood đã được định nghĩa lại trước khi in ra mà không làm ảnh hưởng tới phần khác của chương trình 3 attributes of scoping functions 1.Normal vs. extension fun...
Nhận xét
Đăng nhận xét