Skip to content

Instantly share code, notes, and snippets.

View paddyzab's full-sized avatar

Patryk Zabicki paddyzab

  • Julius Baer
  • Zurich
  • 06:20 (UTC +02:00)
View GitHub Profile
@paddyzab
paddyzab / install_on_multiple
Created July 20, 2014 19:32
Small shell script to install apk on multiple devices from adb
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis

Keybase proof

I hereby claim:

  • I am paddyzab on github.
  • I am paddyzab (https://keybase.io/paddyzab) on keybase.
  • I have a public key whose fingerprint is 5034 7928 087B CFE9 D962 C410 8843 B667 1D88 C023

To claim this, I am signing this object:

@paddyzab
paddyzab / Bounds.java
Created February 23, 2016 08:08
Two helper methods to improve semantics of range comparison.
private boolean isOutsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound || upperBound < i);
}
private boolean isInsideRange(int i, int lowerBound, int upperBound) {
return (i < lowerBound && upperBound < i);
}
@paddyzab
paddyzab / LazyListManager
Created September 12, 2013 17:37
LazyListManager implementation from Chet Haase. Read more here: http://graphics-geek.blogspot.de/2013/09/lazy-lists.html.
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@paddyzab
paddyzab / SignatureView.java
Created July 22, 2013 13:17
padding resolution agnostic.
final int indent = Math.round(kcApp.dpi2px(getResources(), 8));
@paddyzab
paddyzab / SignupField.java
Created June 24, 2013 16:39
Formatting the Strings into blocks in EditTExt . Usable for Credit Card Number :).
boolean splitFlag = true;
String splitBlock[] = copyTextField.getText().toString().split(" ");
for (int j = 0; j < splitBlock.length; j++) {
if (splitBlock[j].length() > 4) {
splitFlag = false;
}
}
if (splitFlag) {
copyTextField.setOnKeyListener(new View.OnKeyListener() {
@paddyzab
paddyzab / kcUtilities.java
Created May 2, 2013 12:31
Create clickable Link from Url on a TextView.
public static void addLinks(TextView view, String url) {
if (null != view && null != url) {
view.setLinksClickable(true);
view.setMovementMethod(LinkMovementMethod.getInstance());
String template = "<a href='{0}'>{1}</a>";
String finalText = format(template, url, TextUtils.htmlEncode(view.getText().toString()));
view.setText(Html.fromHtml(finalText));
} else {
if (kcDebug.isDebuggingOn) {
@paddyzab
paddyzab / kcUtilities.java
Created May 2, 2013 12:33
ListViewHeight based on Height and count of Children.
protected static void doSetListViewHeightBasedOnChildren(ListView listView, int extraPixels) {
if (null != listView) {
final ListAdapter listAdapter = listView.getAdapter();
if (null != listAdapter) {
int totalHeight = 0, desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.AT_MOST);
for (int i = listAdapter.getCount(); --i >= 0; ) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
totalHeight += listItem.getMeasuredHeight();
@paddyzab
paddyzab / SlowMode
Created February 10, 2013 09:42
Simple SlowMode I use in mr Cube.
//unity slow mode
public void enableSlowMode()
{
Time.timeScale=0.3f;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
if(audio.isPlaying == false)
{
@paddyzab
paddyzab / RootUtil.java
Created November 20, 2015 13:54
Am I Root
public class RootUtil {
public static boolean isDeviceRooted() {
return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
}
private static boolean checkRootMethod1() {
String buildTags = android.os.Build.TAGS;
return buildTags != null && buildTags.contains("test-keys");
}