Skip to content

Instantly share code, notes, and snippets.

View devindi's full-sized avatar
🍺
beer

Andrew devindi

🍺
beer
View GitHub Profile
@devindi
devindi / NetworkStateActivity
Created March 13, 2019 13:30
Sample code to demonstrate connectivity manager
class MainActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val view = View(this)
setContentView(view)
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
@devindi
devindi / MapBitmapGenerator
Created April 11, 2018 09:06
Create bitmap with map part by coordinates and zoom. Used osmdroid as map source
class MapBitmapGenerator(private val cacheManager: CacheManager, private val tileSource: OnlineTileSourceBase, private val cache: IFilesystemCache) {
fun createBitmap(rect: BoundingBox, zoom: Int): Bitmap {
var tilesCoverage = CacheManager.getTilesCoverage(rect, zoom)
tilesCoverage.forEach {
if (cacheManager.downloadingAction.tileAction(it)) {
throw IllegalStateException("Failed to load tile")
}
}
tilesCoverage = tilesCoverage.sortedWith(compareBy({ MapTileIndex.getX(it) }, { MapTileIndex.getY(it) }))
@devindi
devindi / localization.gradle
Last active March 19, 2017 20:22
Continuous localization
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.xlson.groovycsv:groovycsv:1.1'
}
}
import static com.xlson.groovycsv.CsvParser.parseCsv
@devindi
devindi / Tree.java
Created December 24, 2016 08:13
Printable binary tree
package com.devindi.tree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("ALL")
public class Tree<T extends Comparable> {
private Node<T> root;
package eu.mihin.sample;
import android.app.Application;
import android.os.AsyncTask;
import android.util.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
public static String getCroreFormat(long value) {
if (value > TEN_MILLION){
String suffix = String.format(".%02.0f Cr", 1000*value/TEN_MILLION % 1000 / 10d);
value = value / TEN_MILLION;
return formatToIndian(value) + suffix;
} else {
return formatToIndian(value);
}
}
@devindi
devindi / commit-msg
Last active August 29, 2015 14:08
Useful git hooks.
#!/bin/bash
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.NinePatch;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**