-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the ProjectArchitecture_MT wiki!
- Api Call
- Recyclerview
- App Permission
- Database
- SharedPreferenceUtility
- Sqlite Database
- MyLog
- ViewPagerAdapter
- ApplicationOperations
- BannerAdInListUtility
- BannerAdUtility
- CustomAlertDialogWithBannerAd
- ListDialog
- CircleImageView
- RateThisApp (Rate Dialog)
- TextDrawable (Text to Image)
- MySnackbar
- CustomAlertDialog (One-Two Button)
- DatePickerDialogUtility
- DateUtility
- FileUtility
- FirebasePhoneAuthentication
- ImagePickerUtility
- ImageUtility
- IntentUtility
- KeyboardUtility
- LocaleManager
- NetworkUtility
- NotificationUtility
- StringUtility
- ValidatorUtility
- jsonschema2pojo Plugin
Add this Dependencies.
` // retrofit, gson
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
`
Step-1 Create Application Class and add it to Manifest file. `class AppClass : Application() {
override fun onCreate() {
super.onCreate()
AppConfig().projectSetUp(applicationContext)
}
}`
Step-2 Now add this class in AndroidManifest.xml file.
android:name=".AppClass"
Step-3 Create AppConfig Class. ` class AppConfig {
val REQUEST_REGISTER_USER = 2
fun projectSetUp(context: Context) {
ApiCall.BASE_URL = "http://localhost/p2j/api/Master/"
ApiCall.HEADER_MAP = getHeader()
ApiCall.LOADING_TITLE = "Title for Loading Dialog" // set Loading Title when api call shows the loading dialog.
ApiCall.LOADING_DIALOG_SHOW = true // true or false: if you want to show loading dialog when api calling
ApiCall.INTERNET_DIALOG_SHOW = true // true or false: if you want to show no internet dialog when internet goes and user tries to api call.
ApiCall.HANDLE_STATUS = true // true or false: if you want to handle status automatically then set true or else pass false it gives directly response.
ApiCall.FILE_DOWNLOAD_PATH = Environment.getExternalStorageDirectory().path // when we downloading file then set file path to save file at particular location.
//map.put("ClassName", arrayOf("URL","METHOD","REQUEST CODE"))
map.put("RegisterReq", arrayOf("register_user", ApiCall.RequestType.POST, AppConfig().REQUEST_REGISTER_USER))
}
private fun getHeader(): HashMap<String, Any> {
val map = HashMap<String, Any>()
map["x-api-key"] = "368405e7872ffea848b6603ebdd455e2"
map["Authorization"] = "Basic d2luQGluZm86I3dpbjEyMw=="
return map
}
fun getRequestparams(classObject: Any): Array<Any> {
val enclosingClass = classObject.javaClass
val className = enclosingClass.simpleName
return map.get(className)!!
}
companion object {
val map = HashMap<String, Array<Any>>()
}
} `
Step-4 Create Api Call. ` // 1. Post(raw) Api Call val registerReq = RegisterReq() // Create Request Class Object registerReq.name = tiedt_name.text.toString() // set data to request class
// Now do the api call // ApiCall(context, AppConfig().getRequestparams(class_object), class_object, webServiceType, listener). ApiCall(this, AppConfig().getRequestparams(registerReq), registerReq, ApiCall.WebServiceType.WS_SIMPLE, object : ApiCall.RetrofitResponseListener{ override fun onSuccess(response: String?, apiRequestCode: Int) {
}
override fun onFailure(t: Throwable, apiRequestCode: Int) {
}
}) `