Skip to content

Instantly share code, notes, and snippets.

Love Lindström ntlv

  • Stockholm, Sweden
View GitHub Profile
@ntlv
ntlv / bfs_view_tree_to_json.java
Created Aug 30, 2016
Transform a Android view tree into a json tree.
View bfs_view_tree_to_json.java
//Breadth first view tree -> json transformation
private static final String CHILDREN = "children";
@SuppressWarnings("unchecked")
private Object extract(ViewGroup container) throws JSONException {
final Map<String, Object> result = new HashMap<>(); //create root node
List<Object> currentNodeList = new LinkedList<>();
View keybase.md

Keybase proof

I hereby claim:

  • I am ntlv on github.
  • I am ntlv (https://keybase.io/ntlv) on keybase.
  • I have a public key whose fingerprint is 3FFB 6691 6CAB FA1B E10D 3853 7909 D311 2298 F4A3

To claim this, I am signing this object:

@ntlv
ntlv / MainActivity.java
Last active Jan 1, 2016
show a fragment
View MainActivity.java
private void showFragmentRoutine(Class<?> fragment, String tag) {
try {
FragmentManager fm = getFragmentManager();
if (fm.findFragmentByTag(tag) != null) {
fm.popBackStack(tag, 0);
} else {
fm.beginTransaction()
.replace(R.id.container, (Fragment) Class.forName(fragment.getName()).newInstance(), tag)
.addToBackStack(tag)
.commit();
You can’t perform that action at this time.