Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…versal-Recycler-View-Adapter

� Conflicts:
�	app/src/main/java/com/techpaliyal/androidkotlinmvvm/ui/activity/ShimmerListingActivity.kt
  • Loading branch information
yogeshpaliyal committed Oct 3, 2021
2 parents 841554f + 2108373 commit 57831ff
Show file tree
Hide file tree
Showing 48 changed files with 297 additions and 209 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions app/detekt-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>EmptyClassBlock:SchoolListing.kt$SchoolListing${ }</ID>
<ID>EmptyDefaultConstructor:BindingTestViewModel.kt$BindingTestViewModel$()</ID>
<ID>MagicNumber:BindingTestViewModel.kt$BindingTestViewModel$3000</ID>
<ID>MagicNumber:LoadingListingViewModel.kt$LoadingListingViewModel$10</ID>
<ID>MagicNumber:LoadingListingViewModel.kt$LoadingListingViewModel$3000</ID>
<ID>MaxLineLength:BindingTestViewModel.kt$BindingTestViewModel$tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))</ID>
<ID>MaxLineLength:UserListingActivityViewModel.kt$UserListingActivityViewModel$tempArr.add(UserModel(name = "Yogesh",image = "https://randomuser.me/api/portraits/men/52.jpg", address = "Jodhpur"))</ID>
<ID>MaxLineLength:UserModel.kt$UserModel$data</ID>
<ID>NewLineAtEndOfFile:BasicListener.kt$com.techpaliyal.androidkotlinmvvm.listeners.BasicListener.kt</ID>
<ID>NewLineAtEndOfFile:BasicListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.BasicListingActivityViewModel.kt</ID>
<ID>NewLineAtEndOfFile:BasicModel.kt$com.techpaliyal.androidkotlinmvvm.model.BasicModel.kt</ID>
<ID>NewLineAtEndOfFile:BindingAdapterTestActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.BindingAdapterTestActivity.kt</ID>
<ID>NewLineAtEndOfFile:BindingTestViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.BindingTestViewModel.kt</ID>
<ID>NewLineAtEndOfFile:HeadingModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.HeadingModel.kt</ID>
<ID>NewLineAtEndOfFile:ImageViewExtensions.kt$com.techpaliyal.androidkotlinmvvm.extensions.ImageViewExtensions.kt</ID>
<ID>NewLineAtEndOfFile:ListItemModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.ListItemModel.kt</ID>
<ID>NewLineAtEndOfFile:LoadingListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.LoadingListingActivity.kt</ID>
<ID>NewLineAtEndOfFile:LoadingListingViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.LoadingListingViewModel.kt</ID>
<ID>NewLineAtEndOfFile:MultiSelectListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.MultiSelectListingActivityViewModel.kt</ID>
<ID>NewLineAtEndOfFile:MultiSelectModel.kt$com.techpaliyal.androidkotlinmvvm.model.MultiSelectModel.kt</ID>
<ID>NewLineAtEndOfFile:MultipleViewTypeActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.MultipleViewTypeActivity.kt</ID>
<ID>NewLineAtEndOfFile:MultipleViewTypeViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.MultipleViewTypeViewModel.kt</ID>
<ID>NewLineAtEndOfFile:PaginationListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.PaginationListingActivity.kt</ID>
<ID>NewLineAtEndOfFile:RecyclerViewPagination.kt$com.techpaliyal.androidkotlinmvvm.extensions.RecyclerViewPagination.kt</ID>
<ID>NewLineAtEndOfFile:SchoolListing.kt$com.techpaliyal.androidkotlinmvvm.ui.multiple_view.SchoolListing.kt</ID>
<ID>NewLineAtEndOfFile:ShimmerListingActivity.kt$com.techpaliyal.androidkotlinmvvm.ui.activity.ShimmerListingActivity.kt</ID>
<ID>NewLineAtEndOfFile:StringHelper.kt$com.techpaliyal.androidkotlinmvvm.utils.StringHelper.kt</ID>
<ID>NewLineAtEndOfFile:UserListingActivityViewModel.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.UserListingActivityViewModel.kt</ID>
<ID>NewLineAtEndOfFile:UserModel.kt$com.techpaliyal.androidkotlinmvvm.model.UserModel.kt</ID>
<ID>NewLineAtEndOfFile:UsersListener.kt$com.techpaliyal.androidkotlinmvvm.listeners.UsersListener.kt</ID>
<ID>NewLineAtEndOfFile:ViewModelFactory.kt$com.techpaliyal.androidkotlinmvvm.ui.view_model.ViewModelFactory.kt</ID>
<ID>PackageNaming:BasicListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>PackageNaming:BindingTestViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>PackageNaming:HeadingModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view</ID>
<ID>PackageNaming:ListItemModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view</ID>
<ID>PackageNaming:LoadingListingViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>PackageNaming:MultiSelectListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>PackageNaming:MultipleViewTypeActivity.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view</ID>
<ID>PackageNaming:MultipleViewTypeViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view</ID>
<ID>PackageNaming:SchoolListing.kt$package com.techpaliyal.androidkotlinmvvm.ui.multiple_view</ID>
<ID>PackageNaming:UserListingActivityViewModel.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>PackageNaming:ViewModelFactory.kt$package com.techpaliyal.androidkotlinmvvm.ui.view_model</ID>
<ID>UnusedPrivateMember:LoadingListingViewModel.kt$LoadingListingViewModel$i</ID>
<ID>VariableNaming:RecyclerViewPagination.kt$val VISIBLE_THRESHOLD: Int = RECYCLER_PAGING_THRESHOLD</ID>
<ID>WildcardImport:BindingTestViewModel.kt$import androidx.lifecycle.*</ID>
</CurrentIssues>
</SmellBaseline>
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.techpaliyal.androidkotlinmvvm.model

import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.techpaliyal.androidkotlinmvvm.model

import com.yogeshpaliyal.universal_adapter.model.BaseDiffUtil
import com.yogeshpaliyal.universalAdapter.model.BaseDiffUtil


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,7 +44,10 @@ class LoadingListingActivity : AppCompatActivity() {
UniversalRecyclerAdapter.Builder<UserModel>(
lifecycleOwner = this,
content = UniversalAdapterViewType.Content(resource = R.layout.item_user,
object : BasicListener<UserModel> {
object : UsersListener {
override fun onLikeClicked(binding: ViewDataBinding, model: UserModel) {

}
override fun onClick(model: UserModel) {
Toast.makeText(this@LoadingListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package com.techpaliyal.androidkotlinmvvm.ui.multiple_view

interface SchoolListing {
}
interface SchoolListing
Original file line number Diff line number Diff line change
@@ -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<Resource<List<UserModel>>>()
val usersData : LiveData<Resource<List<UserModel>>> = _usersData
Expand All @@ -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<UserModel>()
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<UserModel>()
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))
}

}
Loading

0 comments on commit 57831ff

Please sign in to comment.