Skip to content

Instantly share code, notes, and snippets.

View kalaiselvan369's full-sized avatar
🎯
Focusing

Kalaiselvan kalaiselvan369

🎯
Focusing
View GitHub Profile
@kalaiselvan369
kalaiselvan369 / git-commands.txt
Last active November 26, 2018 05:49
Git commands
echo "# fresco-image-library-samples" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/glidodroid/fresco-image-library-samples.git
git push -u origin master
*** Create patch for last commit ***
git show HEAD > some-patch0001.patch
##Method in the same class:
/** See also {@link #myMethod(String)}. */
void foo() { ... }
##Method in a different class, either in the same package or imported:
/** See also {@link MyOtherClass#myMethod(String)}. */
void foo() { ... }
##Method in a different package and not imported:
@kalaiselvan369
kalaiselvan369 / Resources.java
Last active November 26, 2018 05:47
Frequently used android functions.
Usage 1:
ContextCompat.getColor(context, R.color.color_name)
Usage 2:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
yourTitle.setTextColor(getActivity().getResources().getColor(android.R.color.white, getActivity().getTheme()));
}else {
yourTitle.setTextColor(getActivity().getResources().getColor(android.R.color.white));
}
NumberPicker picker = new NumberPicker(this);
picker.setMinValue(0);
picker.setMaxValue(2);
picker.setDisplayedValues( new String[] { "Belgium", "France", "United Kingdom" } );
@kalaiselvan369
kalaiselvan369 / TextView.xml
Last active November 26, 2018 05:45
xml contents
<?xml version="1.0" encoding="utf-8"?>
style="?android:listSeparatorTextViewStyle" // applied for text view with bottom border.
@kalaiselvan369
kalaiselvan369 / app_build.gradle
Created April 17, 2020 10:49
Spotless and pre-commit
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'com.google.gms.google-services'
apply from: "$rootDir/spotless.gradle"
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
@kalaiselvan369
kalaiselvan369 / pre-commit.bash
Last active April 17, 2020 11:04
Precommit hooks that runs spotless code formatter.
#!/bin/bash
LC_ALL=C
RED='\033[0;1;31m'
NC='\033[0m' # No Color
echo "Running git pre-commit hook"
local_branch="$(git rev-parse --abbrev-ref HEAD)"
@kalaiselvan369
kalaiselvan369 / build.gradle
Created April 17, 2020 11:11
Project build gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$androidGradlePluginVersion"
@kalaiselvan369
kalaiselvan369 / spotless.gradle
Created April 17, 2020 11:20
Gradle file for spotless plugin
apply plugin: 'com.diffplug.gradle.spotless'
spotless {
kotlin {
target '**/*.kt'
ktlint("0.36.0")
//ktlint("0.36.0").userData(['disabled_rules': 'no-wildcard-imports'])
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()