Skip to content

Instantly share code, notes, and snippets.

View AniketSK's full-sized avatar
😀
Available for consulting on Android, maybe fulltime for the right company!

Aniket Kadam AniketSK

😀
Available for consulting on Android, maybe fulltime for the right company!
View GitHub Profile
@antarikshc
antarikshc / get-contacts-android.kt
Last active May 19, 2019 08:05
Snippet for fetching contacts in Android
// Declare the data class in Contact.kt
data class Contact(
val id: String,
val name: String,
val thumbnailUri: String?
)
// Following code goes into Fragment or Activity file
// This snippet is used in Android Fragments. Change it accordingly for using it in Activities
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
private fun contacts(): Flowable<SimpleContact> =
Flowable.generate<SimpleContact, Cursor>(
Callable<Cursor> {
contentResolver.query(Contacts.CONTENT_URI,
arrayOf(Contacts.DISPLAY_NAME, Contacts.STARRED),
null, null,
"${Contacts.DISPLAY_NAME} ASC")
},
BiFunction<Cursor, Emitter<SimpleContact>, Cursor> { cursor, emitter ->
@JoseAlcerreca
JoseAlcerreca / ObservableViewModel.kt
Last active February 28, 2021 00:07
An Observable ViewModel for Data Binding and Architecture Components
/*
* Copyright (C) 2018 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