Posts

common class for binding adapters

package com.market_place.toolBarUtil import android.annotation.SuppressLint import android.text.TextWatcher import android.util.Log import android.widget.* import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SwitchCompat import androidx.cardview.widget.CardView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.ContextCompat import androidx.databinding.BindingAdapter import androidx.databinding.ObservableBoolean import com.google.android.material.textfield.TextInputEditText import com.market_place.car_products.R import java.util.* object BindingAdapters { @BindingAdapter(value = ["switchListener"], requireAll = false ) @JvmStatic fun switchListener(switch: SwitchCompat, listener: CompoundButton.OnCheckedChangeListener) { switch.setOnCheckedChangeListener(listener) } @BindingAdapter(value = ["setEditWatcher"], requireAll = false) @JvmStatic fun setEditWatcher(editText:...

common methods for date,time

package com.market_place.car_products.utils import android.app.Activity import android.app.DatePickerDialog import android.content.Context import android.graphics.Color import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.inputmethod.InputMethodManager import androidx.appcompat.app.AlertDialog import androidx.databinding.ObservableField import com.google.firebase.Timestamp import com.market_place.car_products.databinding.AlertMessageBinding import com.market_place.car_products.databinding.IssueTitleBinding import java.text.ParseException import java.text.SimpleDateFormat import java.util.* import java.util.regex.Matcher import java.util.regex.Pattern object CommonMethods { var alertRespDialog: AlertDialog? = null fun hideSoftKeyBoard(activity: Activity) { val inputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager var view = activity.currentFocus ...

preference file

package com.market_place.preferenceFile import android.content.Context import android.content.SharedPreferences object PrefrenceFile { private lateinit var sharedPreferences: SharedPreferences private lateinit var editor: SharedPreferences.Editor private var SHARED_PREFERENCE_KEY = "Renting" private var REMEMBERME_KEY="RememberKey" fun storeRememberKey(context: Context, key: String, value: String) { sharedPreferences =context.getSharedPreferences(REMEMBERME_KEY, Context.MODE_PRIVATE) editor = sharedPreferences.edit() editor.putString(key, value) editor.apply() } fun retrieveRememberKey(context: Context, key: String):String? { sharedPreferences =context.getSharedPreferences(REMEMBERME_KEY, Context.MODE_PRIVATE) return sharedPreferences.getString(key, "") } fun clearRememberKey(context: Context) { sharedPreferences = context.getSharedPreferences(R...

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...