Skip to content

Instantly share code, notes, and snippets.

View arindamxd's full-sized avatar
🌻
I may be slow to respond.

Arindam Karmakar arindamxd

🌻
I may be slow to respond.
View GitHub Profile
@arindamxd
arindamxd / ImageUtils.java
Last active August 8, 2019 12:20 — forked from tcw165/ImageUtil.java
The Android's image helper class
// Copyright (c) 2016 boyw165
//
// 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
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@arindamxd
arindamxd / WorkerUtils.kt
Created August 8, 2019 10:25
Fetch IP Address
internal fun getIpAddress(useIPv4: Boolean = true): String {
try {
val interfaces = Collections.list(getNetworkInterfaces())
for (network in interfaces) {
val addresses = Collections.list(network.inetAddresses)
for (address in addresses) {
if (!address.isLoopbackAddress) {
val sAddress = address.hostAddress
var isIPv4: Boolean
isIPv4 = sAddress.indexOf(':') < 0
@arindamxd
arindamxd / WorkerUtils.kt
Created August 8, 2019 10:31
Post Notification
/**
* Create a Notification that is shown as a heads-up notification if possible.
*
* For this project, this is used to show a notification so that you know when different steps
* of the background work chain are starting
*
* @param message Message shown on the notification
* @param context Context needed to create Toast
*
@arindamxd
arindamxd / WorkerUtils.kt
Created August 8, 2019 10:32
Write Json to File
/**
* Writes Json/Gson to a temporary file and returns the Uri for the File
*
* @param context Application Context
* @param any File Content
* @param fileName Json File Name
*
* @return Uri for temp file with json
* @throws FileNotFoundException Throws if json file cannot be found
*/
@arindamxd
arindamxd / WorkerUtils.kt
Created August 8, 2019 10:32
Create Zip File
/**
* Create ZIP file and returns the Uri for the zip file
*
* @param context Application Context
* @param files File Paths to be Zipped
* @param fileName ZIP File Name
*
* @return Uri for zip file
* @throws FileNotFoundException Throws if zip file cannot be found
*/
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@arindamxd
arindamxd / build.gradle
Created February 10, 2020 11:56 — forked from stepio/build.gradle
gradle: package *.jar into aar
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
@arindamxd
arindamxd / module-size.gradle
Last active October 6, 2020 06:55
List Configuration Dependency Size
// List Release Configuration Dependencies
tasks.create("dependency-size-all") {
configurations.each {
if (it.isCanBeResolved()) {
listConfigurationDependencies(it)
}
}
}
@arindamxd
arindamxd / .gitignore
Last active April 20, 2020 20:26
git-ignore file
# Built application files
*.apk
*.aar
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
@arindamxd
arindamxd / TaskScheduler.kt
Created October 20, 2023 19:36
TaskScheduler: A backgound task scheduler with a delay and override feature.
package com.arindam.scheduler
import android.os.Handler
import android.os.Looper
import android.util.Log
import java.util.concurrent.CancellationException
import java.util.concurrent.CountDownLatch
import java.util.concurrent.ExecutionException
import java.util.concurrent.Executor
import java.util.concurrent.Executors