Skip to content

Instantly share code, notes, and snippets.

View jermainedilao's full-sized avatar

Jermaine L. Dilao jermainedilao

View GitHub Profile
@jermainedilao
jermainedilao / SimpleListAdapter.kt
Last active July 19, 2021 01:59
Powerful and Reusable ListAdapter for Simple Lists. For more info, check this article: https://medium.com/swlh/powerful-and-reusable-listadapter-using-databinding-for-simple-lists-55ac377fa750
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
@jermainedilao
jermainedilao / HorizontalMarginItemDecoration.kt
Last active August 6, 2020 08:04
Adds horizontal margin to RecyclerView's items. For more information, check this article: https://medium.com/@jermainedilao/android-recyclerview-item-margins-the-right-way-66f8371ee0a1
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
/**
* Adds horizontal margin to RecyclerView's items.
*/
class HorizontalMarginItemDecoration(
/**
* Horizontal margin for all items.
@jermainedilao
jermainedilao / VerticalMarginItemDecoration.kt
Last active August 6, 2020 08:04
Adds vertical margin to RecyclerView's items. For more information, check this article: https://medium.com/@jermainedilao/android-recyclerview-item-margins-the-right-way-66f8371ee0a1
import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
/**
* Adds vertical margin to RecyclerView's items.
*/
class VerticalMarginItemDecoration(
/**
* Vertical margin for all items.
@jermainedilao
jermainedilao / basic_git_push.md
Last active December 4, 2018 08:19
Basic steps on pushing new branch to git repo.

Steps when committing changes.

  1. To add all your changes for commit, run git add .
  2. To commit all changes you added in step 1, run git commit -m "<Insert commit message>"

After committing, follow the steps below.

Steps when pushing a local branch to repo.

  1. Always check for changes from the branch you checked out from before pushing. (let's say your branch was checked out from master. Check if there are any updates from origin/master)
/**
* Bookmarks or removes bookmark from an article.
**/
export const articleBookmarkOrRemoveBookmark = (article) => {
console.log("articleBookmarkOrRemoveBookmark");
// Temporary workaround.
// Replace with bookmarking inside DB then pass the new list from DB to reducers.
article.bookmark = !article.bookmark;
@jermainedilao
jermainedilao / activity_second.xml
Created November 17, 2017 14:59
activity_second layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView2"
@jermainedilao
jermainedilao / item_cheese.xml
Created November 17, 2017 14:13
item_cheese layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
@jermainedilao
jermainedilao / activity_main.xml
Last active November 17, 2017 14:17
activity_main layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.kotlinworkshop.MainActivityKt">
<EditText
android:id="@+id/editText"
@jermainedilao
jermainedilao / CheeseKt.kt
Created November 17, 2017 11:26
Copy this file to your package.
package com.example.kotlinworkshop
object CheeseKt {
val LIST = arrayOf(
"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
"Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
"Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
"Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell",
@jermainedilao
jermainedilao / keybase.md
Created September 19, 2017 02:29
Keybase gist

Keybase proof

I hereby claim:

  • I am jermainedilao on github.
  • I am jermainedilao (https://keybase.io/jermainedilao) on keybase.
  • I have a public key ASAYqNYv59g1VWZPXStMTS5BsE-d6pJe0zS6-9rB96JeDgo

To claim this, I am signing this object: