<commit_before>package trikita.v;

import android.content.Context;
import android.view.*;
import android.widget.*;

import java.lang.reflect.InvocationTargetException;
import java.util.*;

public class Render {

	interface Renderable {
		Node view();
		ViewGroup getRootView();
	}

	interface AttributeSetter {
		void set(View v);
	}

	public static abstract class SimpleSetter<T> implements AttributeSetter {
		T value;

		public SimpleSetter(T value) {
			this.value = value;
		}
		
		@Override
		public boolean equals(Object obj) {
			return (getClass() == obj.getClass() &&
					((this.value == null && ((SimpleSetter) obj).value == null)
					|| this.value.equals(((SimpleSetter) obj).value)));
		}

		abstract public void set(View v);
	}

	public static class Node {
		List<Node> attrs = new ArrayList<Node>();
		Class<? extends View> viewClass;
		AttributeSetter setter;

		public Node(Class<? extends View> c) {
			this.viewClass = c;
		}

		public Node(AttributeSetter setter) {
			this.setter = setter;
		}
	}

	private static Map<Renderable, Node> mounts = new WeakHashMap<Renderable, Node>();

	public static Node v(final Class<? extends View> cls, final Node ...nodes) {
		return new Node(cls) {{
			for (Node n : nodes) {
				if (n != null) {
					attrs.add(n);
				}
			}
		}};
	}

	public static void render(Renderable r) {
		Node oldValue = mounts.get(r);

		Node virt = r.view();
		mounts.put(r, virt);

		int count = r.getRootView().getChildCount();
		View oldView = null;
		if (count > 0) {
			oldView = r.getRootView().getChildAt(0);
		}
		View v = inflateNode(r.getRootView().getContext(), virt, oldValue, oldView);

		// if inflate returned a different view - add it to the parent
		if (count == 0) {
			r.getRootView().addView(v); // New view
		} else if (count > 0 && r.getRootView().getChildAt(0) != v) {
			r.getRootView().removeAllViews();
			r.getRootView().addView(v); // Old view has been changed
		}
	}
<commit_msg>added flag to avoid recursive rendering, fixes seek bar change rendering<commit_after>package trikita.v;

import android.content.Context;
import android.view.*;
import android.widget.*;

import java.lang.reflect.InvocationTargetException;
import java.util.*;

public class Render {

	interface Renderable {
		Node view();
		ViewGroup getRootView();
	}

	interface AttributeSetter {
		void set(View v);
	}

	public static abstract class SimpleSetter<T> implements AttributeSetter {
		T value;

		public SimpleSetter(T value) {
			this.value = value;
		}
		
		@Override
		public boolean equals(Object obj) {
			return (getClass() == obj.getClass() &&
					((this.value == null && ((SimpleSetter) obj).value == null)
					|| this.value.equals(((SimpleSetter) obj).value)));
		}

		abstract public void set(View v);
	}

	public static class Node {
		List<Node> attrs = new ArrayList<Node>();
		Class<? extends View> viewClass;
		AttributeSetter setter;

		public Node(Class<? extends View> c) {
			this.viewClass = c;
		}

		public Node(AttributeSetter setter) {
			this.setter = setter;
		}
	}

	private static Map<Renderable, Node> mounts = new WeakHashMap<Renderable, Node>();

	public static Node v(final Class<? extends View> cls, final Node ...nodes) {
		return new Node(cls) {{
			for (Node n : nodes) {
				if (n != null) {
					attrs.add(n);
				}
			}
		}};
	}

	private static boolean isRendering = false;

	public static void render(Renderable r) {
		if (isRendering) {
			return; // Don't render recursively
		}
		isRendering = true;
		Node oldValue = mounts.get(r);

		Node virt = r.view();
		mounts.put(r, virt);

		int count = r.getRootView().getChildCount();
		View oldView = null;
		if (count > 0) {
			oldView = r.getRootView().getChildAt(0);
		}
		View v = inflateNode(r.getRootView().getContext(), virt, oldValue, oldView);

		// if inflate returned a different view - add it to the parent
		if (count == 0) {
			r.getRootView().addView(v); // New view
		} else if (count > 0 && r.getRootView().getChildAt(0) != v) {
			r.getRootView().removeAllViews();
			r.getRootView().addView(v); // Old view has been changed
		}
		isRendering = false;
	}

{'fraction_non_alphanumeric': 0.13802336903602727, 'fraction_numerical': 0.0024342745861733205, 'mean_word_length': 3.490710382513661, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1063301', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1328, 'n_words': 377}