Skip to content

Instantly share code, notes, and snippets.

View pedrofsn's full-sized avatar

Pedro Francisco de Sousa Neto pedrofsn

View GitHub Profile
package com.geekorum.geekdroid.navigation
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import androidx.core.content.res.use
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
@humblehacker
humblehacker / mutablelivedata.md
Last active March 25, 2023 02:14
Don't expose MutableLiveData
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active September 28, 2023 15:01
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@florina-muntenescu
florina-muntenescu / Data.kt
Last active April 16, 2024 19:48
Using RoomDatabase#Callback to pre-populate the database - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@nosix
nosix / MainActivity.kt
Last active May 26, 2018 02:22
DialogFragment for Android (SDK 22) in Kotlin 1.0.2
class MainActivity : AppCompatActivity(), SeekDialogFragment.SeekDialogListener {
companion object {
private val TAG = MainActivity::class.qualifiedName;
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
@parmentf
parmentf / GitCommitEmoji.md
Last active April 24, 2024 13:34
Git Commit message Emoji
@kosiara
kosiara / proguard-rules.pro
Created November 3, 2015 15:39
RxJava RxAndroid Proguard rules
#build.gradle
#
# compile 'io.reactivex:rxandroid:1.0.1'
# compile 'io.reactivex:rxjava:1.0.14'
# compile 'io.reactivex:rxjava-math:1.0.0'
# compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
# rxjava
-keep class rx.schedulers.Schedulers {
public static <methods>;
@cmelchior
cmelchior / SerializeToJson.java
Last active September 20, 2022 04:30
Serialize Realm objects to JSON using GSON
// GSON can parse the data.
//
// Deserialization:
// Note there is a bug in GSON 2.3.1 that can cause it to StackOverflow when working with RealmObjects.
// To work around this, use the ExclusionStrategy below or downgrade to 1.7.1
// See more here: https://code.google.com/p/google-gson/issues/detail?id=440
//
// Serialization:
// <Type>RealmProxy objects are created by the Realm annotation processor. They are used to control
// access to the actual data instead of storing them in fields and it is therefore them we need to register a
@yqritc
yqritc / gist:ccca77dc42f2364777e1
Last active March 29, 2024 10:25
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0