Skip to content

Instantly share code, notes, and snippets.

View Fbada006's full-sized avatar
🎯
Leveling up

Ferdinand Bada Fbada006

🎯
Leveling up
View GitHub Profile
@Fbada006
Fbada006 / activity_main.xml
Created May 3, 2020 06:48
Layout for ViewPager2 with a LinearLayout for sliding dots
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/slidingViewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
@Fbada006
Fbada006 / active_dot.xml
Created May 3, 2020 06:44
Active dot for sliding tabs
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:shape="oval"
android:useLevel="true">
<size
android:width="12dp"
android:height="12dp" />
@Fbada006
Fbada006 / non_active_dot.xml
Created May 3, 2020 06:43
None active dot for autoscroll images in
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:shape="oval"
android:useLevel="true">
<size
android:width="8dp"
android:height="8dp" />
class PojoAdapter :
androidx.recyclerview.widget.ListAdapter<Pojo, PojoAdapter.POJOViewHolder>(POJODiffCallback()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): POJOViewHolder {
return POJOViewHolder.from(parent)
}
override fun onBindViewHolder(holder: POJOViewHolder, position: Int) {
val pojoItem = getItem(position)
holder.bind(pojoItem)
viewModel.pojoLiveData.observe(this, Observer { pojoList ->
if (pojoList != null) {
myAdapter.submitList(pojoList)
}
})
@Fbada006
Fbada006 / MyAdapter.kt
Last active April 19, 2020 07:58
A sample of a ListAdapter in Android and the accompanying fragment or activity implementation
import android.annotation.SuppressLint
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
class MyAdapter() : ListAdapter<Pojo, MyAdapter.MyNewsHolder>(PojoDiffCallback()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyNewsHolder {
return MyNewsHolder()
}
@Fbada006
Fbada006 / RecyclerViewTemplate.kt
Created August 15, 2019 19:26
This is a template for generating a RecyclerView from Android Studio
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.ListAdapter
//TODO: Import your model when you first use this template
const functions = require('firebase-functions');
// Firebase admin
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
// The snapshot to the user's tokens.
// /* Trigger when a new document is created */
exports.createdMatchNotification = functions.firestore
// Add the document path to your collection mine is called matches
.document('match/{documentId}')
.onCreate((snap, context) => {