Browse Source

step

PankajBranch
pankaj 2 years ago
parent
commit
06aded85e0
7 changed files with 73 additions and 5 deletions
  1. +13
    -0
      app/src/main/java/com/nivesh/production/bajajfd/BajajApplication.kt
  2. +5
    -0
      app/src/main/java/com/nivesh/production/bajajfd/adapter/CustomerListAdapter.kt
  3. +39
    -1
      app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt
  4. +2
    -0
      app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFourBajajFDFragment.kt
  5. +6
    -0
      app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt
  6. +5
    -1
      app/src/main/res/layout/fragment_bajajfd_step_four.xml
  7. +3
    -3
      app/src/main/res/layout/item_customer_list_preview.xml

+ 13
- 0
app/src/main/java/com/nivesh/production/bajajfd/BajajApplication.kt View File

@ -1,6 +1,7 @@
package com.nivesh.production.bajajfd package com.nivesh.production.bajajfd
import android.app.Application import android.app.Application
import android.content.Context
class BajajApplication : Application() { class BajajApplication : Application() {
private var mInstance: BajajApplication? = null private var mInstance: BajajApplication? = null
@ -9,10 +10,22 @@ class BajajApplication : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
mInstance = this; mInstance = this;
appContext = applicationContext
} }
@Synchronized @Synchronized
fun getInstanceApp(): BajajApplication? { fun getInstanceApp(): BajajApplication? {
return mInstance return mInstance
} }
companion object {
lateinit var appContext: Context
}
} }

+ 5
- 0
app/src/main/java/com/nivesh/production/bajajfd/adapter/CustomerListAdapter.kt View File

@ -3,6 +3,7 @@ package com.nivesh.production.bajajfd.adapter
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.switchmaterial.SwitchMaterial import com.google.android.material.switchmaterial.SwitchMaterial
import com.nivesh.production.bajajfd.R import com.nivesh.production.bajajfd.R
@ -34,11 +35,15 @@ class CustomerListAdapter(
override fun onBindViewHolder(holder: BankListViewHolder, position: Int) { override fun onBindViewHolder(holder: BankListViewHolder, position: Int) {
val cList = customerList?.get(position) val cList = customerList?.get(position)
if (cList != null) { if (cList != null) {
holder.itemView.apply { holder.itemView.apply {
holder.tvCustomerName.text = cList.Label holder.tvCustomerName.text = cList.Label
setOnClickListener { setOnClickListener {
onItemClickListener?.let { onItemClickListener?.let {
it(cList) it(cList)
Toast.makeText(context,cList.Value,Toast.LENGTH_SHORT).show()
if (checkedPosition != holder.adapterPosition) { if (checkedPosition != holder.adapterPosition) {
notifyItemChanged(checkedPosition) notifyItemChanged(checkedPosition)
checkedPosition = holder.adapterPosition checkedPosition = holder.adapterPosition


+ 39
- 1
app/src/main/java/com/nivesh/production/bajajfd/api/ApiClient.kt View File

@ -1,13 +1,16 @@
package com.nivesh.production.bajajfd.api package com.nivesh.production.bajajfd.api
import com.nivesh.production.bajajfd.interfaces.ApiInterface import com.nivesh.production.bajajfd.interfaces.ApiInterface
import com.nivesh.production.bajajfd.util.Constants.Companion.BASE_URL import com.nivesh.production.bajajfd.util.Constants.Companion.BASE_URL
import okhttp3.Interceptor
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
class ApiClient { class ApiClient {
companion object { companion object {
private val client by lazy { private val client by lazy {
//lazy means we only initialize this here once //lazy means we only initialize this here once
@ -17,7 +20,7 @@ class ApiClient {
//see the body of response //see the body of response
//create client for retrofit //create client for retrofit
val client = OkHttpClient.Builder() val client = OkHttpClient.Builder()
.addInterceptor(logging)
.addInterceptor(ConnectVerifierInterceptor())
.retryOnConnectionFailure(true) .retryOnConnectionFailure(true)
.build() .build()
Retrofit.Builder() Retrofit.Builder()
@ -29,5 +32,40 @@ class ApiClient {
val getApiClient: ApiInterface by lazy { val getApiClient: ApiInterface by lazy {
client.create(ApiInterface::class.java) client.create(ApiInterface::class.java)
} }
class ConnectVerifierInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): okhttp3.Response {
// if (isNetworkAvailable(BaseActivity())) {
// // throw IOException("No Network Available!")
//
// }
val request = chain.request()
return chain.proceed(request)
}
}
} }
} }

+ 2
- 0
app/src/main/java/com/nivesh/production/bajajfd/ui/fragment/StepFourBajajFDFragment.kt View File

@ -138,6 +138,8 @@ class StepFourBajajFDFragment : BaseFragment() {
val customerListAdapter = CustomerListAdapter(getCustomerList) val customerListAdapter = CustomerListAdapter(getCustomerList)
binding.rvTerms.adapter = customerListAdapter binding.rvTerms.adapter = customerListAdapter
} }
private fun getFDDetailsApi(uniqueId: String) { private fun getFDDetailsApi(uniqueId: String) {


+ 6
- 0
app/src/main/java/com/nivesh/production/bajajfd/util/Common.kt View File

@ -14,6 +14,7 @@ import com.google.android.material.textfield.MaterialAutoCompleteTextView
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import com.google.gson.JsonObject import com.google.gson.JsonObject
import com.nivesh.production.bajajfd.BajajApplication
import com.nivesh.production.bajajfd.R import com.nivesh.production.bajajfd.R
import com.nivesh.production.bajajfd.ui.activity.BaseActivity import com.nivesh.production.bajajfd.ui.activity.BaseActivity
import retrofit2.HttpException import retrofit2.HttpException
@ -27,6 +28,8 @@ import java.util.regex.Pattern
class Common { class Common {
companion object { companion object {
/** /**
*Before use this method write following code in model class *Before use this method write following code in model class
app:Application(in activity and model) app:Application(in activity and model)
@ -64,6 +67,9 @@ class Common {
return false return false
} }
//valid email check //valid email check
fun isValidEmail(target: String?): Boolean { fun isValidEmail(target: String?): Boolean {
return Patterns.EMAIL_ADDRESS.matcher(target.toString()).matches() return Patterns.EMAIL_ADDRESS.matcher(target.toString()).matches()


+ 5
- 1
app/src/main/res/layout/fragment_bajajfd_step_four.xml View File

@ -220,7 +220,11 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvTerms" android:id="@+id/rvTerms"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
tools:listitem="@layout/item_customer_list_preview"
/>
</LinearLayout> </LinearLayout>


+ 3
- 3
app/src/main/res/layout/item_customer_list_preview.xml View File

@ -22,14 +22,14 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:padding="@dimen/margin_2" android:padding="@dimen/margin_2"
android:layout_weight="0.87" android:layout_weight="0.87"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="@dimen/text_size_12"/> android:textSize="@dimen/text_size_12"/>
<com.google.android.material.switchmaterial.SwitchMaterial <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/tvCustomerName" android:id="@+id/tvCustomerName"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:padding="@dimen/margin_4" android:padding="@dimen/margin_4"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="0.13" android:layout_weight="0.13"
@ -37,4 +37,4 @@
android:drawablePadding="@dimen/margin_2" /> android:drawablePadding="@dimen/margin_2" />
</LinearLayout> </LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>

Loading…
Cancel
Save

Powered by TurnKey Linux.