Skip to content

Instantly share code, notes, and snippets.

View nisd93's full-sized avatar
🎯
Focusing

Nisarg nisd93

🎯
Focusing
View GitHub Profile
@quentin41500
quentin41500 / CartManager.kt
Last active June 8, 2021 12:28
Using Sealed class and LiveData to handle network request through the repository layer.
/**
* Observable manager for saving the [Cart]'s resource information.
*/
class CartManager : LiveData<Resource<Cart?>>() {
init {
value = Success(null)
}
/**
@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`.
@soulduse
soulduse / ApiInterface.kt
Last active May 7, 2022 08:48
ver.2) Example of usage kotlin-coroutines-retrofit
interface ApiInterface {
@GET("User")
fun getUser(
@Query("user_id") userId: String
): Deferred<User>
}
@nickbutcher
nickbutcher / rainbow.xml
Last active January 25, 2023 17:09
Demonstrating using VectorDrawable gradients to create a rainbow effect. See https://twitter.com/crafty/status/1011922414983352320
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Google Inc.
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 distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
@chrisbanes
chrisbanes / Animators.kt
Last active March 7, 2024 11:13
Material Image Loading treatment for Android
/*
* Copyright 2018 Google, Inc.
*
* 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
@robertoestivill
robertoestivill / md_colors.xml
Last active June 18, 2018 08:42
Material Design color palette for Android applications.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
References
- https://www.materialpalette.com/colors
- https://www.materialui.co/colors
- https://material-ui.com/style/color/
-->
@AkshayChordiya
AkshayChordiya / DateHeaderHelper.kt
Last active May 26, 2023 13:39
Use these date related top-level Kotlin functions to show sections like "Today", "Yesterday" and so on
import org.joda.time.LocalDate
/**
* @return true if the supplied date is in the future else false
*/
fun isUpcoming(millis: Long): Boolean {
return !isTomorrow(millis) && LocalDate(millis).isAfter(LocalDate.now())
}
/**
@chrisbanes
chrisbanes / code.kt
Last active August 10, 2023 10:46
Night Mode inflater
/*
* Copyright 2017 Google, Inc.
*
* 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
/*
* 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
@cketti
cketti / android-26-sources.md
Last active August 14, 2019 12:08
Build your own android-26 sources

If you are annoyed that "Sources for Android 26" are not yet available via SDK manager, this might be for you:

  1. Collect source files
mkdir android-sdk-source-build
cd android-sdk-source-build

mkdir -p frameworks/base