Skip to content

Instantly share code, notes, and snippets.

View JeffMcKnight's full-sized avatar

Jeff McKnight JeffMcKnight

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jeffmcknight on github.
  • I am jeffmcknight (https://keybase.io/jeffmcknight) on keybase.
  • I have a public key ASCWuYLby__d_yqoLpV3pBV0erYatf0GO1Z4nzM6ysIN9Ao

To claim this, I am signing this object:

@JeffMcKnight
JeffMcKnight / ArrayIterator.java
Created May 31, 2019 06:13
Iterator backed by an array of integers which it interprets as a set of pairs, where the first item of the pair indicates how many values should be returned, and the second item of the pair indicates the value to be returned.
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
* Iterator backed by an array of integers which it interprets as a set of pairs, where the
* first item of the pair indicates how many values should be returned, and the second
* item of the pair indicates the value to be returned. So, for example, when we iterate over the
* array <b>{3, 11, 0, 22, 2, 33}</b>, an ArrayIterator should return: <b><i>11, 11, 11, 33, 33</i></b>.
* <br>
* <br>
@JeffMcKnight
JeffMcKnight / ViewUtil.java
Created July 2, 2019 17:34
Static method to return the Tag attribute of an Android View, or, if that is missing, return the name of the ID attribute
public class ViewUtil {
public static String getTagOrIdName(View view) {
if (view != null) {
if (view.getTag() != null) {
return view.getTag().toString();
} else {
return view.getResources().getResourceEntryName(view.getId());
}
} else {