Skip to content

Instantly share code, notes, and snippets.

@artem-zinnatullin
artem-zinnatullin / MyApp.java
Last active January 15, 2023 13:04
If you need to set one font for all TextViews in android application you can use this solution. It will override ALL TextView's typefaces, includes action bar and other standard components, but EditText's password font won't be overriden.
public class MyApp extends Application {
@Override
public void onCreate() {
TypefaceUtil.overrideFont(getApplicationContext(), "SERIF", "fonts/Roboto-Regular.ttf"); // font from assets: "assets/fonts/Roboto-Regular.ttf
}
}
@bojan
bojan / .gitignore
Last active August 8, 2022 07:43
Git ignore file for development on Apple platforms. Covers Xcode, AppCode, SPM, Carthage, CocoaPods, Fastlane, etc.
# --------------------------------
# macOS temporary files
# --------------------------------
.DS_Store
*.lock
*.swp
# --------------------------------
# Xcode
# --------------------------------
@staltz
staltz / introrx.md
Last active July 26, 2024 04:24
The introduction to Reactive Programming you've been missing
@daniellevass
daniellevass / android_material_design_colours.xml
Last active June 5, 2024 13:54
Android Material Design Colours
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
@codediodeio
codediodeio / database.rules.json
Last active July 24, 2024 21:05
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@kobeumut
kobeumut / UiThreadExample.java
Last active August 25, 2017 07:03
thread that has not called Looper.prepare() Android Error
runOnUiThread(new Runnable() {
public void run() {
//Your code is in here
}
});
@kobeumut
kobeumut / UnabletoAddWindow.java
Created August 11, 2017 08:50
This is a common problem, you can not reach the context first and therefore it is null. What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(), context etc. your problem will be resolved.
/*
This is a common problem, you can not reach the context first and therefore it is null.
What you need to do here is that if you use "ActivityName.this" instead of getApplicationContext(),
context etc. your problem will be resolved.
*/
//For example Alert Dialog;
AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); //Activity name
alertDialog.setMessage("Test Messages");
alertDialog.setPositiveButton("OK", listener);
AlertDialog alert = alertDialog.create();
@kobeumut
kobeumut / MultiDexSample.java
Last active August 25, 2017 07:03
MultiDex Error
android {
...
defaultConfig {
multiDexEnabled true
...
}
}
dependencies {
// add dependency
@kobeumut
kobeumut / hideKeyboard.kt
Created August 21, 2017 07:06
Close opened keyboard on Android programatically
//For Kotlin
val inputManager:InputMethodManager =getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(currentFocus.windowToken, InputMethodManager.SHOW_FORCED)
//For Java
InputMethodManager inputManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.SHOW_FORCED);
@kobeumut
kobeumut / kotlin-Restriction-Vetoable.kt
Last active October 3, 2017 13:25
if you only want to use within your restriction you use vetoable
//if you only want to use within your restriction you use vetoable
var name by vetoable("adali") { property: KProperty<*>, oldValue, newValue ->
newValue.startsWith("A")
}
name = "umut"
// # : name = "adali" ->because name not startwith S so
name = "Adanalı"
// # : name = "adanali" -> that's it