Posts

Showing posts from April, 2022

Retrofit service 2

package com.example.retrofit2 import android.content.Context import android.util.Log import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory import com.kaopiz.kprogresshud.KProgressHUD import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import okhttp3.OkHttpClient import okhttp3.ResponseBody import org.json.JSONObject import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit class RetrofitService() { private var kProgressHUD: KProgressHUD? = null lateinit var context: Context fun callService( mContext: Context, dialogFlag: Boolean, token: String, requestProcessor: RetrofitResponse ) { try { context = mContext if (dialogFlag) { createProgressBar(mContext) } ...

retrofit response

package com.guidingu24x7.retrofit interface RetrofitResponse { suspend fun sendRequest(retrofitApi: RetrofitApi):T fun onResponse(res: T) fun onException(message: String?) fun onError(error:String){} }

Retrofit api Response

interface RetrofitApi { @Multipart @POST(WebApiKeys.USER_SIGN_UP) suspend fun userSignUp( @Part("name") name: RequestBody, @Part("email") email: RequestBody, @Part("phone_no") phone_no : RequestBody, @Part("state") state: RequestBody, @Part("city") city: RequestBody, @Part("street_no") street_no: RequestBody, @Part("pincode") pincode: RequestBody, @Part("date_of_birth") date_of_birth: RequestBody, @Part("gender") gender: RequestBody, @Part("password") password: RequestBody, @Part("latitude") latitude: RequestBody, @Part("longitude") longitude: RequestBody, @Part("country") country: RequestBody, @Part("device_token") deviceToken: RequestBody, @Part("device_id") deviceId: RequestBody, @Part("devi...