diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml
new file mode 100644
index 0000000..62a80dc
--- /dev/null
+++ b/.github/workflows/codacy-analysis.yml
@@ -0,0 +1,49 @@
+# This workflow checks out code, performs a Codacy security scan
+# and integrates the results with the
+# GitHub Advanced Security code scanning feature. For more information on
+# the Codacy security scan action usage and parameters, see
+# https://github.com/codacy/codacy-analysis-cli-action.
+# For more information on Codacy Analysis CLI in general, see
+# https://github.com/codacy/codacy-analysis-cli.
+
+name: Codacy Security Scan
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ master ]
+ schedule:
+ - cron: '20 15 * * 3'
+
+jobs:
+ codacy-security-scan:
+ name: Codacy Security Scan
+ runs-on: ubuntu-latest
+ steps:
+ # Checkout the repository to the GitHub Actions runner
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
+ - name: Run Codacy Analysis CLI
+ uses: codacy/codacy-analysis-cli-action@1.1.0
+ with:
+ # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
+ # You can also omit the token and run the tools that support default configurations
+ project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
+ verbose: true
+ output: results.sarif
+ format: sarif
+ # Adjust severity of non-security issues
+ gh-code-scanning-compat: true
+ # Force 0 exit code to allow SARIF file generation
+ # This will handover control about PR rejection to the GitHub side
+ max-allowed-issues: 2147483647
+
+ # Upload the SARIF file generated in the previous step
+ - name: Upload SARIF results file
+ uses: github/codeql-action/upload-sarif@v1
+ with:
+ sarif_file: results.sarif
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 21a2b4c..b3a2b6c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -10,6 +10,8 @@
+
+
diff --git a/README.md b/README.md
index c6d72b5..f29f764 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
Tired of creating 100s of Adapters and View Models.
This Library will make it easy, No need to create a Adapter, ViewHolder for every list
-![Cover Image](https://github.com/yogeshpaliyal/Android-Universal-Recycler-View-Adapter/blob/master/images/Universal%20Recycler%20View.jpg?raw=true)
+![Cover Image](https://raw.githubusercontent.com/yogeshpaliyal/Android-Universal-Recycler-View-Adapter/master/images/Universal%20Recycler%20View.jpg)
## 🤔 How?
Using Resource Pattern to find the status of the list and show view types according to that.
diff --git a/app/build.gradle b/app/build.gradle
index 90775a1..f58987e 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,6 +2,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
+apply plugin: "io.gitlab.arturbosch.detekt"
+
android {
compileSdkVersion 29
diff --git a/app/detekt-baseline.xml b/app/detekt-baseline.xml
new file mode 100644
index 0000000..c806e9e
--- /dev/null
+++ b/app/detekt-baseline.xml
@@ -0,0 +1,51 @@
+
+
+
+
+ EmptyClassBlock:SchoolListing.kt$SchoolListing${ }
+ EmptyDefaultConstructor:BindingTestViewModel.kt$BindingTestViewModel$()
+ MagicNumber:BindingTestViewModel.kt$BindingTestViewModel$3000
+ MagicNumber:LoadingListingViewModel.kt$LoadingListingViewModel$10
+ MagicNumber:LoadingListingViewModel.kt$LoadingListingViewModel$3000
+ MaxLineLength:BindingTestViewModel.kt$BindingTestViewModel$tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ MaxLineLength:UserListingActivityViewModel.kt$UserListingActivityViewModel$tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ MaxLineLength:UserModel.kt$UserModel$data
+ NewLineAtEndOfFile:BasicListener.kt$com.techpaliyal.androidkotlinmvvm.listeners.BasicListener.kt
+ NewLineAtEndOfFile:BasicListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.BasicListingActivityViewModel.kt
+ NewLineAtEndOfFile:BasicModel.kt$com.techpaliyal.androidkotlinmvvm.model.BasicModel.kt
+ NewLineAtEndOfFile:BindingAdapterTestActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.BindingAdapterTestActivity.kt
+ NewLineAtEndOfFile:BindingTestViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.BindingTestViewModel.kt
+ NewLineAtEndOfFile:HeadingModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.HeadingModel.kt
+ NewLineAtEndOfFile:ImageViewExtensions.kt$com.techpaliyal.androidkotlinmvvm.extensions.ImageViewExtensions.kt
+ NewLineAtEndOfFile:ListItemModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.ListItemModel.kt
+ NewLineAtEndOfFile:LoadingListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.LoadingListingActivity.kt
+ NewLineAtEndOfFile:LoadingListingViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.LoadingListingViewModel.kt
+ NewLineAtEndOfFile:MultiSelectListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.MultiSelectListingActivityViewModel.kt
+ NewLineAtEndOfFile:MultiSelectModel.kt$com.techpaliyal.androidkotlinmvvm.model.MultiSelectModel.kt
+ NewLineAtEndOfFile:MultipleViewTypeActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.MultipleViewTypeActivity.kt
+ NewLineAtEndOfFile:MultipleViewTypeViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.MultipleViewTypeViewModel.kt
+ NewLineAtEndOfFile:PaginationListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.PaginationListingActivity.kt
+ NewLineAtEndOfFile:RecyclerViewPagination.kt$com.techpaliyal.androidkotlinmvvm.extensions.RecyclerViewPagination.kt
+ NewLineAtEndOfFile:SchoolListing.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.SchoolListing.kt
+ NewLineAtEndOfFile:ShimmerListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.ShimmerListingActivity.kt
+ NewLineAtEndOfFile:StringHelper.kt$com.techpaliyal.androidkotlinmvvm.utils.StringHelper.kt
+ NewLineAtEndOfFile:UserListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.UserListingActivityViewModel.kt
+ NewLineAtEndOfFile:UserModel.kt$com.techpaliyal.androidkotlinmvvm.model.UserModel.kt
+ NewLineAtEndOfFile:UsersListener.kt$com.techpaliyal.androidkotlinmvvm.listeners.UsersListener.kt
+ NewLineAtEndOfFile:ViewModelFactory.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.ViewModelFactory.kt
+ PackageNaming:BasicListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ PackageNaming:BindingTestViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ PackageNaming:HeadingModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
+ PackageNaming:ListItemModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
+ PackageNaming:LoadingListingViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ PackageNaming:MultiSelectListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ PackageNaming:MultipleViewTypeActivity.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
+ PackageNaming:MultipleViewTypeViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
+ PackageNaming:SchoolListing.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
+ PackageNaming:UserListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ PackageNaming:ViewModelFactory.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model
+ UnusedPrivateMember:LoadingListingViewModel.kt$LoadingListingViewModel$i
+ VariableNaming:RecyclerViewPagination.kt$val VISIBLE_THRESHOLD: Int = RECYCLER_PAGING_THRESHOLD
+ WildcardImport:BindingTestViewModel.kt$import androidx.lifecycle.*
+
+
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/BasicModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/BasicModel.kt
index c0c9112..a85ea10 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/BasicModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/BasicModel.kt
@@ -1,6 +1,6 @@
package com.techpaliyal.androidkotlinmvvm.model
-import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
+import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
/**
* @author Yogesh Paliyal
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/MultiSelectModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/MultiSelectModel.kt
index 336700d..04f68dd 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/MultiSelectModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/MultiSelectModel.kt
@@ -1,6 +1,6 @@
package com.techpaliyal.androidkotlinmvvm.model
-import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
+import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
/**
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/UserModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/UserModel.kt
index 54d75f6..ad0b3b3 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/UserModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/model/UserModel.kt
@@ -1,6 +1,6 @@
package com.techpaliyal.androidkotlinmvvm.model
-import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
+import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
/**
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/BasicListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/BasicListingActivity.kt
index 0b644ee..21f4637 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/BasicListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/BasicListingActivity.kt
@@ -12,9 +12,9 @@ import com.techpaliyal.androidkotlinmvvm.listeners.BasicListener
import com.techpaliyal.androidkotlinmvvm.model.BasicModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.BasicListingActivityViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.utils.Resource
/**
* @author Yogesh Paliyal
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/LoadingListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/LoadingListingActivity.kt
index d7cd170..e9b32e2 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/LoadingListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/LoadingListingActivity.kt
@@ -5,15 +5,17 @@ import android.content.Intent
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
+import androidx.databinding.ViewDataBinding
import androidx.lifecycle.Observer
import com.techpaliyal.androidkotlinmvvm.R
import com.techpaliyal.androidkotlinmvvm.databinding.ActivityListingBinding
import com.techpaliyal.androidkotlinmvvm.listeners.BasicListener
+import com.techpaliyal.androidkotlinmvvm.listeners.UsersListener
import com.techpaliyal.androidkotlinmvvm.model.UserModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.LoadingListingViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
/**
* @author Yogesh Paliyal
@@ -42,7 +44,10 @@ class LoadingListingActivity : AppCompatActivity() {
UniversalRecyclerAdapter.Builder(
lifecycleOwner = this,
content = UniversalAdapterViewType.Content(resource = R.layout.item_user,
- object : BasicListener {
+ object : UsersListener {
+ override fun onLikeClicked(binding: ViewDataBinding, model: UserModel) {
+
+ }
override fun onClick(model: UserModel) {
Toast.makeText(this@LoadingListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/MultiSelectListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/MultiSelectListingActivity.kt
index 2e3da79..9a87173 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/MultiSelectListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/MultiSelectListingActivity.kt
@@ -11,9 +11,9 @@ import com.techpaliyal.androidkotlinmvvm.listeners.BasicListener
import com.techpaliyal.androidkotlinmvvm.model.MultiSelectModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.MultiSelectListingActivityViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.utils.Resource
/**
* @author Yogesh Paliyal
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/PaginationListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/PaginationListingActivity.kt
index 68906eb..7ad1d25 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/PaginationListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/PaginationListingActivity.kt
@@ -15,7 +15,7 @@ import com.techpaliyal.androidkotlinmvvm.listeners.UsersListener
import com.techpaliyal.androidkotlinmvvm.model.UserModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.LoadingListingViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
/**
* @author Yogesh Paliyal
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/ShimmerListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/ShimmerListingActivity.kt
index 24ce890..fb5da19 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/ShimmerListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/ShimmerListingActivity.kt
@@ -14,8 +14,8 @@ import com.techpaliyal.androidkotlinmvvm.listeners.UsersListener
import com.techpaliyal.androidkotlinmvvm.model.UserModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.LoadingListingViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
/**
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/UserListingActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/UserListingActivity.kt
index af0e500..d87b70a 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/UserListingActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/UserListingActivity.kt
@@ -9,13 +9,12 @@ import androidx.databinding.ViewDataBinding
import androidx.lifecycle.Observer
import com.techpaliyal.androidkotlinmvvm.R
import com.techpaliyal.androidkotlinmvvm.databinding.ActivityListingBinding
-import com.techpaliyal.androidkotlinmvvm.listeners.BasicListener
import com.techpaliyal.androidkotlinmvvm.listeners.UsersListener
import com.techpaliyal.androidkotlinmvvm.model.UserModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.UserListingActivityViewModel
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.utils.Resource
/**
* @author Yogesh Paliyal
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/HeadingModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/HeadingModel.kt
index 88cf5f9..70d8e8d 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/HeadingModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/HeadingModel.kt
@@ -1,7 +1,7 @@
package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
import com.techpaliyal.androidkotlinmvvm.R
-import com.yogeshpaliyal.universal_adapter.listener.UniversalViewType
+import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
data class HeadingModel(val title: String) : UniversalViewType,SchoolListing {
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/ListItemModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/ListItemModel.kt
index 931e871..bc70375 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/ListItemModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/ListItemModel.kt
@@ -1,7 +1,7 @@
package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
import com.techpaliyal.androidkotlinmvvm.R
-import com.yogeshpaliyal.universal_adapter.listener.UniversalViewType
+import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
data class ListItemModel(val name: String) : UniversalViewType,SchoolListing {
override fun getLayoutId(): Int {
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeActivity.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeActivity.kt
index 3d016e8..2c3a297 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeActivity.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeActivity.kt
@@ -7,8 +7,8 @@ import android.os.Bundle
import androidx.lifecycle.Observer
import com.techpaliyal.androidkotlinmvvm.databinding.ActivityMultipleViewTypeBinding
import com.techpaliyal.androidkotlinmvvm.ui.view_model.initViewModel
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
class MultipleViewTypeActivity : AppCompatActivity() {
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeViewModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeViewModel.kt
index e140369..f6acf79 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeViewModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/MultipleViewTypeViewModel.kt
@@ -1,11 +1,9 @@
package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
-import android.app.Application
-import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.utils.Resource
class MultipleViewTypeViewModel : ViewModel() {
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/SchoolListing.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/SchoolListing.kt
index 506c0ba..0d2f314 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/SchoolListing.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/multiple_view/SchoolListing.kt
@@ -1,4 +1,3 @@
package com.techpaliyal.androidkotlinmvvm.ui.multiple_view
-interface SchoolListing {
-}
\ No newline at end of file
+interface SchoolListing
\ No newline at end of file
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/BindingTestViewModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/BindingTestViewModel.kt
index 7e21d03..6733585 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/BindingTestViewModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/BindingTestViewModel.kt
@@ -1,13 +1,13 @@
package com.techpaliyal.androidkotlinmvvm.ui.view_model
-import android.app.Application
import androidx.lifecycle.*
import com.techpaliyal.androidkotlinmvvm.model.UserModel
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.utils.Resource
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
-class BindingTestViewModel() : ViewModel() {
+class BindingTestViewModel : ViewModel() {
private val _usersData = MutableLiveData>>()
val usersData : LiveData>> = _usersData
@@ -19,17 +19,35 @@ class BindingTestViewModel() : ViewModel() {
private fun loadData(){
- viewModelScope.launch {
+ viewModelScope.launch(Dispatchers.IO) {
_usersData.postValue(Resource.loading())
- delay(3000)
- val tempArr = ArrayList()
- tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
- tempArr.add(UserModel(name = "Umesh",image = "https://randomuser.me/api/portraits/men/62.jpg"))
- tempArr.add(UserModel(name = "Sohan",image = "https://randomuser.me/api/portraits/men/84.jpg"))
- tempArr.add(UserModel(name = "Jitendra",image = "https://randomuser.me/api/portraits/men/83.jpg"))
- _usersData.postValue(Resource.success(tempArr))
+ for (i in 0 until 100) {
+ delay(3000)
+ addDummyData()
+ }
}
}
+ private fun addDummyData(){
+ val tempArr = ArrayList()
+ tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ tempArr.add(UserModel(name = "Umesh",image = "https://randomuser.me/api/portraits/men/62.jpg"))
+ tempArr.add(UserModel(name = "Sohan",image = "https://randomuser.me/api/portraits/men/84.jpg"))
+ tempArr.add(UserModel(name = "Jitendra",image = "https://randomuser.me/api/portraits/men/83.jpg"))
+ tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ tempArr.add(UserModel(name = "Umesh",image = "https://randomuser.me/api/portraits/men/62.jpg"))
+ tempArr.add(UserModel(name = "Sohan",image = "https://randomuser.me/api/portraits/men/84.jpg"))
+ tempArr.add(UserModel(name = "Jitendra",image = "https://randomuser.me/api/portraits/men/83.jpg"))
+ tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ tempArr.add(UserModel(name = "Umesh",image = "https://randomuser.me/api/portraits/men/62.jpg"))
+ tempArr.add(UserModel(name = "Sohan",image = "https://randomuser.me/api/portraits/men/84.jpg"))
+ tempArr.add(UserModel(name = "Jitendra",image = "https://randomuser.me/api/portraits/men/83.jpg"))
+ tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))
+ tempArr.add(UserModel(name = "Umesh",image = "https://randomuser.me/api/portraits/men/62.jpg"))
+ tempArr.add(UserModel(name = "Sohan",image = "https://randomuser.me/api/portraits/men/84.jpg"))
+ tempArr.add(UserModel(name = "Jitendra",image = "https://randomuser.me/api/portraits/men/83.jpg"))
+ _usersData.postValue(Resource.success(tempArr))
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/LoadingListingViewModel.kt b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/LoadingListingViewModel.kt
index e3fb68c..4dbec7e 100644
--- a/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/LoadingListingViewModel.kt
+++ b/app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/view_model/LoadingListingViewModel.kt
@@ -4,7 +4,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.techpaliyal.androidkotlinmvvm.model.UserModel
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.utils.Resource
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
diff --git a/app/src/main/res/layout/activity_binding_adapter_test.xml b/app/src/main/res/layout/activity_binding_adapter_test.xml
index b7414a1..38c51db 100644
--- a/app/src/main/res/layout/activity_binding_adapter_test.xml
+++ b/app/src/main/res/layout/activity_binding_adapter_test.xml
@@ -28,6 +28,7 @@
item_layout="@{R.layout.item_user}"
loading_layout="@{R.layout.item_user_shimmer}"
data="@{mViewModel.usersData}"
+ ura_use_tag="@{false}"
lifecycleOwner="@{myLifecycleOwner}"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
diff --git a/build.gradle b/build.gradle
index ca770c2..e9d9db7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,13 +5,17 @@ buildscript {
repositories {
google()
jcenter()
-
+ mavenCentral()
+ gradlePluginPortal()
+
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
+ classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.18.1"
+
}
}
diff --git a/universal_adapter/build.gradle b/universal_adapter/build.gradle
index 6a38592..d919cc6 100644
--- a/universal_adapter/build.gradle
+++ b/universal_adapter/build.gradle
@@ -2,6 +2,8 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-kapt'
+ id 'io.gitlab.arturbosch.detekt'
+
}
android {
diff --git a/universal_adapter/src/androidTest/java/com/yogeshpaliyal/universal_adapter/ExampleInstrumentedTest.kt b/universal_adapter/src/androidTest/java/com/yogeshpaliyal/universalAdapter/ExampleInstrumentedTest.kt
similarity index 93%
rename from universal_adapter/src/androidTest/java/com/yogeshpaliyal/universal_adapter/ExampleInstrumentedTest.kt
rename to universal_adapter/src/androidTest/java/com/yogeshpaliyal/universalAdapter/ExampleInstrumentedTest.kt
index c09bbcb..0a84f10 100644
--- a/universal_adapter/src/androidTest/java/com/yogeshpaliyal/universal_adapter/ExampleInstrumentedTest.kt
+++ b/universal_adapter/src/androidTest/java/com/yogeshpaliyal/universalAdapter/ExampleInstrumentedTest.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter
+package com.yogeshpaliyal.universalAdapter
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
diff --git a/universal_adapter/src/main/AndroidManifest.xml b/universal_adapter/src/main/AndroidManifest.xml
index 2570065..d90ece5 100644
--- a/universal_adapter/src/main/AndroidManifest.xml
+++ b/universal_adapter/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.yogeshpaliyal.universalAdapter">
\ No newline at end of file
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ContentListAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ContentListAdapter.kt
similarity index 93%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ContentListAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ContentListAdapter.kt
index facbccb..e694b81 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ContentListAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ContentListAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,9 +9,9 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
-import com.yogeshpaliyal.universal_adapter.listener.UniversalViewType
-import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
+import com.yogeshpaliyal.universalAdapter.BR
+import com.yogeshpaliyal.universalAdapter.listener.UniversalViewType
+import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ErrorAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ErrorAdapter.kt
similarity index 96%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ErrorAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ErrorAdapter.kt
index 4647247..26d4cc0 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/ErrorAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/ErrorAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
+import com.yogeshpaliyal.universalAdapter.BR
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingAdapter.kt
similarity index 95%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingAdapter.kt
index 2430094..a9fffa2 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
+import com.yogeshpaliyal.universalAdapter.BR
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingFooterAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingFooterAdapter.kt
similarity index 95%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingFooterAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingFooterAdapter.kt
index b6ef67f..56195df 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/LoadingFooterAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/LoadingFooterAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
+import com.yogeshpaliyal.universalAdapter.BR
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/NoDataAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/NoDataAdapter.kt
similarity index 96%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/NoDataAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/NoDataAdapter.kt
index 12e5405..b18b07b 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/NoDataAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/NoDataAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,7 +9,7 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
+import com.yogeshpaliyal.universalAdapter.BR
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionAdapter.kt
similarity index 79%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionAdapter.kt
index a704788..f4e2288 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionAdapter.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
@@ -9,13 +9,15 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.BR
-import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
+import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil
class SectionAdapter(
- val lifecycleOwner: LifecycleOwner?,var model: T,val resource: Int,val customBindingMapping: ((itemBinding: B, item: T) -> Unit)
+ val lifecycleOwner: LifecycleOwner?,
+ var model: T,
+ val resource: Int,
+ val customBindingMapping: ((itemBinding: B, item: T) -> Unit)
) :
- ListAdapter.ViewHolder>(AsyncDifferConfig.Builder(object :
+ ListAdapter.ViewHolder>(AsyncDifferConfig.Builder(object :
DiffUtil.ItemCallback() {
override fun areItemsTheSame(oldItem: T, newItem: T): Boolean {
return if (oldItem is BaseDiffUtil && newItem is BaseDiffUtil) {
@@ -39,10 +41,10 @@ class SectionAdapter(
inner class ViewHolder(val binding: B) : RecyclerView.ViewHolder(binding.root) {
fun bind(model: T) {
binding.lifecycleOwner = lifecycleOwner
- customBindingMapping.invoke(
- binding,
- model
- )
+ customBindingMapping.invoke(
+ binding,
+ model
+ )
}
}
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt
similarity index 94%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt
index 59f1212..212a21a 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/SectionUniversalRecyclerAdapterBuilder.kt
@@ -1,7 +1,7 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import androidx.recyclerview.widget.ConcatAdapter
-import com.yogeshpaliyal.universal_adapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.utils.Resource
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalAdapterViewType.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalAdapterViewType.kt
similarity index 96%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalAdapterViewType.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalAdapterViewType.kt
index 263f3b4..f8ca8db 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalAdapterViewType.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalAdapterViewType.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import androidx.annotation.LayoutRes
import androidx.databinding.ViewDataBinding
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalRecyclerAdapter.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalRecyclerAdapter.kt
similarity index 89%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalRecyclerAdapter.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalRecyclerAdapter.kt
index 7f65686..f5ae325 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/adapter/UniversalRecyclerAdapter.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/adapter/UniversalRecyclerAdapter.kt
@@ -1,22 +1,21 @@
-package com.yogeshpaliyal.universal_adapter.adapter
+package com.yogeshpaliyal.universalAdapter.adapter
import androidx.annotation.LayoutRes
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.utils.Resource
-import com.yogeshpaliyal.universal_adapter.utils.Status
-import com.yogeshpaliyal.universal_adapter.utils.UniversalAdapterBuilder
+import com.yogeshpaliyal.universalAdapter.utils.Resource
+import com.yogeshpaliyal.universalAdapter.utils.Status
/**
* @author Yogesh Paliyal
* Created Date : 15 October 2020
*/
+@Suppress
class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
-// var adapterOptions : UniversalAdapterOptions = UniversalAdapterOptions(resource, resourceLoading, defaultLoadingItems, loaderFooter, data, errorLayout, errorListener, mListener, noDataLayout, noDataListener, lifecycleOwner)
-
+ @Suppress
@Deprecated(
"Use UniversalAdapterBuilder for better approach",
ReplaceWith(
@@ -78,7 +77,7 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
private var loadMoreAdapter: LoadingFooterAdapter? = null
private var errorAdapter: ErrorAdapter? = null
- private var data : Resource?>?= null
+ private var data: Resource?>? = null
init {
if (adapterBuilder.content != null)
@@ -117,7 +116,7 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
}
fun updateData(data: Resource?>) {
- this.data = data;
+ this.data = data
setupAdapters(data)
}
@@ -139,8 +138,8 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
remove(errorAdapter)
if (data.data.isNullOrEmpty()) {
// add only loading state
- remove(contentAdapter)
- remove(loadMoreAdapter)
+ remove(contentAdapter)
+ remove(loadMoreAdapter)
addAdapter(loadingAdapter)
} else {
@@ -205,7 +204,7 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
}
private fun remove(adapter: RecyclerView.Adapter<*>?) {
- adapter?.let { mainAdapter.removeAdapter(adapter) }
+ adapter?.let { mainAdapter.removeAdapter(adapter) }
}
@@ -218,6 +217,7 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
return false
}
+ @Suppress
private fun clearMainAdapter() {
for (adapter in mainAdapter.adapters) {
mainAdapter.removeAdapter(adapter)
@@ -233,6 +233,8 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
val noData: UniversalAdapterViewType.NoData? = null,
val error: UniversalAdapterViewType.Error? = null
) {
+
+ @Suppress
constructor(
@LayoutRes
resource: Int,
@@ -260,19 +262,9 @@ class UniversalRecyclerAdapter constructor(val adapterBuilder: Builder) {
UniversalAdapterViewType.Error(errorLayout, errorListener)
)
- constructor(oldBuilder: UniversalAdapterBuilder) : this(
- oldBuilder.lifecycleOwner,
- oldBuilder.data,
- oldBuilder.content,
- oldBuilder.loading,
- oldBuilder.loadingFooter,
- oldBuilder.noData,
- oldBuilder.error
- )
-
fun build() = UniversalRecyclerAdapter(this)
- fun buildAdapter() = build().getAdapter();
+ fun buildAdapter() = build().getAdapter()
}
}
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/extensions/BindingAdaptersUtils.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/extensions/BindingAdaptersUtils.kt
new file mode 100644
index 0000000..40a47cb
--- /dev/null
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/extensions/BindingAdaptersUtils.kt
@@ -0,0 +1,73 @@
+package com.yogeshpaliyal.universalAdapter.extensions
+
+import androidx.annotation.LayoutRes
+import androidx.databinding.BindingAdapter
+import androidx.lifecycle.LifecycleOwner
+import androidx.recyclerview.widget.RecyclerView
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalAdapterViewType
+import com.yogeshpaliyal.universalAdapter.adapter.UniversalRecyclerAdapter
+import com.yogeshpaliyal.universalAdapter.utils.DEFAULT_LOADING_ITEMS
+import com.yogeshpaliyal.universalAdapter.utils.Resource
+
+
+@BindingAdapter("recycler_adapter")
+fun RecyclerView.setRecyclerAdapter(adapter: RecyclerView.Adapter<*>) {
+ if (this.adapter != adapter)
+ this.adapter = adapter
+}
+
+
+@BindingAdapter(
+ value = ["lifecycleOwner",
+ "data",
+ "item_layout",
+ "loading_layout_count",
+ "loading_layout",
+ "error_layout",
+ "load_more_layout",
+ "no_data_layout",
+ "item_listener",
+ "error_listener",
+ "no_data_listener",
+ "ura_use_tag"], // Allow universal recycler view to set tag
+ requireAll = false
+)
+@Suppress("UNCHECKED_CAST")
+fun RecyclerView.setRecyclerAdapter(
+ lifecycleOwner: LifecycleOwner?,
+ data: Resource>?,
+ @LayoutRes itemLayout: Int?,
+ loadingLayoutCount: Int?,
+ @LayoutRes loadingLayout: Int?,
+ @LayoutRes errorLayout: Int?,
+ @LayoutRes loadMoreLayout: Int?,
+ @LayoutRes noDataLayout: Int?,
+ itemListener: Any?,
+ errorListener: Any?,
+ noDataListener: Any?,
+ useTag: Boolean? = true // use
+) {
+ if (itemLayout != null) {
+ val universalAdapter = tag as? UniversalRecyclerAdapter
+ if(useTag != false && universalAdapter != null){
+ data?.let {
+ universalAdapter.updateData(it)
+ }
+ }else {
+ val tempAdapter = UniversalRecyclerAdapter.Builder(
+ lifecycleOwner = lifecycleOwner, data = data,
+ content = UniversalAdapterViewType.Content(itemLayout, itemListener),
+ loading = UniversalAdapterViewType.Loading(
+ loadingLayout,
+ loadingLayoutCount ?: DEFAULT_LOADING_ITEMS
+ ),
+ loadingFooter = UniversalAdapterViewType.LoadingFooter(loadMoreLayout),
+ error = UniversalAdapterViewType.Error(errorLayout, errorListener),
+ noData = UniversalAdapterViewType.NoData(noDataLayout, noDataListener)
+ ).build()
+ adapter = tempAdapter.getAdapter()
+ if (useTag != false)
+ tag = tempAdapter
+ }
+ }
+}
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalViewType.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/listener/UniversalViewType.kt
similarity index 53%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalViewType.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/listener/UniversalViewType.kt
index 516d675..73e326d 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalViewType.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/listener/UniversalViewType.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.listener
+package com.yogeshpaliyal.universalAdapter.listener
interface UniversalViewType {
fun getLayoutId() : Int
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/model/BaseDiffUtil.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/model/BaseDiffUtil.kt
similarity index 71%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/model/BaseDiffUtil.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/model/BaseDiffUtil.kt
index 522d0f5..daf91f0 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/model/BaseDiffUtil.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/model/BaseDiffUtil.kt
@@ -1,6 +1,6 @@
-package com.yogeshpaliyal.universal_adapter.model
+package com.yogeshpaliyal.universalAdapter.model
-import com.yogeshpaliyal.universal_adapter.utils.getRandomString
+import com.yogeshpaliyal.universalAdapter.utils.getRandomString
/*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Constans.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Constans.kt
new file mode 100644
index 0000000..a480b9d
--- /dev/null
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Constans.kt
@@ -0,0 +1,4 @@
+package com.yogeshpaliyal.universalAdapter.utils
+
+
+const val DEFAULT_LOADING_ITEMS = 5
\ No newline at end of file
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Resource.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Resource.kt
similarity index 93%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Resource.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Resource.kt
index c71b9be..585c54c 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Resource.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Resource.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.utils
+package com.yogeshpaliyal.universalAdapter.utils
/**
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Status.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Status.kt
similarity index 71%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Status.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Status.kt
index 859bae8..e0dbd3e 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/Status.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/Status.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.utils
+package com.yogeshpaliyal.universalAdapter.utils
/**
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/StringHelper.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/StringHelper.kt
similarity index 79%
rename from universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/StringHelper.kt
rename to universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/StringHelper.kt
index a51ec27..18c20ec 100644
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/StringHelper.kt
+++ b/universal_adapter/src/main/java/com/yogeshpaliyal/universalAdapter/utils/StringHelper.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter.utils
+package com.yogeshpaliyal.universalAdapter.utils
import java.util.*
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/extensions/BindingAdaptersUtils.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/extensions/BindingAdaptersUtils.kt
deleted file mode 100644
index 10bb73a..0000000
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/extensions/BindingAdaptersUtils.kt
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.yogeshpaliyal.universal_adapter.extensions
-
-import androidx.annotation.LayoutRes
-import androidx.databinding.BindingAdapter
-import androidx.lifecycle.LifecycleOwner
-import androidx.recyclerview.widget.RecyclerView
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
-import com.yogeshpaliyal.universal_adapter.utils.Resource
-import java.util.*
-
-
-@BindingAdapter("recycler_adapter")
-fun RecyclerView.setRecyclerAdapter(adapter: RecyclerView.Adapter<*>) {
- if(this.adapter != adapter)
- this.adapter = adapter
-}
-
-
-@BindingAdapter(value = ["lifecycleOwner", "data", "item_layout", "loading_layout_count","loading_layout", "error_layout", "load_more_layout", "no_data_layout", "item_listener", "error_listener", "no_data_listener"], requireAll = false)
-fun RecyclerView.setRecyclerAdapter(
- lifecycleOwner: LifecycleOwner?,
- data: Resource>?,
- @LayoutRes itemLayout: Int?,
- loadingLayoutCount: Int?,
- @LayoutRes loadingLayout: Int?,
- @LayoutRes errorLayout: Int?,
- @LayoutRes loadMoreLayout: Int?,
- @LayoutRes noDataLayout: Int?,
- itemListener: Any?,
- errorListener: Any?,
- noDataListener: Any?
-) {
- if (itemLayout != null) {
- val tempAdapter = UniversalRecyclerAdapter.Builder(
- lifecycleOwner = lifecycleOwner, data = data,
- content = UniversalAdapterViewType.Content(itemLayout, itemListener),
- loading = UniversalAdapterViewType.Loading(loadingLayout,loadingLayoutCount?:5),
- loadingFooter = UniversalAdapterViewType.LoadingFooter(loadMoreLayout),
- error = UniversalAdapterViewType.Error(errorLayout, errorListener),
- noData = UniversalAdapterViewType.NoData(noDataLayout, noDataListener)
- ).build()
- adapter = tempAdapter.getAdapter()
- }
-}
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/TestListener.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/TestListener.kt
deleted file mode 100644
index 313d155..0000000
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/TestListener.kt
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.yogeshpaliyal.universal_adapter.listener
-
-
-/*
-* @author Yogesh Paliyal
-* yogeshpaliyal.foss@gmail.com
-* https://techpaliyal.com
-* created on 02-12-2020 21:02
-*/
-interface TestListener
\ No newline at end of file
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalAdapterInterface.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalAdapterInterface.kt
deleted file mode 100644
index 142037a..0000000
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/listener/UniversalAdapterInterface.kt
+++ /dev/null
@@ -1,4 +0,0 @@
-package com.yogeshpaliyal.universal_adapter.listener
-
-interface UniversalAdapterInterface {
-}
\ No newline at end of file
diff --git a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/UniversalAdapterBuilder.kt b/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/UniversalAdapterBuilder.kt
deleted file mode 100644
index 056c924..0000000
--- a/universal_adapter/src/main/java/com/yogeshpaliyal/universal_adapter/utils/UniversalAdapterBuilder.kt
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.yogeshpaliyal.universal_adapter.utils
-
-import androidx.annotation.LayoutRes
-import androidx.lifecycle.LifecycleOwner
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalAdapterViewType
-import com.yogeshpaliyal.universal_adapter.adapter.UniversalRecyclerAdapter
-
-
-/*
-* @author Yogesh Paliyal
-* yogeshpaliyal.foss@gmail.com
-* https://techpaliyal.com
-* created on 08-01-2021 19:54
-*/
-@Deprecated("Use UniversalRecyclerAdapter.Builder")
-open class UniversalAdapterBuilder constructor(
- var lifecycleOwner: LifecycleOwner? = null,
- var data: Resource?>? = null,
- val content: UniversalAdapterViewType.Content? = null,
- val loading: UniversalAdapterViewType.Loading? = null,
- val loadingFooter: UniversalAdapterViewType.LoadingFooter? = null,
- val noData: UniversalAdapterViewType.NoData? = null,
- val error: UniversalAdapterViewType.Error? = null
-) {
- constructor(
- @LayoutRes
- resource: Int,
- @LayoutRes
- resourceLoading: Int? = null,
- defaultLoadingItems: Int = 5,
- @LayoutRes
- loaderFooter: Int? = null,
- data: Resource?>? = null,
- @LayoutRes
- errorLayout: Int? = null,
- errorListener: Any? = null,
- mListener: Any? = null,
- @LayoutRes
- noDataLayout: Int? = null,
- noDataListener: Any? = null,
- lifecycleOwner: LifecycleOwner? = null
- ) : this(
- lifecycleOwner,
- data,
- UniversalAdapterViewType.Content(resource, mListener),
- UniversalAdapterViewType.Loading(resourceLoading, defaultLoadingItems),
- UniversalAdapterViewType.LoadingFooter(loaderFooter),
- UniversalAdapterViewType.NoData(noDataLayout, noDataListener),
- UniversalAdapterViewType.Error(errorLayout, errorListener)
- )
-
- fun build() = UniversalRecyclerAdapter.Builder(this).build()
-}
-
diff --git a/universal_adapter/src/test/java/com/yogeshpaliyal/universal_adapter/ExampleUnitTest.kt b/universal_adapter/src/test/java/com/yogeshpaliyal/universalAdapter/ExampleUnitTest.kt
similarity index 87%
rename from universal_adapter/src/test/java/com/yogeshpaliyal/universal_adapter/ExampleUnitTest.kt
rename to universal_adapter/src/test/java/com/yogeshpaliyal/universalAdapter/ExampleUnitTest.kt
index 18a9fe9..0ab5c4c 100644
--- a/universal_adapter/src/test/java/com/yogeshpaliyal/universal_adapter/ExampleUnitTest.kt
+++ b/universal_adapter/src/test/java/com/yogeshpaliyal/universalAdapter/ExampleUnitTest.kt
@@ -1,4 +1,4 @@
-package com.yogeshpaliyal.universal_adapter
+package com.yogeshpaliyal.universalAdapter
import org.junit.Test
diff --git a/universal_recycler_view_multiple_view_type.png b/universal_recycler_view_multiple_view_type.png
new file mode 100644
index 0000000..e5882b8
Binary files /dev/null and b/universal_recycler_view_multiple_view_type.png differ