Skip to content

Instantly share code, notes, and snippets.

View pritomzap's full-sized avatar
🏠
Working from home

Zarraf Ahmed pritomzap

🏠
Working from home
  • Newroz Technology
  • Dhaka
View GitHub Profile
@pritomzap
pritomzap / BaseViewHolder.kt
Created February 9, 2021 19:28
A baseViewHolder class for base adapter
class BaseViewHolder<T> internal constructor(private val binding:ViewBinding,private val experssion:(T,ViewBinding)->Unit)
:RecyclerView.ViewHolder(binding.root){
fun bind(item:T){
experssion(item,binding)
}
}
@pritomzap
pritomzap / BaseAdapter.kt
Created February 9, 2021 19:45
BaseAdapter class for recyclerView
class BaseAdapter<T>: RecyclerView.Adapter<BaseViewHolder<T>>(){
var listOfItems:MutableList<T>? = mutableListOf()
set(value) {
field = value
notifyDataSetChanged()
}
var expressionViewHolderBinding: ((T,ViewBinding) -> Unit)? = null
var expressionOnCreateViewHolder:((ViewGroup)->ViewBinding)? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<T> {
return expressionOnCreateViewHolder?.let { it(parent) }?.let { BaseViewHolder(it, expressionViewHolderBinding!!) }!!
@pritomzap
pritomzap / HowToUseBaseAdapter.kt
Created February 9, 2021 19:58
How to user BaseAdapter
//Initiate the adapter with type
var mAdapter = BaseAdapter<String>()
//Sample data
mAdapter.listOfItems = mutableListOf("2","3","2","3","2","3")
mAdapter.expressionViewHolderBinding = {eachItem,viewBinding->
//eachItem will provide the each item in the list, in this case its a string type
//cast the viewBinding with yout layout binding class
pipelines: // start of the pipeline
default: // means that on every push or merge on main or master branch will trigger the pipeline
- step: //step 1
name: Android Sdk Setup
image: androidsdk/android-30 // we are using official android 30 sdk
caches:
- gradle // to cache gradle and not to download the gradle each time.
script:
- bash ./gradlew assembleDebug // you can write other scripts in here.
artifacts:
- step:
name: Installing node.js and npm appcenter-cli
image: node:10.0.0
script:
- npm install // node js package manager installation
- npm install -g appcenter-cli // install app center cli using node js
- appcenter apps list --token "your_token" // in case you want to see all the applications on your account (optional command)
- appcenter distribute release --group Collaborators --file "app/build/outputs/apk/debug/app-debug.apk" --release-notes 'Test release Notes' --app organization_name_or_your_account_name/app_name --token "your_token" --quiet
pipelines: // start of the pipeline
default: // means that on every push or merge on main or master branch will trigger the pipeline
- step: //step 1
name: Android Sdk Setup
image: androidsdk/android-30 // we are using official android 30 sdk
caches:
- gradle // to cache gradle and not to download the gradle each time.
script:
- bash ./gradlew assembleDebug // you can write other scripts in here.
artifacts:
class HmsPushService: HmsMessageService() {
companion object{
private const val TAG = "HmsPushService"
}
override fun onNewToken(p0: String?) {}
override fun onMessageReceived(remoteMessage:RemoteMessage?){
super.onMessageReceived(remoteMessage)
remoteMessage?.dataOfMap?.let {
// Show notification and do other stuffs e.g. pendingIntent