IdentifyUtil
Variables class
| Name | Description | Type | Default | Variable Type |
|---|
| JSON_RESULT | String “results” เอาไว้ตั้งค่า IdentifyCallback | String | “results” | var |
| JSON_MESSAGE | String “message” เอาไว้ตั้งค่า IdentifyCallback | String | “message” | var |
Method Overview
| Name | Description | Return |
|---|
| callIdentifyService() | สร้าง Folder file | Call< JsonObject > |
Method Details
fun callIdentifyService(apiInterface: ApiInterface ,
mapServiceUrl: String,
params: HashMap<String, Any>): Call<JsonObject>
การสร้าง Request ที่จะ Identify
Parameters
| Name | Description | Type |
|---|
| apiInterface | apiInterface ที่ใช้เรียก Service เช่น Retrofit | ApiInterface |
| mapServiceUrl | String url ของ Map Service | String |
| params | Parameters สำหรับการ Identify | HashMap< String, Any > |
Returns
| Type | Description |
|---|
| Call< JsonObject > | Return Call ที่สามารถไปสลับ Thread ต่อได้แล้วสามารถใช้ร่วมกับ IdentifyCallback ได้อีกด้วย |
Example
IdentifyUtil.callIdentifyService(apiInterface,mapUrl,params).enqueue(object :
IdentifyCallback<JsonObject>() {
override fun onSuccess(response: JsonObject) {
val features = response.get(JSON_RESULT).asJsonArray
if(features.size() != 0){ //check feture size
//feture size is not empty.
// doing something
} else {
//feature is empty.
}
}
override fun onFailure(t: Throwable) {
// handle error
}
})