IdentifyUtil

IdentifyUtil

Variables class

NameDescriptionTypeDefaultVariable Type
JSON_RESULTString “results” เอาไว้ตั้งค่า IdentifyCallbackString“results”var
JSON_MESSAGEString “message” เอาไว้ตั้งค่า IdentifyCallbackString“message”var

Method Overview

NameDescriptionReturn
callIdentifyService()สร้าง Folder fileCall< JsonObject >

Method Details

fun callIdentifyService(apiInterface: ApiInterface , 
                        mapServiceUrl: String, 
                        params: HashMap<String, Any>): Call<JsonObject>

การสร้าง Request ที่จะ Identify

Parameters

NameDescriptionType
apiInterfaceapiInterface ที่ใช้เรียก Service เช่น RetrofitApiInterface
mapServiceUrlString url ของ Map ServiceString
paramsParameters สำหรับการ IdentifyHashMap< String, Any >

Returns

TypeDescription
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
            }

        })