Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
wajahatkarim3 / ActivitiesLaunchingWay.kt
Last active April 3, 2023 08:12
Kotlin Extensions for simpler, easier and funw way of launching of Activities
/**
* Kotlin Extensions for simpler, easier and funw way
* of launching of Activities
*/
inline fun <reified T : Any> Activity.launchActivity (
requestCode: Int = -1,
options: Bundle? = null,
noinline init: Intent.() -> Unit = {})
{
@HarryTylenol
HarryTylenol / Anko+.kt
Last active June 19, 2018 00:29
Anko LiveData Binding
class LifecycleGetter<T : View>(var lifecycleOwner: LifecycleOwner, var view: T)
fun <T : View> T.observe(lifecycleOwner: LifecycleOwner): LifecycleGetter<T> {
return LifecycleGetter(lifecycleOwner, this)
}
fun <T : TextView> LifecycleGetter<T>.liveText(liveData: LiveData<String>): LifecycleGetter<T> {
liveData.observe(lifecycleOwner, Observer {
this.view.text = it
})
@ValCanBuild
ValCanBuild / BottomNavigationBehavior.kt
Last active December 18, 2023 00:04
Full code of a BottomNavigationBehavior which hides itself on scroll and handles Snackbars, FAB and snapping. https://medium.com/@ValCanBuild/scroll-your-bottom-navigation-view-away-with-10-lines-of-code-346f1ed40e9e
/**
MIT License
Copyright (c) 2018 Valentin Hinov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@XinyueZ
XinyueZ / compare_drawable_bitmap.kt
Last active March 19, 2025 11:06
Compare drawable or bitmap content
// Usage:
// drawable1.bytesEqualTo(drawable2)
// drawable1.pixelsEqualTo(drawable2)
// bitmap1.bytesEqualTo(bitmap1)
// bitmap1.pixelsEqualTo(bitmap2)
fun <T : Drawable> T.bytesEqualTo(t: T?) = toBitmap().bytesEqualTo(t?.toBitmap(), true)
fun <T : Drawable> T.pixelsEqualTo(t: T?) = toBitmap().pixelsEqualTo(t?.toBitmap(), true)
var shouldShowRequestPermissionRational = false
for(permission in permissions) {
if (shouldShowRequestPermissionRationale(permission)) {
shouldShowRequestPermissionRational = true
break
}
}
@balrampandey19
balrampandey19 / gist:96bdc04174e58ba3dd03c0aa6f7345af
Created December 29, 2016 07:24
Encrypt retrofit request body with SHA256
/**
* Created by Balram Pandey on 12/29/16.
*/
public class EncryptionInterceptor implements Interceptor {
private static final String TAG = EncryptionInterceptor.class.getSimpleName();
private static final boolean DEBUG = true;
package com.novonetworks.eng.core.util;
/*
* Created by orange on 2016-12-29.
*/
import android.util.Log;
import com.crashlytics.android.Crashlytics;
@Arinerron
Arinerron / permissions.txt
Last active April 14, 2025 21:41
A list of all Android permissions...
android.permission.ACCESS_ALL_DOWNLOADS
android.permission.ACCESS_BLUETOOTH_SHARE
android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.ACCESS_CHECKIN_PROPERTIES
android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY
android.permission.ACCESS_DOWNLOAD_MANAGER
android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED
android.permission.ACCESS_DRM_CERTIFICATES
android.permission.ACCESS_EPHEMERAL_APPS
android.permission.ACCESS_FM_RADIO
@drcarter
drcarter / keep_adb.sh
Created September 30, 2016 02:44
adb 연결이 끊기는거 방지 script.
#!/bin/bash
function monitor_adb () {
adb start-server
echo "[$(date)] adb started"
while [ "$(adb shell echo 1)" ]; do sleep 5; done
echo "[$(date)] adb is broken, restarting"
@QuadFlask
QuadFlask / Text align justify.md
Created June 14, 2016 12:50
[CodeWars] Text align justify

텍스트 정렬 - 공백 균등 분할 하기

조건 :

  • Use spaces to fill in the gaps between words.
  • Each line should contain as many words as possible.
  • Use '\n' to separate lines.
  • Gap between words can't differ by more than one space.
  • Lines should end with a word not a space.
  • '\n' is not included in the length of a line.