Skip to content

Instantly share code, notes, and snippets.

private class UsPhoneNumberFormatter implements TextWatcher {
//This TextWatcher sub-class formats entered numbers as 1 (123) 456-7890
private boolean mFormatting; // this is a flag which prevents the
// stack(onTextChanged)
private boolean clearFlag;
private int mLastStartLocation;
private String mLastBeforeText;
private WeakReference<EditText> mWeakEditText;
@CrandellWS
CrandellWS / height.java
Created April 30, 2016 17:14 — forked from hamakn/height.java
Android: Get height of status, action, navigation bar (pixels)
// status bar height
int statusBarHeight = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = getResources().getDimensionPixelSize(resourceId);
}
// action bar height
int actionBarHeight = 0;
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
@CrandellWS
CrandellWS / DismissCancelDialogActivity.java
Created May 29, 2016 17:24
Alert Dialog Cancel Activity to send onResume event.
import android.app.Activity;
import android.os.Bundle;
/**
* Created by William on 5/29/2016.
*
* new AlertDialog.Builder(this).
*
* use:(OnClickListener){setNegativeButton, setNeutralButton, setPositiveButton}
@CrandellWS
CrandellWS / .travis.yml
Created September 23, 2016 20:47 — forked from mariotaku/.travis.yml
Sign and upload compiled apk to Github releases automatically using Travis CI
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-22.0.0
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.spinBtn{
position: relative;
color: rgba(255,255,255,1);
text-decoration: none;
@CrandellWS
CrandellWS / android-19-circle.yml
Last active February 16, 2017 00:28 — forked from donnfelker/android-19-circle.yml
Sample CircleCI Configuration For an Android App
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/your-app-name/app/build/outputs/apk/
machine:
environment:
@CrandellWS
CrandellWS / circle.yml
Last active January 4, 2018 03:35 — forked from dazza5000/circle.yml
CircleCI Android Configuration Template - circle.yml
#
# Build configuration for Circle CI
#
general:
artifacts:
- /home/ubuntu/AndroidApp/app/build/outputs/apk/
machine:
environment:
/**
* Sets the text size for a Paint object so a given string of text will be a
* given width.
*
* @param paint the Paint to set the text size for
* @param desiredView the desired view
* @param text the text that should be that width
*/
private static float setTextSizeByWidth(Paint paint, View desiredView,
String text) {
public Drawable applyRandomColorToDrawable(Drawable image) {
if (image != null) {
// PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(randomColorInt(),
PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(getRandomAlphaColorInt(),
PorterDuff.Mode.SRC_ATOP);
image.setColorFilter(porterDuffColorFilter);
}
return image;
}
using UnityEngine;
using UnityEngine.Networking;
public class YourClass : Player
{
[Client]
public void Addthing()
{