Skip to content

Instantly share code, notes, and snippets.


Prokash Sarkar prokash-sarkar

View GitHub Profile
View Time Validation (WACABS).java
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
public class HelloWorld {
prokash-sarkar / Android Transparent Color Codes
Created Jan 12, 2016
A list of transparent color codes that can be used to get the exact amount of transparency.
View Android Transparent Color Codes
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
prokash-sarkar / Facebook KeyHash
Created Dec 18, 2017
A simple code snippet for generating Facebook KeyHash in Android
View Facebook KeyHash
public void getKeyHash(Context context) {
try {
PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
Log.i("Base64", Base64.encodeToString(md.digest(),Base64.NO_WRAP));
} catch (PackageManager.NameNotFoundException e) {
Log.d("Name not found", e.getMessage(), e);
View android-release-aar.gradle
// ./gradlew clean build generateRelease
apply plugin: 'maven'
def groupId = project.PUBLISH_GROUP_ID
def artifactId = project.PUBLISH_ARTIFACT_ID
def version = project.PUBLISH_VERSION
def localReleaseDest = "${buildDir}/release/${version}"
task androidJavadocs(type: Javadoc) {
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
prokash-sarkar / File Header.kt
Created Sep 8, 2019
IntellijIDEA File Header Example
View File Header.kt
@author ${USER}
@version 1.0
prokash-sarkar / Scoping Functions.kt
Created Sep 15, 2019
Exmaples of 5 Kotlin Scoping functions, Run, With, Let, Apply, Also
View Scoping Functions.kt
class ScopingFunctions {
fun main() {
val firstPerson = Person("Prokash", 28, "Programmer")
val secondPerson = Person("Elizabeth", 34, "Singer")
//Calls the specified function block with this value as its receiver and returns its result.
run {
if (firstPerson.age > secondPerson.age) firstPerson else secondPerson
prokash-sarkar / LiveDataReactiveStreams.kt
Created Sep 28, 2019
Using LiveDataReactiveStreams to convert Flowable
View LiveDataReactiveStreams.kt
fun <T> LiveData<T>.toFlowable(owner: LifecycleOwner): Flowable<T> =
Flowable.fromPublisher(LiveDataReactiveStreams.toPublisher(owner, this))
fun <T> Flowable<T>.toLiveData(): LiveData<T> = LiveDataReactiveStreams.fromPublisher(this)
View BaseViewModel.kt
abstract class BaseViewModel: ViewModel()
protected val _viewState: MutableLiveData<ViewState> = MutableLiveData()
// don't expose the MutableLiveData outside of the class
val viewState: LiveData<ViewState>
get() = _viewState // only getter / no setter
fun setViewState(viewState: ViewState){
prokash-sarkar / AuthenticationInterceptor.kt
Last active Jan 27, 2021
Example of runtime modification of an auth token and base URL of the okHttp client using Interceptor and Dagger injection.
View AuthenticationInterceptor.kt
class AuthenticationInterceptor @Inject constructor(baseUrl: String, jwtToken: String) :
Interceptor {
private var baseUrl: HttpUrl
private var jwtToken: String
companion object {
private const val LOG_TAG = "AuthenticationInterceptor:"
private const val AUTHORIZATION = "Authorization"
private const val BEARER = "Bearer"